Download presentation
Presentation is loading. Please wait.
1
Sec:25.3 RUNGE-KUTTA METHODS
2
Sec:25.3 RUNGE-KUTTA METHODS
Second-Order Runge-Kutta Methods 1) Heun Method 2) The Midpoint Method 3) Ralston’s Method Computational Examples Taylor Series Methods Derivations
3
Sec:25.3 RUNGE-KUTTA METHODS
Initial Value Problem Euler’s Method 𝑦 ′ =𝑓 𝑡,𝑦 𝑦(𝑎) =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 =𝛼 𝑎≤ 𝑡 ≤𝑏, Heun Method Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 𝑲 𝟏 𝑲 𝟐 ℎ 𝑤 =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑲 𝟏 𝑤 =𝛼 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 +ℎ, 𝑤 𝑖 + 𝑲 𝟏 ℎ
4
Sec:25.3 RUNGE-KUTTA METHODS
Heun Method Example 𝑤 𝑖+1 = 𝑤 𝑖 𝑲 𝟏 𝑲 𝟐 ℎ 𝑤 =𝛼 Use the Heun method h = 0.5, to approximate 𝑦(1) 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤4, 𝑦(0) = 0.5 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 +ℎ, 𝑤 𝑖 + 𝑲 𝟏 ℎ 𝑓(𝑡,𝑦)=𝑦− 𝑡 2 +1 𝑲 𝟏 =𝑓 𝑡 1 , 𝑤 1 𝑲 𝟏 =𝑓 𝑡 0 , 𝑤 0 =𝑓 0.5,1.375 =2.125 𝑲 𝟐 =𝑓 𝑡 1 +ℎ, 𝑤 1 + 𝑲 𝟏 ℎ =𝑓 0,0.5 =1.5 =𝑓 1,1.375+𝟐.𝟏𝟐𝟓∗0.5 𝑲 𝟐 =𝑓 𝑡 0 +ℎ, 𝑤 0 + 𝑲 𝟏 ℎ =2.4375 =𝑓 0.5,0.5+𝟏.𝟓∗0.5 =2 𝒘 𝟐 =𝟏.𝟑𝟕𝟓+ 𝟏 𝟐 ∗𝟐.𝟏𝟐𝟓 + 𝟏 𝟐 ∗𝟐.𝟒𝟑𝟕𝟓 𝟎.𝟓 𝑤 1 = ∗𝟏.𝟓+ 1 2 ∗𝟐 0.5 𝑤 2 = 𝑤 1 =1.375 →𝒚(𝟏)≈𝟐.𝟓𝟏𝟓𝟔𝟐𝟓 →𝒚(𝟎.𝟓)≈𝟏.𝟑𝟕𝟓
5
Sec:25.3 RUNGE-KUTTA METHODS
Second-Order Runge-Kutta Methods 1) Heun Method 2) The Midpoint Method 3) Ralston’s Method
6
Sec:25.3 RUNGE-KUTTA METHODS
Midpoint method Example 𝑤 𝑖+1 = 𝑤 𝑖 + 𝑲 𝟐 ℎ 𝑤 =𝛼 Use the Midpoint method h = 0.5, to approximate 𝑦(0.5) 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤4, 𝑦(0) = 0.5 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ 𝑓(𝑡,𝑦)=𝑦− 𝑡 2 +1 𝑲 𝟏 =𝑓 𝑡 0 , 𝑤 0 =𝑓 0,0.5 =1.5 𝑲 𝟐 =𝑓 𝑡 ∗ℎ, 𝑤 ∗𝑲 𝟏 ℎ =𝑓 0.5, ∗𝟏.𝟓∗0.5 =1.8125 𝑤 1 =0.5+ 𝟏.𝟖𝟏𝟐𝟓 0.5 𝑤 1 = →𝒚(𝟎.𝟓)≈𝟏.𝟒𝟎𝟔𝟐𝟓
7
Sec:25.3 RUNGE-KUTTA METHODS
Second-Order Runge-Kutta Methods 1) Heun Method 2) The Midpoint Method 3) Ralston’s Method
8
Sec:25.3 RUNGE-KUTTA METHODS
Ralston’s Method Example 𝑤 𝑖+1 = 𝑤 𝑖 𝑲 𝟏 𝑲 𝟐 ℎ 𝑤 =𝛼 Use the Ralston’s method with h = 0.5, to approximate 𝑦(0.5) 𝑦 ′ =𝑦− 𝑡 2 +1 0≤ 𝑡 ≤4, 𝑦(0) = 0.5 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ 𝑓(𝑡,𝑦)=𝑦− 𝑡 2 +1 𝑲 𝟏 =𝑓 𝑡 0 , 𝑤 0 =𝑓 0,0.5 =1.5 𝑲 𝟐 =𝑓 𝑡 ∗ℎ, 𝑤 ∗𝑲 𝟏 ℎ =𝑓 0.75, ∗𝟏.𝟓∗0.5 =1.5 𝑤 1 = ∗𝟏.𝟓+ 2 3 ∗𝟏.𝟓 0.5 𝑤 1 =1.25 →𝒚(𝟎.𝟓)≈𝟏.𝟐𝟓
9
Sec:25.3 RUNGE-KUTTA METHODS
Heun Method Midpoint method 𝑤 𝑖+1 = 𝑤 𝑖 𝑲 𝟏 𝑲 𝟐 ℎ 𝑤 =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 + 𝑲 𝟐 ℎ 𝑤 =𝛼 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ 𝑲 𝟐 =𝑓 𝑡 𝑖 +ℎ, 𝑤 𝑖 + 𝑲 𝟏 ℎ Ralston’s Method 𝑤 𝑖+1 = 𝑤 𝑖 𝑲 𝟏 𝑲 𝟐 ℎ 𝑤 =𝛼 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ
10
Sec:25.3 RUNGE-KUTTA METHODS
𝑦 ′ =−2 𝑡 𝑡 2 −20𝑡+8.5 0≤ 𝑡 ≤4, 𝑦(0) =1 Example Second-Order Runge-Kutta Methods 1) Heun Method 2) The Midpoint Method 3) Ralston’s Method Notice how all the second-order RK methods are superior to Euler’s method
11
Sec:25.3 RUNGE-KUTTA METHODS
clear; clc; y-t.^2+1; alpha = 0.5; t0=0; h=0.5; n=2; [w] = midpoint(t0,h,n,alpha,f); w'; function [w] = huen(t0,h,n,alpha,f) w(1)=alpha; t(1)=t0; for i=1:n K1 = f(t(i),w(i)); K2 = f(t(i)+h,w(i)+h*K1); w(i+1)=w(i)+(K1+K2)*h/2; t(i+1)=t(i)+h; end function [w] = midpoint(t0,h,n,alpha,f) K1 = f(t(i),w(i)) K2 = f(t(i)+0.5*h,w(i)+0.5*h*K1) w(i+1)=w(i)+(K2)*h
12
Sec:25.3 RUNGE-KUTTA METHODS
The motion of a swinging pendulum under certain simplifying assumptions is described by the second-order differential equation 𝒅 𝟐 𝜽 𝒅 𝒕 𝟐 + 𝒈 𝑳 𝐬𝐢𝐧 𝜽=𝟎 where L=2 is the length of the pendulum, g ≈ ft/s2 is the gravitational constant of the earth, and θ is the angle the pendulum makes with the vertical. If, in addition, we specify the position of the pendulum when the motion begins, 𝜃( 𝑡 0 ) = 𝜋 6 , and its velocity at that point, 𝜃′( 𝑡 0 ) =0, we have what is called an initial-value problem. Use midpoint method with h = 0.1 s, compute the angle θ obtained for this initial-value problems at t = 0, 1, and 2 s.
13
Convert into system of 1st order ode
Sec:25.3 RUNGE-KUTTA METHODS 𝒅 𝟐 𝜽 𝒅 𝒕 𝟐 + 𝒈 𝑳 𝐬𝐢𝐧 𝜽=𝟎 Convert into system of 1st order ode 𝑦 1 =𝜃 𝑦 2 = 𝑑𝜃 𝑑𝑡 𝑑 𝑦 1 𝑑𝑡 = 𝑑𝜃 𝑑𝑡 𝑑 𝑦 2 𝑑𝑡 = 𝑑 2 𝜃 𝑑 𝑡 2 𝑑 𝑦 1 𝑑𝑡 = 𝑦 2 𝑑 𝑦 2 𝑑𝑡 =− 𝑔 𝐿 sin 𝑦 1 𝑌′ 𝑡 = 𝑑 𝑦 1 𝑑𝑡 𝑑 𝑦 2 𝑑𝑡 𝑌 𝑡 = 𝑦 1 (𝑡) 𝑦 2 (𝑡) 𝑌′ 𝑡 =𝐹(𝑡,𝑌) 𝜃(0) = 𝜋 6 𝐹 𝑡,𝑌 = 𝑦 2 − 𝑔 𝐿 sin 𝑦 1 𝜃′(0) =0 𝑌 0 = 𝜋/6 0
14
Sec:25.3 RUNGE-KUTTA METHODS
𝒅 𝟐 𝜽 𝒅 𝒕 𝟐 + 𝒈 𝑳 𝐬𝐢𝐧 𝜽=𝟎 𝑌′ 𝑡 =𝐹(𝑡,𝑌) 𝐹 𝑡,𝑌 = 𝑦 2 − 𝑔 𝐿 sin 𝑦 1 𝜽(𝟎) = 𝝅 𝟔 𝜽′(𝟎) =𝟎 𝑌 0 = 𝜋/6 0 Midpoint method 𝑊 𝑖+1 = 𝑊 𝑖 + 𝑲 𝟐 ℎ 𝑊 =𝛼 𝑊 𝑖 is a vector of size 2×1 𝑲 𝟏 , 𝑲 𝟐 and 𝜶 are vector of size 2×1 𝑲 𝟏 =𝐹 𝑡 𝑖 , 𝑊 𝑖 ℎ and 𝑡 𝑖 are scalars 𝑲 𝟐 =𝐹 𝑡 𝑖 ℎ, 𝑊 𝑖 𝑲 𝟏 ℎ 𝐹: 𝑡, 𝑦 1 𝑦 →
15
Sec:25.3 RUNGE-KUTTA METHODS
clear; clc; L = 2; g=32.17; [ Y(2) ; ... -(g/L)*sin(Y(1))]; t0=0; tf=2; n=1000; h=(tf-t0)/n; alpha = [ pi/6 ; 0 ]; [t,w] = midpoint(t0,h,n,alpha,F); [t',w'] plot(t,w(1,:));grid on function [t,w] = midpoint(t0,h,n,alpha,F) w(1:2,1)=alpha; t(1)=t0; for i=1:n K1 = F(t(i),w(1:2, i)); K2 = F(t(i)+0.5*h,w(1:2, i)+0.5*h*K1); w(1:2, i+1)=w(1:2, i)+(K2)*h; t(i+1)=t(i)+h; end 𝑌′ 𝑡 =𝐹(𝑡,𝑌) 𝐹 𝑡,𝑌 = 𝑦 2 − 𝑔 𝐿 sin 𝑦 1 𝑌 0 = 𝜋/6 0 Midpoint method 𝑊 𝑖+1 = 𝑊 𝑖 + 𝑲 𝟐 ℎ 𝑊 =𝛼 𝑲 𝟏 =𝐹 𝑡 𝑖 , 𝑊 𝑖 𝑲 𝟐 =𝐹 𝑡 𝑖 ℎ, 𝑊 𝑖 𝑲 𝟏 ℎ
16
Sec:25.3 RUNGE-KUTTA METHODS
𝒅 𝟐 𝜽 𝒅 𝒕 𝟐 + 𝒈 𝑳 𝐬𝐢𝐧 𝜽=𝟎 t(:) w(1,:) w(2,:) 𝜽(𝟎) = 𝝅 𝟔 𝜽′(𝟎) =𝟎 𝜽 𝜽′
17
Sec:25.3 RUNGE-KUTTA METHODS
clear; clc; L = 2; g=32.17; [ Y(2) ; -(g/L)*sin(Y(1))]; t0=0; tf=10; n=1000; h=(tf-t0)/n; alpha = [ pi/4 ; 0 ]; [t,w] = midpoint(t0,h,n,alpha,F); [t',w'] plot(t,w(1,:));grid on function [t,w] = midpoint(t0,h,n,alpha,F) w(1:2,1)=alpha; t(1)=t0; for i=1:n K1 = F(t(i),w(1:2, i)); K2 = F(t(i)+0.5*h,w(1:2, i)+0.5*h*K1); w(1:2, i+1)=w(1:2, i)+(K2)*h; t(i+1)=t(i)+h; End; end 𝑌′ 𝑡 =𝐹(𝑡,𝑌) 𝐹 𝑡,𝑌 = 𝑦 2 − 𝑔 𝐿 sin 𝑦 1 𝑌 0 = 𝝅/𝟒 0 𝒕 𝒇 =𝟏𝟎
18
Sec:25.3 RUNGE-KUTTA METHODS
Second-Order Runge-Kutta Methods 1) Heun Method 2) The Midpoint Method 3) Ralston’s Method Computational Examples Taylor Series Methods Derivations
19
Sec:25.3 RUNGE-KUTTA METHODS
Taylor’s Series Methods 𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Initial Value Problem Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑤 =𝛼 𝑦 ′ =𝑓 𝑡,𝑦 𝑦(𝑎) =𝛼 (*) 𝑎≤ 𝑡 ≤𝑏, We will use Taylor’s Theorem to derive Euler’s method. Suppose that 𝒚(𝒕), the unique solution to (*) Taylor’s Series Methods 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 𝒕 𝒊+𝟏 −𝒕 𝒊 𝒚 ′ 𝒕 𝒊 𝑡 𝑖+1 −𝑡 𝑖 𝟐 𝑦 ′′ 𝒕 𝒊 +⋯ 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 𝒕 𝒊+𝟏 −𝒕 𝒊 𝒚 ′ 𝒕 𝒊 + 𝑡 𝑖+1 −𝑡 𝑖 𝟐 𝑦 ′′ 𝜉 𝑖 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 +𝒉𝒚′ 𝒕 𝒊 𝒉 2 𝒚′′ 𝒕 𝒊 +⋯ 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 +𝒉𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 𝒉 𝟐 𝒇′ 𝒕 𝒊 ,𝑦 𝑡 𝑖 +⋯ 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 +𝒉𝒚′ 𝒕 𝒊 + 𝒉 2 𝑦 ′′ 𝜉 𝑖 𝒇 ′ 𝒕 𝒊 ,𝒚 𝒕 𝒊 = 𝝏 𝝏𝒕 𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 = 𝒇 𝒕 + 𝒇 𝒚 𝒚′ 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 +𝒉𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 + 𝒉 𝟐 𝑦 ′′ 𝜉 𝑖 𝑦 𝑡 𝑖+1 ≈𝑦 𝑡 𝑖 +𝒉𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 𝑦 𝑡 𝑖+1 =𝑦 𝑡 𝑖 +𝒉𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 𝒉 𝟐 𝒇 𝒕 + 𝒇 𝒚 𝒇 +⋯ 𝑤 𝑖+1 = 𝑤 𝑖 + 𝒉𝒇 𝒕 𝒊 , 𝒘 𝒊 𝑦 𝑡 𝑖+1 ≈𝑦 𝑡 𝑖 +𝒉𝒇 𝒕 𝒊 ,𝑦 𝑡 𝑖 𝒉 𝟐 𝒇 𝒕 + 𝒇 𝒚 𝒇 One way to reduce the error of Euler’s method would be to include higher-order terms of the Taylor series expansion in the solution. 𝑤 𝑖+1 = 𝑤 𝑖 +𝒉𝒇 𝒕 𝒊 , 𝑤 𝑖 𝒉 𝟐 𝒇 𝒕 + 𝒇 𝒚 𝒇 𝒕 𝒊 , 𝑤 𝑖 Higher-order derivatives become increasingly more complicated
20
Sec:25.3 RUNGE-KUTTA METHODS
Taylor’s Series Methods 𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Taylor’s Series Methods 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒚 ′ 𝒕 𝒊 + 𝟏 𝟐 𝒉 𝟐 𝒚 ′′ 𝒕 𝒊 + 𝟏 𝟔 𝒉 𝟑 𝒚 ′′′ 𝒕 𝒊 +⋯ 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉𝒇+ 𝟏 𝟐 𝒉 𝟐 𝒇 ′ + 𝟏 𝟔 𝒉 𝟑 𝒇 ′′ +⋯ 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 ′ + 𝟏 𝟔 𝒉 𝟐 𝒇 ′′ +⋯ Taylor’s Series Method of order one 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 ′ + 𝟏 𝟔 𝒉 𝟐 𝒇 ′′ +⋯ Euler’s Method Taylor’s Series Method of order two 𝒇 ′ = 𝒇 𝒕 + 𝒇 𝒚 𝒚′ = 𝒇 𝒕 + 𝒇 𝒚 𝒇 𝒕 𝒊 ,𝒚 𝒕 𝒊 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 ′ + 𝟏 𝟔 𝒉 𝟐 𝒇 ′′ +⋯ 𝒘 𝒊+𝟏 = 𝒘 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 𝒕 + 𝟏 𝟐 𝒉𝒇 𝒇 𝒚 𝒕 𝒊 , 𝒘 𝒊
21
Taylor series in 2-dimension
Sec:25.3 RUNGE-KUTTA METHODS Heun Method Midpoint method Ralston’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑲 𝟏 𝑲 𝟐 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑲 𝟐 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝑲 𝟏 𝑲 𝟐 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟏 =𝑓 𝑡 𝑖 , 𝑤 𝑖 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ 𝑲 𝟐 =𝑓 𝑡 𝑖 ℎ, 𝑤 𝑖 𝑲 𝟏 ℎ 𝑲 𝟐 =𝑓 𝑡 𝑖 +ℎ, 𝑤 𝑖 + 𝑲 𝟏 ℎ 𝑲 𝟏 =𝒇 𝒕 𝒊 , 𝒘 𝒊 Taylor’s Series Method of order two 𝑲 𝟐 =𝒇 𝒕 𝒊 + 𝒑 𝟏 𝒉, 𝒘 𝒊 + 𝒒 𝟏𝟏 𝑲 𝟏 𝒉 𝒘 𝒊+𝟏 = 𝒘 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 𝒕 + 𝟏 𝟐 𝒉𝒇 𝒇 𝒚 𝒕 𝒊 , 𝒘 𝒊 𝒘 𝒊+𝟏 = 𝒘 𝒊 +𝒉 𝒂 𝟏 𝑲 𝟏 + 𝒂 𝟐 𝑲 𝟐 Taylor series in 2-dimension + <2ed deriv>+⋯ =𝒇 𝒕 𝒊 , 𝒘 𝒊 + 𝒑 𝟏 𝒉 𝒇 𝒕 𝒕 𝒊 , 𝒘 𝒊 + 𝒒 𝟏𝟏 𝑲 𝟏 𝒉 𝒇 𝒚 𝒕 𝒊 , 𝒘 𝒊 𝑲 𝟐 𝒂 𝟏 𝑲 𝟏 + 𝒂 𝟐 𝑲 𝟐 = 𝒂 𝟏 𝒇+ 𝒂 𝟐 𝒇+ 𝒂 𝟐 𝒑 𝟏 𝒉 𝒇 𝒕 + 𝒂 𝟐 𝒒 𝟏𝟏 𝑲 𝟏 𝒉 𝒇 𝒚 +⋯ Matching the coefficients of f and its derivatives 𝒂 𝟐 𝒑 𝟏 = 𝟏 𝟐 𝒂 𝟐 𝒒 𝟏𝟏 = 𝟏 𝟐 𝒂 𝟏 + 𝒂 𝟐 =𝟏
22
Sec:25.3 RUNGE-KUTTA METHODS
𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 𝑲 𝟏 =𝒇 𝒕 𝒊 , 𝒘 𝒊 Matching the coefficients of f and its derivatives 𝑲 𝟐 =𝒇 𝒕 𝒊 + 𝒑 𝟏 𝒉, 𝒘 𝒊 + 𝒒 𝟏𝟏 𝑲 𝟏 𝒉 𝒂 𝟏 + 𝒂 𝟐 =𝟏 𝒘 𝒊+𝟏 = 𝒘 𝒊 +𝒉 𝒂 𝟏 𝑲 𝟏 + 𝒂 𝟐 𝑲 𝟐 𝒂 𝟐 𝒑 𝟏 = 𝟏 𝟐 three equations four unknown We have infinite number of solutions , there are an infinite number of second-order RK methods. 𝒂 𝟐 𝒒 𝟏𝟏 = 𝟏 𝟐 We present three of the most commonly used and preferred versions: 𝒂 𝟐 = 𝟐 𝟑 𝒂 𝟐 = 𝟏 𝟐 𝒂 𝟐 =𝟏 Heun Method Midpoint method Ralston’s Method
23
Sec:25.3 RUNGE-KUTTA METHODS
Taylor’s Series Methods 𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Taylor’s Series Method of order three 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 ′ + 𝟏 𝟔 𝒉 𝟐 𝒇 ′′ + 𝟏 𝟐𝟒 𝒉 𝟑 𝒇 ′′′ +⋯ Third-Order Runge-Kutta Methods Higher order Runge-Kutta methods can be derived using the same technique.
24
Sec:25.3 RUNGE-KUTTA METHODS
𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Taylor’s Series Method of order three 𝒚 𝒕 𝒊+𝟏 =𝒚 𝒕 𝒊 +𝒉 𝒇+ 𝟏 𝟐 𝒉 𝒇 ′ + 𝟏 𝟔 𝒉 𝟐 𝒇 ′′ + 𝟏 𝟐𝟒 𝒉 𝟑 𝒇 ′′′ + 𝟏 𝟏𝟐𝟎 𝒉 𝟒 𝒇 ′′′′ +⋯ The most popular method is the fourth order Runge-Kutta method, or RK4 method Fourth-Order Runge-Kutta Methods Third-Order Runge-Kutta Method
25
Implicit Euler’s Method Explicit Euler’s Method
Sec:25.3 RUNGE-KUTTA METHODS Explicit and Implicit Euler 𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Implicit Euler’s Method called implicit because the unknown appears on both sides of the equation. 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝒊+𝟏 , 𝑤 𝒊+𝟏 𝑤 =𝛼 Example Use Implicit Euler’s method with h = 1, to approximate 𝑦(2) Explicit Euler’s Method 𝑦 ′ = 𝑡 1+ 𝑦 ≤ 𝑡 ≤4, 𝑦(1) =1 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝒊 , 𝑤 𝒊 𝑤 =𝛼 Implicit Euler 𝑤 𝑖+1 = 𝑤 𝑖 + ℎ 𝑡 𝑖 𝑤 𝑖+1 2 𝑤 1 = 𝑤 1 2 you need to solve nonlinear equation
26
Sec:25.3 RUNGE-KUTTA METHODS
Explicit and Implicit Euler 𝑫𝒆𝒓𝒊𝒗𝒂𝒕𝒊𝒐𝒏 Explicit Euler’s Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝒊 , 𝑤 𝒊 𝑤 =𝛼 Implicit Euler’s Method Implicit 2ed order Method Implicit 2ed order Method 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ 𝟏 𝟐 𝑓 𝑡 𝒊 , 𝑤 𝒊 + 𝟏 𝟐 𝑓 𝑡 𝒊+𝟏 , 𝑤 𝒊+𝟏 𝑤 =𝛼 𝑤 𝑖+1 = 𝑤 𝑖 +ℎ𝑓 𝑡 𝒊+𝟏 , 𝑤 𝒊+𝟏 𝑤 =𝛼 predictor-corrector method we will use a predicted value, 𝒘 𝒊+𝟏 ∗ obtained with Explicit Euler to evaluate an approximation to the value 𝒘 𝒊+𝟏 at the new point. Predictor: 𝒘 𝒊+𝟏 ∗ = 𝑤 𝑖 +ℎ𝑓 𝑡 𝒊 , 𝑤 𝒊 𝒘 𝒊+𝟏 = 𝑤 𝑖 +ℎ 𝟏 𝟐 𝑓 𝑡 𝒊 , 𝑤 𝒊 + 𝟏 𝟐 𝑓 𝑡 𝒊+𝟏 , 𝒘 𝒊+𝟏 ∗ Corrector:
27
Sec:25.3 RUNGE-KUTTA METHODS
ODE Solver in MATLAB Ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb, ode15i, Example Example 𝑦 ′ =𝒚− 𝒕 𝟐 +𝟏 𝟎≤ 𝒕 ≤𝟒, 𝑦(0) = 𝟎.𝟓 [t,y] = ode23(odefun,tspan,y0) y-t^2+1,[0 4],0.5); plot(t,y);grid on
28
Sec:25.3 RUNGE-KUTTA METHODS
ODE Solver in MATLAB Ode45, ode23, ode113, ode15s, ode23s, ode23t, ode23tb, ode15i, Example Example 𝒚 𝟏 ′ = 𝒚 𝟐 [t,y] = ode45(odefun,tspan,y0) 𝒚 𝟐 ′ = 𝟏− 𝒚 𝟏 𝟐 𝒚 𝟐 − 𝒚 𝟐 𝟎≤ 𝒕 ≤𝟐𝟎, 𝒚 𝟏 (𝟎) 𝒚 𝟐 (𝟎) = 𝟐 𝟎 F [y(2); (1-y(1)^2)*y(2)-y(1)]; [t,y] = ode45(F,[0 20],[2; 0]); plot(t,y(:,1),'-o',t,y(:,2),'-o')
29
Sec:25.3 RUNGE-KUTTA METHODS
Solver Problem Type Accuracy When to Use ode45 Nonstiff Medium Most of the time. ode45 should be the first solver you try. ode23 Low ode23 can be more efficient than ode45 at problems with crude tolerances, or in the presence of moderate stiffness. Low to High ode113 can be more efficient than ode45 at problems with stringent error tolerances, or when the ODE function is expensive to evaluate. ode113 ode15s Stiff Low to Medium Try ode15s when ode45 fails or is inefficient and you suspect that the problem is stiff. Also use ode15s when solving differential algebraic equations (DAEs). ode23s can be more efficient than ode15s at problems with crude error tolerances. It can solve some stiff problems for which ode15s is not effective. ode23s computes the Jacobian in each step, so it is beneficial to provide the Jacobian via odesetto maximize efficiency and accuracy. If there is a mass matrix, it must be constant. ode23s ode23t Use ode23t if the problem is only moderately stiff and you need a solution without numerical damping. ode23t can solve differential algebraic equations (DAEs). ode23tb Like ode23s, the ode23tb solver might be more efficient than ode15s at problems with crude error tolerances. ode15i Fully implicit Use ode15i for fully implicit problems f(t,y,y’) = 0 and for differential algebraic equations (DAEs) of index 1. Sec:25.3 RUNGE-KUTTA METHODS
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.