section 5.4 runge-kutta methods

12
Section 5.4 Runge-Kutta Methods

Upload: others

Post on 03-Jun-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Section 5.4 Runge-Kutta Methods

Section 5.4 Runge-KuttaMethods

Page 2: Section 5.4 Runge-Kutta Methods

Motivation

β€’ How to design a high-order accurate method without knowledge of derivatives of 𝑓 𝑑, 𝑦 , which are cumbersome to compute.

𝑀&'( = 𝑀& + β„Žπ‘‡ - 𝑑&, 𝑀& ,where

𝑇 - 𝑑&, 𝑀& = 𝑓 𝑑&, 𝑀& +β„Ž2

πœ•π‘“πœ•π‘‘

𝑑&, 𝑀& +πœ•π‘“πœ•π‘¦

𝑑&, 𝑀& 𝑓 𝑑&, 𝑀&

β€’ Recall Taylor method of order 2:

𝑀&'( = 𝑀& + β„Ž π‘Ž(𝑓(𝑑& + 𝛼(, 𝑀& + 𝛽(),thendeterminethecoefficients π‘Ž(, 𝛼(, 𝛽( suchthat

|π‘Ž(𝑓 𝑑 + 𝛼(, 𝑦 + 𝛽( -𝑇 - 𝑑, 𝑦 | = 𝑂(β„Ž-)

β€’Main idea: design a method of the form

Page 3: Section 5.4 Runge-Kutta Methods

Derivation of Runge-Kutta Method of Order Two

a) 𝑇 - 𝑑, 𝑦 = 𝑓 𝑑, 𝑦 + H-IJIK

𝑑, 𝑦 𝑑 + H-IJIL

𝑑, 𝑦 𝑑 M 𝑓 𝑑, 𝑦 𝑑 .

b) Using Talyor theorem of two variables (Thm 5.13 in textbook), π‘Ž(𝑓 𝑑 + 𝛼(, 𝑦 + 𝛽( = π‘Ž(𝑓 𝑑, 𝑦 + π‘Ž(𝛼(

IJIK

𝑑, 𝑦 + π‘Ž(𝛽(IJIL

𝑑, 𝑦

+π‘Ž(𝑅( 𝑑 + 𝛼(, 𝑦 + 𝛽( <-- remainderβ€’Matching coefficients in a) and b) βˆ’βˆ’β†’

π‘Ž( = 1, 𝛼( =β„Ž2, 𝛽( =

β„Ž2𝑓 𝑑, 𝑦 .

β€’ The remainder term π‘Ž(𝑅( 𝑑 + 𝛼(, 𝑦 + 𝛽( = 𝑂 β„Ž- ---- >|π‘Ž(𝑓 𝑑 + 𝛼(, 𝑦 + 𝛽( βˆ’ 𝑇 - 𝑑, 𝑦 | = 𝑂(β„Ž-)

èèèThe new method is of order 2!!! (same order as Taylor 2)

Page 4: Section 5.4 Runge-Kutta Methods

Midpoint Method

β€’ The midpoint method:

𝑀&'( = 𝑀& + β„Žπ‘“ 𝑑& +β„Ž2, 𝑀& +

β„Ž2𝑓 𝑑&, 𝑀& ,

for each 𝑖 = 0, 1, 2,β‹― ,𝑁 βˆ’ 1.

Remark: Local truncation error of Midpoint method is 𝑂 β„Ž- .The method is second-order accurate.

Page 5: Section 5.4 Runge-Kutta Methods

Two stage formula of Midpoint Method

Wπ‘˜( = 𝑓(𝑑&, 𝑀&)

π‘˜- = 𝑓 𝑑& +β„Ž2, 𝑀& +

β„Ž2π‘˜(

𝑀&'( = 𝑀& + β„Žπ‘˜-for each 𝑖 = 0, 1, 2,β‹― ,𝑁 βˆ’ 1.

β€’ Example 2. Use the Midpoint method with 𝑁 = 2 to solve the IVP𝑦Y = 𝑦 βˆ’ 𝑑- + 1, 0 ≀ 𝑑 ≀ 2, 𝑦 0 = 0.5.

(MATLAB) Implement the method using β„Ž = 0.2. Record the maximum error.

Page 6: Section 5.4 Runge-Kutta Methods

Midpoint

Page 7: Section 5.4 Runge-Kutta Methods

Modified Euler Methodβ€’ This is another Runge-Kutta method of order two:

The modified Euler method:

𝑀&'( = 𝑀& +β„Ž2𝑓 𝑑&, 𝑀& + 𝑓 𝑑&'(, 𝑀& + β„Žπ‘“ 𝑑&, 𝑀&

for each 𝑖 = 0, 1, 2,β‹― ,𝑁 βˆ’ 1.

Remark: Local truncation error of Modified Euler method is 𝑂 β„Ž- .

Page 8: Section 5.4 Runge-Kutta Methods

Two stage formula of Modified Euler Method

\π‘˜( = 𝑓(𝑑&, 𝑀&)

π‘˜- = 𝑓 𝑑& + β„Ž, 𝑀& + β„Žπ‘˜(𝑀&'( = 𝑀& +

β„Ž2[π‘˜( + π‘˜-],

for each 𝑖 = 0, 1, 2,β‹― ,𝑁 βˆ’ 1.

Example 2. Use the modified Euler method with 𝑁 = 2 to solve the IVP

𝑦Y = 𝑦 βˆ’ 𝑑- + 1, 0 ≀ 𝑑 ≀ 2, 𝑦 0 = 0.5.(MATLAB) Implement the method using β„Ž = 0.2. Record the maximum error.

Page 9: Section 5.4 Runge-Kutta Methods
Page 10: Section 5.4 Runge-Kutta Methods

Runge-Kutta Order Four (RK4)π‘˜( = 𝑓 𝑑&, 𝑀&

π‘˜- = 𝑓 𝑑& +β„Ž2 ,𝑀& +

β„Ž2 π‘˜(

π‘˜_ = 𝑓(𝑑& +β„Ž2,𝑀& +

β„Ž2π‘˜-)

π‘˜` = 𝑓(𝑑& + β„Ž,𝑀& + β„Ž π‘˜_)

,

𝑀&'( = 𝑀& +β„Ž6 [π‘˜( + 2π‘˜- + 2π‘˜_ + π‘˜`],

for each 𝑖 = 0, 1, 2,β‹― ,𝑁 βˆ’ 1.

Remark: RK4 hasfour stages,andisthe mostwidelyusedRKmethod.Its local truncation error is 𝑂 β„Ž` . , 𝑖. 𝑒., fourth order accurate.

Page 11: Section 5.4 Runge-Kutta Methods

Example 3. Use RK4 with 𝑁 = 2 to solve the IVP𝑦Y = 𝑦 βˆ’ 𝑑- + 1, 0 ≀ 𝑑 ≀ 2, 𝑦 0 = 0.5.

(MATLAB) Implement the method using β„Ž = 0.2. Record the maximum error.

Page 12: Section 5.4 Runge-Kutta Methods