Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Lecture 21: Solutions to ODEs & Runge-Kutta Methods - Fall 2004, Slides of Numerical Methods in Engineering

A part of the ce 341/441 lecture notes from fall 2004. It covers the solutions to ordinary differential equations (odes) and the implementation of runge-kutta methods. How to find the solution of an ode with initial conditions and introduces the 2nd order runge-kutta methods. The document also discusses the approximation error and the comparison of different methods.

Typology: Slides

2011/2012

Uploaded on 02/20/2012

damyen
damyen 🇺🇸

4.4

(27)

274 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CE 341/441 - Lecture 21 - Fall 2004
p. 21.1
LECTURE 21
SOLUTIONS TO O.D.E.’S Continued
Solve
Initial condition
Note that the solution is a function of only while the slope is a function of
both and .
INSERT FIGURE NO. 96
dy
dt
------fyt,()=
yt
o
() yo
=
yt() tfyt,()
yt
y(t)
y
0
t
f(y,t)=slope
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Lecture 21: Solutions to ODEs & Runge-Kutta Methods - Fall 2004 and more Slides Numerical Methods in Engineering in PDF only on Docsity!

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

LECTURE 21SOLUTIONS TO O.D.E.’S Continued • Solve

Initial condition

  • Note that the solution

is a function of

only while the slope

is a function of

both

and

INSERT FIGURE NO. 96

dy ----- dt

-^

f^

y t ,(

y t

o (^

)^

y^ o

y t ( )

t^

f^

y t ,(

y^

t

y(t)

y^0

t

f(y,t)=slope

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

2nd Order Runge-Kutta Methods • Use two terms for

  • Expand the 2nd term in Equation (3) as a Taylor series about

where

and

y^

j^

1 +^

y^

j^

t Φ

=

a

g 1 1

a

g 2

2

a

1

f^

t^ j

y^

j , (^

)^

a^2

f^

t^ j

p

1

t y

j^

p

2

t f

t^ j

y j , (^

(^

t^ j

y j , (^

f^

t^ j

p

t y

j ,^

p

t f

t^ j

y j , (^

(^

)^

f^

t^ j

y j , (^

)^

T

ft

t^ j^

y^ , i (^

)

y

f

y

t^ j^

y^ , j (^

)

T

(^

2

f

(^2) t

-^

T

(^

y (^

2

f

y

t


-^

y (^

2

f

(^2) y

t^ j^

y^ , j (^

)^

T

p

t

y^

p^2

t f

t^ j

y^

j , (^

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

  • Use Taylor Series to find exact representation for

by expanding about

  • However by definition

y^

j^

1 +^

y t

j^

1

(^

t^ j

y^

j^

1 +^

y^

j^

dy ----- tdt

j

t (^

d -

2 y^2 dt

j

O

t (^

dy ----- dt

-^

f^

t y ,(

d

2 y^2 dt

ft

f

y

dy ----- dt

^

^

d

2 y^2 dt

f^ ∂

t

f

y

f

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

  • Substituting for

and

into the Taylor series expanded form of

, Equation

(5), we obtain an exact expression for

(to

  • Recall that the Runge-Kutta approximation for

was:

  • Select constants between Equations

and (6) such that both are the same

dy ----- dt

j

d

2 y^2 dt

j

y^

j^

1

y^

j^

1 +^

O

t (^

y^

j^

1 +^

y^

j^

t f

j

t (^

-^

ft

j

f

y

f j j

^

^

^

O

t (^

y^

j^

1

y^

j^

1 +^

y^

j^

t a

1

a^2

(^

)^

f^

j^

t (^

a

2

p

1

ft

j

a

2

p^2

f^

j

f

y

j

^

^

^

^

O

t (^

a

1

a

2

a^2

p

1

a^2

p

2

^    

a^1

a

2

=

p

1

p

2

1 2 a

2

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

INSERT FIGURE NO. 97 • Procedure

  • Estimate

by using first order Euler

  • Evaluate the slope at

and the 1st order estimate of

  • Find the point

by taking the average of slope at

and at (

, 1st order

approximation to

y )

yj+

tj+

tj

t

t

yj

fj

avg.slope

slope = f(t

+j

t, y

+j

t f

)j

avg. slopeslope = f(t

, yj

)j

y^

j^

1

t^ j

1 +^

y^

j^

1 +^

f^

t^ j

t y

j^

t f

j

(^

y^

j^

1 +^

t^ j

y j , (^

)^

t^ j

1

y^

j^

1

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

Modified Euler Method • Let

  • Implementation of this formula may be viewed as follows:

evaluate first

evaluate second

final step

  • Note that the 2nd order formulae require 2 evaluations of the function

a^

a^1

a

2

p

1

p

2

y^

j^

1 +^

y^

j^

t f

t^ j

t 2 ----

y^

j

t 2 ----

-^

f^

j

^

^

t^ j

1 --- 2 +^

t^ j

t 2

=

y^

j^

1 --- 2 *****^ +

y^

j

t 2

f

t^ j

y j , (^

y^

j^

1 +^

y^

j^

t f

t^ j

1 --- 2 +^

y^

j^

1 --- 2 ***** + ,

^

^

f^

t y ,(

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

4th Order Runge-Kutta (often referred to as the “Runge-Kutta formula”) • Sum of coefficients equals 1.0 since we’re taking an average slope.• Procedure as follows:

y^

j^

1 +^

y^

j^

t

g^1 ----^6

-^

g

-^

g

-^

g

y^

j^

1 --- 2 *^ +

y^

j

t 2

f

y^

j^

t^ , j

(^

y^

j^

1 --- 2 **^ +

y^

j

t 2

f

y^

j^

1 --- 2 *^ +

t^ j

1 --- 2

,

^

^

y^

j^

1 *^ +

y^

j^

t f

y^

j^

1 --- 2 **^ +

t^ j

1 --- 2

,

^

^

y^

j^

1 +^

y^

j^

t^

1 ---^6

f^

y^

j^

t^ , j

(^

)^

1 ---^3

f^

y^

j^

**1 --- 2

***^

t^ j

1 --- 2 + ,

^

^

^

1 ---^3

f^

y^

j^

**1 --- 2


t^ j

1 --- 2 + ,

^

^

^

1 ---^6

f^

y^

j^

**1 ***^ +

t^ j

1 + ,

(^

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

INSERT FIGURE NO. 99 • Notes

  • Find the point

by using the weighted average of the 4 slopes

  • Note that there are other coefficients possible for 4th order Runge-Kutta• We require 4 evaluations of the slope for this 4th order method

4 times the work of

y the 1st order Runge-Kutta Method

yj+1/

tj+

=

tj

t

yj

t+j

t^2

tj^

+

t

**j+1/2y *

*yj+

use further improved value of slope to obtain y

j+

3

f(y

j + 1/

,^ t

j + 1/

)

3

use improved slope to evaluate the new midpoint y

**j+1/

2

f(y

j + 1/

,^ t

j + 1/

)

2

f(t

+j y

) used to estimatej

y *^ j+1/

1

y^

j^

1

CE 341/441 - Lecture 21 - Fall 2004

p. 21.

  • Qualitative basis for verifying accuracy of solutions

use 2 different time steps (similar

to Romberg integration)

  • Can estimate truncation error as:

where

solution found using

(therefore 2 steps)

solution found using

(1 step)

= order of the method

  • Need to run the solution using two different time steps!

E

j^

1

y ˆ^

j^

1 +^

y^

j^

1

  • 2

k

y ˆ^

j^

1 +^

t /

y^

j^

1 +^

t

k