Initial Value Problems (Ivps) : Y: Dependent Variable, T: Independent Variable If F F (Y) 7 Autonomous Ode
Initial Value Problems (Ivps) : Y: Dependent Variable, T: Independent Variable If F F (Y) 7 Autonomous Ode
• Here we will focus on: First order linear IVPs. IVPs involving higher
order ODEs can be rendered as a system of first order ODEs.
Euler method (Euler explicit or Euler forward) • If h is sufficiently small, then we can approximate
• Consistency: A numerical scheme is said to be consistent with the • Stability: Errors propagate 7→ Investigation of unbounded growth of
ODE being discretized, if the local truncation error tends to zero as the errors
mesh size tends to zero.
• Error analysis for general case 7→ can be difficult!
1 From Taylor series expansion 7→ Local truncation error Et (h) = O(h2 ) • To get insight: Simple case
2 Finite precision calculation 7→ Round off errors dy
= −ay, y(0) = y0 , a > 0(constant)
dt
3 Total error/ global error
• Analytic solution: y = y0 e−at (· · · asymptotically approached to 0.)
= Local truncation error propagation + Round off errors = O(h)
• Forward Euler scheme: yn+1 = yn − hayn = (1 − ah)yn
If |1 − ah| > 1 7→ The numerical solution will grow unbounded.
⇒ The stability of the method depends on the stepsize h. ⇐
The forward Euler method is conditionally stable.
Hiremath, K. R. (IITJ) 4 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 5 / 19 August 29, 2013
Hiremath, K. R. (IITJ) 6 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 7 / 19 August 29, 2013
Improvements in the forward Euler method One more example. . .
• Why not approximate the constant slope on [tn , tn+1 ] by • Consider
1 the slope at the end-point of the interval? (Backward Euler method) y 0 (t) = 1 + t + y 2 , y(0) = 0
| {z }
yn+1 = yn + hf (tn+1 , yn+1 ) (2) f (t,y)
2 the slope at the mid-point of the interval? The forward Euler scheme:
2
yn+1 = yn + hf (tn+1/2 , yn+1/2 ) (3) yn+1 = yn + h(1 + tn+1 + yn+1 )
3 the average of the slopes at tn and tn+1 ? yn+1 on both the sides 7→ Solve nonlinear algebraic equation.
f (tn , yn ) + f (tn+1 , yn+1 ) • This is a typical case when f (t, y) is nonlinear in y. 7→ Implicit scheme:
yn+1 = yn + h (4)
2 Implicit Euler method 7→ Computationally expensive
• Let’s start with the first choice.: Solve the IVP • :-(( Difficulty with the mid-point: yn+1 = yn + hf (tn+1/2 , yn+1/2 )
| {z }
0
y (t) = −4y, y(0) = 4 unknown
over an interval [0, 2] with the backward Euler method with h = 0.5, How to overcome the above difficulties?
and 0.2. Compare these results with that of the forward Euler method. Predictor-Corrector methods
Hiremath, K. R. (IITJ) 8 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 9 / 19 August 29, 2013
• Motivation: Use the slope information (= f (tn+1/2 , yn+1/2 )) at the • Motivation: Use the slope information at the both end points of the
mid-point tn+1/2 of the interval [tn , tn+1 ]. interval [tn , tn+1 ].
• Difficulty: We don’t know yn+1/2 . • Difficulty: Possibility of getting an implicit scheme!
• Way out: • Way out: Repeat the trick used in the mid-point method :-B
1 Using the standard Euler method, predict the value of yn+1/2 :
• Heun’s method: (LTE=O(h3 ), GE= O(h2 ))
h
yn+1/2 = yn + f (tn , yn ) 0
2 yn+1 = yn + hf (tn , yn ) (Predictor)
0 )
f (tn , yn ) + f (tn+1 , yn+1
2 Using the above predicted value of yn+1/2 , correct the value of yn+1 :
yn+1 = yn + h (Corrector)
yn+1 = yn + hf (tn+1/2 , yn+1/2 )
2
• Iterated Heun’s method: For m = 1, 2, · · · (+ Termination criterion)
• The mid-point method: (LTE=O(h3 ), GE= O(h2 ))
0
yn+1 = yn + hf (tn , yn ) (Predictor)
h
yn+1/2 = yn + f (tn , yn ) (Predictor)
" #
m−1
2 m f (tn , yn ) + f (tn+1 , yn+1 )
yn+1 = yn + h (Corrector)
yn+1 = yn + hf (, tn+1/2 , yn+1/2 ) (Corrector) 2
Hiremath, K. R. (IITJ) 10 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 11 / 19 August 29, 2013
Example Recap
2 Use the “weighted average” of all these slope values to extrapolate the y
value at the next time step.
1 1 yn+1 = yn + h (b1 k1 + b2 k2 )
yn+1 = yn + h k1 + k2
2 2
k1 = f (tn , yn )
k1 = f (tn , yn )
k2 = f (tn + β2 h, yn + α21 hk1 , )
k2 = f (tn + h, yn + hk1 )
1
1 b1 = b2 = 2 and α21 = β2 = 1 7→ Heun’s method
1 The k1 and k2 are known as the stages of RK method.
1
2 b1 = 0, b2 = 1 and α21 = β2 = 2 7→ The mid-point method
2 They correspond to different estimations for the slope of the solution.
• k1 : slope estimation at the start of the interval tn using yn Conclusion: several versions of RK2 method
• k2 : slope estimation at the end of the interval tn+1 using yn + hk1 Four unknowns and three equations (Ref: Chapra’s book)
This is also true for a general n’th order RK method.
3 This scheme can be interpreted as a predictor-corrector method. 7→
Heun’s method (with m = 1)
Hiremath, K. R. (IITJ) 16 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 17 / 19 August 29, 2013
Generalized m’th order explicit Runge-Kutta methods Classical 4th order Runge-Kutta method
m
X k1 = f (tn , yn )
yn+1 = yn + h bj kj
j=1
1 1
k2 = f (tn + h, yn + k1 h)
k1 = f (tn , yn ) 2 2
1 1
k2 = f (tn + β2 h, yn + α21 hk1 ) k3 = f (tn + h, yn + k2 h)
2 2
.. k4 = f (tn + h, yn + k3 h)
.
m−1 1
X yn+1 = yn + (k1 + 2k2 + 2k3 + k4 )h
km = f (tn + βn h, yn + h αn,j kj ) 6
j=1
Most popular: Classical RK4 method • When f = f (t): Classical RK4 is similar to Simpson’s 1/3 rule
Hiremath, K. R. (IITJ) 18 / 19 August 29, 2013 Hiremath, K. R. (IITJ) 19 / 19 August 29, 2013