Module 6 3 RungeKutta 2 Method Angela B
Module 6. 3 Runge-Kutta 2 Method Angela B. Shiflet and George W. Shiflet Wofford College © 2014 by Princeton University Press
Introduction • Notation: At (tn, Pn), can write d. P/dt|t=tn, P=Pn as f(tn, Pn) For example: for d. P/dt = 0. 1 P & P 0 = 100, f(t 0, P 0) = f(0, 100) = 0. 1(100) = 10. Using Euler’s method for Δt = 8, for n = 1, P 1 = P 0 + f(t 0, P 0)*Δt = 100 + 10*8 = 180.
Euler’s Method • tn = t 0 + n Δ t • Pn = Pn - 1 + f(tn - 1, Pn - 1) Δ t f(tn - 1, Pn - 1) is the slope of the tangent line At point (tn - 1, Pn - 1).
Runge-Kutta 2 method • Euler's Predictor-Corrector (EPC) Method • Better than Euler’s Method • Predict and correct
Concept of method • Instead of slope of tangent line at (tn-1, Pn-1), want slope of chord (i. e. slope of the secant line). • For ∆t = 8, want slope of chord between (0, P(0)) = (0, 100) and (8, P(8)) = (8, 223), i. e. (223 – 100)/(8 – 0) = 123/8, but P(8) (the function value is usually unknown and is the value that we are trying to estimate)
Concept of method • Then, estimate for 2 nd point is ? • (∆t, P(0) + slope_of_chord * ∆t) • (8, P(0) + slope_of_chord * 8)
Concept of method • Slope of chord ≈ average of slopes of tangents at P(0) and P(8)
How find slope of tangent at P(8) when do not know P(8)? • Y = Euler’s estimate for P(8) • In this case Y = 180 • Use (8, 180) in derivative formula to obtain estimate of slope at t = 8 • In this case, f(8, 180) = 0. 1(180) = 18 • Average of slope at 0 and estimate of slope at 8 is • 0. 5(10 + 18) = 14 • Corrected estimate of P 1 is 100 + 8(14) = 212
Predicted and corrected estimation of (8, P(8))
Summary of the method • We estimate the slope of the chord by using Using Euler’s method to estimate P(8) so we can estimate The slope of the tangent line at (8, P(8)) = (8, 180). The slope of the tangent line at (8, P(8)) is f(8, 180) = 0. 1*180 =18. Therefore, the slope of the chord is approximately (10 + 18)/2 = 14, and P 1 = 100 + 14*8 = 212 which is closer to the actual value 223 (compared to 180 using Euler’s method).
Runge-Kutta 2 method
Runge-Kutta 2 Algorithm • Initialize t 0 and P 0 • Initialize Number. Of. Steps • for n going from 1 to Number. Of. Steps do: • tn = t 0 + n ∆t • Yn = Pn - 1 + f(tn - 1, Pn - 1)∆t, which is Euler's Method estimate • Pn = Pn - 1 + 0. 5 (f(tn - 1, Pn - 1) + f(tn, Yn))∆t
Error • With P(8) = 15. 3193 and Euler estimate = 180, relative error = ? • |(180 - P(8))/P(8)| ≈ 19. 1% • With EPC estimate = 212, relative error = ? • |(212 - P(8))/P(8)| ≈ 4. 7% • Relative error of Euler's method is O(Δt)
EPC at time 100 • • Δt 1. 0 0. 5 0. 25 Estimated P 2, 168, 841 2, 193, 824 2, 200, 396 Relative error 0. 015348 0. 004005 0. 001022 • Relative error of EPC method is on order of O((Δt)2)
Error
- Slides: 15