=yi +φ(xi , y ,h - University of Utahmech.utah.edu/~pardyjak/me6700/Lect14_RungeKutta.pdfMicrosoft...
-
Upload
trinhhuong -
Category
Documents
-
view
214 -
download
0
Transcript of =yi +φ(xi , y ,h - University of Utahmech.utah.edu/~pardyjak/me6700/Lect14_RungeKutta.pdfMicrosoft...
Runge-Kutta Methods – CH 25Can achieve Taylor Series accuracy without evaluating higher order derivatives.
General form: ( )hhyxyy iiii ,,1 φ+=+
( )hyx ii ,,φ - Increment function & is like a slope over the interval
nnkakaka +++= ...2211φ • a’s are constants & k’s are recurrence relationships•n=1 Euler’s method
(1)
Runge-Kutta Methods – CH 25Can achieve Taylor Series accuracy without evaluating higher order derivatives.
General form: ( )hhyxyy iiii ,,1 φ+=+
( )hyx ii ,,φ - Increment function & is like a slope over the interval
nnkakaka +++= ...2211φ • a’s are constants & k’s are recurrence relationships•n=1 Euler’s method),(1 ii yxfk =
),( 11112 hkqyhpxfk ii ++=),( 22212123 hkqhkqyhpxfk ii +++=
)...,( 11,122,111,11 hkqhkqhkqyhpxfk nnnnninin −−−−−− +++++=
(1)
Runge-Kutta MethodsTo Determine the final form of (1)
1. Select n
2. Evaluate a’s,p’s,q’s by setting the general form equal to terms in the T-S expansion.
3. For low-order forms • Number of terms n=order of the method• Local truncation error is O(hn+1)• Global truncation error is O(hn)
2nd- Order Runge-Kutta Methods
General Form: ( )hkakayy ii 22111 ++=+
),(1 ii yxfk =),( 11112 hkqyhpxfk ii ++=
By setting (2) equal to a T-S expansion through the 2nd order term, we can solve for a1,a2,p1,q11
(2)
2/12/11
112
12
21
===+
qapa
aa3 Eqns & 4 unknowsSpecify a2 value
( )( )211
21
21
2/12/1
1
aqap
aa
==
−=
*Since there are an infinite number of choices for a2 there will be an infinite number of 2nd order R-K Methods
See Box25.1 inText
2nd- Order Runge-Kutta Methods
A) Huen Method without iteration(a2 = ½ ): a1 = ½ , p1 = 1,q11 =1
hkkyy ii ⎟⎠⎞
⎜⎝⎛ ++=+ 211 2
121
),(1 ii yxfk =
),( 12 hkyhxfk ii ++=
k1 slope at start of intervalk2 slope at end of interval ( )
( )211
21
21
2/12/1
1
aqap
aa
==
−=
Global Truncation Error ~ O(h2)
2nd- Order Runge-Kutta Methods
B) Midpoint Method (a2 = 1 ): a1 = 0 , p1 = 1/2, q11 =1/2
hkyy ii 21 +=+
),(1 ii yxfk =
)5.0,5.0( 12 hkyhxfk ii ++=
( )( )211
21
21
2/12/1
1
aqap
aa
==
−=
Global Truncation Error ~ O(h2)
2nd- Order Runge-Kutta Methods
C) Ralston’s Method (a2 = 2/3 ): a1 = 1/3 , p1 = 3/4, q11 =3/4
),(1 ii yxfk =
)75.,75.0( 12 hkyhxfk ii ++=
hkkyy ii ⎟⎠⎞
⎜⎝⎛ ++=+ 211 3
231
( )( )211
21
21
2/12/1
1
aqap
aa
==
−=
Global Truncation Error ~ O(h2)
4th - Order Runge-Kutta Methods
Classical 4th order RK Method – most commonly used RK method
),(1 ii yxfk =
)5.,5.0( 12 hkyhxfk ii ++=
( )
hyy
hkkkkyy
ii
ii
φ+=
++++=
+
+
1
43211 2261
)5.,5.0( 23 hkyhxfk ii ++=
),( 34 hkyhxfk ii ++=
xi xi+1
y
xi+1/2
h
k1
k2
k3
k4
φk3
k1
k2
Slope Estimates:
Global Truncation Error ~ O(h4)
4th - Order Runge-Kutta Methods –
Recall the exact solution is:
0),( 001 =−== yxyxfk ii
2.0)00()2/4.00()5.,5.0( 12 =+−+=++= hkyhxfk ii
( ) ( )
07040.0
4.0336.)16(.2)2(.2061022
61
1
432101
=
++++=++++=
y
hkkkkyy
16.0))4.0)(2.0)(5.0(0()2/4.00()5.,5.0( 23 =+−+=++= hkyhxfk ii
336.0))4.0(16.00()4.00(),5.0( 34 =+−+=++= hkyhxfk ii
070320.0)4.0(1
=−+= −
yexy x
RK4 Solution:
Example: Use classical RK4 to determine y @ x=0.4 for y’=x-y andh=0.4
00
0
0
==
yx
Initial Conditions
4th - Order Runge-Kutta Methods –
Error:
Example: Use classical RK4 to determine y @ x=0.4 for y’=x-y andh=0.4
%11.%10007032.
07040.07032.=•
−=tE
See Matlab Sample Matlab RK4 method
Method Comparison
• Higher order methods produce better accuracy
• Effort for the higher order methods is similar to low-order methods (much of the effort goes into evaluating the function)
• Classical 4th order RK is most widely used as it produces accurate results with reasonable effort.
Systems of Equations
• Recall, Any nth order ODE can be represented as a system of n 1st order ODEs
• To solve the system requires n initial conditions at x = x0
( )
( )
( )nnn
n
n
yyyxfdxdy
yyyxfdxdy
yyyxfdxdy
,...,,,
,...,,,
,...,,,
21
2122
2111
=
=
=
M
Systems of Equations – RK4 Example
( )
( )2122
2111
,,
,,
yyxfdxdy
yyxfdxdy
=
=
For example:
( )
( ) yzzyxfdxdz
yzyxfdxdy
+−==
−==
cos43,,
,,
2
1
Subject to initial conditions
( )( ) 220,2
110,1
00
YxyyYxyy===
===
Systems of Equations – RK4 Example
Solve for slopesjik ,
ith value of k for the jth dependant variable
For RK-4 i=1,2,3 and 4 while j=1, 2, … number of dependant variables
Systems of Equations – RK4 Example
( )( )
( )( )hkyhkyhxfk
hkyhkyhxfk
hkyhkyhxfk
hkyhkyhxfk
hkyhkyhxfk
kyhkyhxfk
yyxfkyyxfk
iii
iii
iii
iii
iii
iii
iii
iii
32231122,4
32231111,4
22221122,3
22221111,3
12211122,2
12211111,2
2122,1
2111,1
,,,,
21,
21,
21
21,
21,
21
21,
21,
21
21,
21,
21
,,,,
+++=
+++=
⎟⎠⎞
⎜⎝⎛ +++=
⎟⎠⎞
⎜⎝⎛ +++=
⎟⎠⎞
⎜⎝⎛ +++=
⎟⎠⎞
⎜⎝⎛ +++=
=
=Solve for slopesStart with i=0The initial condition
Systems of Equations – RK4 Example
( )
( )hkkkkyy
hkkkkyy
ii
ii
4232221221,2
4131211111,1
2261
2261
++++=
++++=
+
+
Show Matlab Systems of Equations RK4 Example
122
21
72
yydxdy
ydxdy
−−=
= ( )( ) 00
40
2
1
====
xyxy
Matlab ODE solvers
ODE23 and ODE45 are RK solvers that combine2nd and 3rd order RK and 4th and 5th order RK methods.
See Chapter 8 in Palm Text.