Post on 20-Jun-2020
Differential Equations
� Definitions
� Finite Differences
� Taylor Series based Methods: Euler Method
� Runge-Kutta Methods
⇒ Improved Euler, Midpoint methods⇒ Runge Kutta (2nd, 4th order) methods
� Predictor-Corrector Methods
⇒ Euler-Trapezoidal, Milne Simpson Methods
ITCS 4133/5133: Numerical Comp. Methods/Analysis 1 Ordinary Differential Equations
Motivation
� Engineering problems require estimates of derivatives of functionsfor analysis
� Approaches:
1. Use function differences between neighboring points, divided bydistance between the points,
2. Fit a function to the relationship between the independent anddependent variable (say an nth order polynomial) and use itsderivative
ITCS 4133/5133: Numerical Comp. Methods/Analysis 2 Ordinary Differential Equations
Differential Equations
An equation that defines a relationship between an unknown function and oneor more derivatives
dy
dx= f (x, y)
d2y
dx2= f
(x, y,
dy
dx
)Definitions:
� Order: is the order of the highest derivative
� f (.) may be a function any combination of x, y, and (in case of sec-ond order) dy/dx
� Ordinary Diff. Eq.: f (.) is a function of a single variable
ITCS 4133/5133: Numerical Comp. Methods/Analysis 3 Ordinary Differential Equations
Definitions(contd)
� Linearity: determined by whether f (.) is linear in x, y, dy/dx,
� Solution: is a function of the independent variable.
� Boundary Conditions: constraints placed on the solution space.
ITCS 4133/5133: Numerical Comp. Methods/Analysis 4 Ordinary Differential Equations
Example Applications
1. Electrical Circuit: Relationship between current and time
Ldi
dt+ Ri = E, i = 0 at t = 0
2. 1D Heat Flow:
H = KAdT
dr
where K is the coeff. of thermal conductivity, H is the quantity ofheat, A is the area perpendicular to heat flow, T is the temperature.
ITCS 4133/5133: Numerical Comp. Methods/Analysis 5 Ordinary Differential Equations
Example Applications
ITCS 4133/5133: Numerical Comp. Methods/Analysis 6 Ordinary Differential Equations
Reminder:Finite Differences
Forward Difference
df (x)
dx=f (x + ∆x)− f (x)
∆x
Backward Difference
df (x)
dx=f (x)− f (x−∆x)
∆x
Two Step Method
df (x)
dx=f (x + ∆x)− f (x−∆x)
2∆x
ITCS 4133/5133: Numerical Comp. Methods/Analysis 7 Ordinary Differential Equations
Taylor Series Based Methods:Euler’s Method
Given
y′ = f (x, y)
treat f (x, y) as a constant and the derivative as a tangent (quotient)
y′ =y1 − y0
x1 − x0
Thus,
y1 − y0 = f (x0, y0)(x1 − x0)
y1 = y0 + hf (x0, y0)
where h = (b− a)/n, n is the number of values of x.
ITCS 4133/5133: Numerical Comp. Methods/Analysis 8 Ordinary Differential Equations
Taylor Series Based Methods:Euler’s Method
y1 = y0 + hf (x0, y0)
ITCS 4133/5133: Numerical Comp. Methods/Analysis 9 Ordinary Differential Equations
Euler’s method: From Taylor Series
� Taylor’s series, truncated to the first term is given by
y(x + h) = y(x) + hy′(x) +h2
2y′′(η)
� Euler’s method follows, since y(x + h) = yi+1, y(x) = yi, y′(x) =
f (xi, yi), x < η < x + h
ITCS 4133/5133: Numerical Comp. Methods/Analysis 10 Ordinary Differential Equations
Euler’s Method: Example 1
◦ y′ = x + y, 0 ≤ x ≤ 1, y(0) = 2
ITCS 4133/5133: Numerical Comp. Methods/Analysis 11 Ordinary Differential Equations
Euler’s Method: Example 2
◦ y′ =
{y(−2x + 1/x), x 6= 0
1 x = 0
where y(0) = 0.0, 0 ≤ x ≤ 2.0.
ITCS 4133/5133: Numerical Comp. Methods/Analysis 12 Ordinary Differential Equations
Euler’s Method: Algorithm
ITCS 4133/5133: Numerical Comp. Methods/Analysis 13 Ordinary Differential Equations
Euler’s Method: Notes, Errors
� dydx
is evaluated at beginning of interval
� Error e increases with the width of (x − x0), as higher order termsbecome more important
� Also known as one-step Euler method
� Local Error: Range over a single step size; measure difference be-tween numerical solution at end of step (starting with exact solutionat beginning of the step) and the exact solution at end of step.
� Global Error: Accumulates over the range of the solution; measuredas the difference between numerical and exact solutions.
� Errors using Euler’s method can be approximated using the secondorder term of the Taylor series:
ε =h2
2y′′(η)
ITCS 4133/5133: Numerical Comp. Methods/Analysis 14 Ordinary Differential Equations
Runge-Kutta Methods
� To improve on Euler’s method, we can use additional terms of theTaylor series.
� Problem: Need to compute additional higher order derivatives, whichcan be problematic for complex functions.
� Runge-Kutta methods determine the y value (dependent variable)based on the value at the beginning of the interval, step size andsome representative slope over the interval
� Euler’s and the mnodified Euler’s methods are special cases of thesetechniques
� Runge-Kutta methods are classified based on their order; fourth or-der is the most commonly used.
� Higher order derivates are not required of these methods
ITCS 4133/5133: Numerical Comp. Methods/Analysis 15 Ordinary Differential Equations
Second Order Runge-Kutta Methods
General Form:
k1 = hf (xn, yn)//slope at beginning of intervalk2 = hf (xn + c2h, yn + a21k1)//slope at end of interval
Iteration:
yn+1 = yn + w1k1 + w2k2
Example Methods:
◦ Improved Euler: c2 = 1, a21 = 1, w1 = w2 = 0.5
◦ Midpoint: c2 = 1, a21 = 2/3, w1 = 0, w2 = 1
◦ Heun: c2 = 2/3, a21 = 2/3, w1 = 1/4, w2 = 3/4
ITCS 4133/5133: Numerical Comp. Methods/Analysis 16 Ordinary Differential Equations
Second Order Runge Kutta Methods: MidpointMethod
� Idea: Approximate the value of y at (x + h/2) by summing currentvalue of y and one-half the change in y from Euler’s method:
k1 = hf (xi, yi)// change in y : Euler’s methodk2 = hf (xi + h/2, yi + k1/2)// change in y: slope est. at midpoint
Iteration:
yi+1 = yi + k2
ITCS 4133/5133: Numerical Comp. Methods/Analysis 17 Ordinary Differential Equations
Runge Kutta Methods:Improved Euler’sMethod
� A second order Runge-Kutta method.
� Estimates of y′ at start and midpoint of interval are averaged to pro-duce a revised estimate of y at end of interval.
� Procedure:
k1 = hf (xn, yn)
k2 = hf (xn + h, yn + k1)
yn+1 = yn +1
2k1 +
1
2k2
ITCS 4133/5133: Numerical Comp. Methods/Analysis 18 Ordinary Differential Equations
Improved Euler’s Method: Procedure
⇒ Evaluate y′ at start of interval
⇒ Estimate y at end of interval using Euler’s method
⇒ Evaluate y′ at end of interval
⇒ Compute average slope
⇒ Compute a revised y at end of interval using average slope
ITCS 4133/5133: Numerical Comp. Methods/Analysis 19 Ordinary Differential Equations
Example : Midpoint and Improved Euler’sMethods
ITCS 4133/5133: Numerical Comp. Methods/Analysis 20 Ordinary Differential Equations
Classic Runge-Kutta Method: Fourth Order
A commonly used class of Runge-Kutta methods.
k1 = hf (xi, yi)
k2 = hf (xi + 0.5h, yi + 0.5k1)
k3 = hf (xi + 0.5h, yi + 0.5k2)
k4 = hf (xi + 0.5h, yi + k3)
Iteration:
yi+1 = yi +1
6(k1 + 2k2 + 2k3 + k4)
ITCS 4133/5133: Numerical Comp. Methods/Analysis 21 Ordinary Differential Equations
Classic Runge-Kutta Method: Algorithm
ITCS 4133/5133: Numerical Comp. Methods/Analysis 22 Ordinary Differential Equations
Classic Runge-Kutta Method: Example 1
ITCS 4133/5133: Numerical Comp. Methods/Analysis 23 Ordinary Differential Equations
Classic Runge-Kutta Method: Example 2
ITCS 4133/5133: Numerical Comp. Methods/Analysis 24 Ordinary Differential Equations
Predictor-Corrector Methods
� Euler’s method and Runge-Kutta methods generally require stepsizes to be small, else might not yield precise solutions
� Predictor-Corrector methods can be used to increase the accuracyof solutions
� These methods use solutions from previous intervals to project tothe end of the next interval, followed by iterative refinement.
� Disadvantage: Requires values from previous intervals - one-stepmethods such as the Euler’s method have to be used.
� Predictor: Gets an initial estimate at the end of the interval.
� Corrector: Improves the estimate by iteration.
ITCS 4133/5133: Numerical Comp. Methods/Analysis 25 Ordinary Differential Equations
Euler-Trapezoidal Method
� Uses Euler’s method as predictor and Trapezoidal rule as cor-rector
Predictor
yi+1,0 = yi,∗ + hdy
dx
∣∣∣∣i,∗
Corrector
yi+1,j = yi,∗ +h
2
[dy
dx
∣∣∣∣i,∗
+dy
dx
∣∣∣∣i+1,j−1
]
ITCS 4133/5133: Numerical Comp. Methods/Analysis 26 Ordinary Differential Equations
Euler-Trapezoidal Method: Example
ITCS 4133/5133: Numerical Comp. Methods/Analysis 27 Ordinary Differential Equations
Euler-Trapezoidal Method: Example
ITCS 4133/5133: Numerical Comp. Methods/Analysis 28 Ordinary Differential Equations
Milne-Simpson Method
� Uses Milne’s method as predictor and Simpson’s rule as cor-rector
Predictor
yi+1,0 = yi−3,∗ +4h
3
[2dy
dx
∣∣∣∣i,∗− dy
dx
∣∣∣∣i−1,∗
+ 2dy
dx
∣∣∣∣i−2,∗
]Corrector
yi+1,j = yi−1,∗ +h
3
[dy
dx
∣∣∣∣i+1,j−1
+ 4dy
dx
∣∣∣∣i,∗
+dy
dx
∣∣∣∣i−1,∗
]
ITCS 4133/5133: Numerical Comp. Methods/Analysis 29 Ordinary Differential Equations
Milne-Simpson Method: Example
ITCS 4133/5133: Numerical Comp. Methods/Analysis 30 Ordinary Differential Equations
Milne-Simpson: Example
ITCS 4133/5133: Numerical Comp. Methods/Analysis 31 Ordinary Differential Equations
ITCS 4133/5133: Numerical Comp. Methods/Analysis 32 Ordinary Differential Equations