Docsity

1474152, Exams of Engineering Mathematics

Partial preview of the text

Download 1474152 and more Exams Engineering Mathematics in PDF only on Docsity!

th-order Runge Kutta and

the Dormand-Prince Methods

Douglas Wilhelm Harder, M.Math. LEL

Department of Electrical and Computer Engineering

University of Waterloo

Waterloo, Ontario, Canada

ece.uwaterloo.ca

[email protected]

© 2012 by Douglas Wilhelm Harder. Some rights reserved.

Outline

This topic discusses advanced numerical solutions to

initial value problems:

  • (^) Weighted averages and integration techniques
  • (^) Runge-Kutta methods
  • (^4)

th-order Runge Kutta

Adaptive methods

The Dormand-Prince method

The Matlab ode45 function

2

Weighted Averages

The average of five numbers x

1 , x 2 , x 3 , x 4 , and x 5 is:

Suppose these were project grades and the last two projects had twice the weight of the other

projects

We can calculate the following weighted average :

(^1 2 3 4 5 1 1 1 1 )

5 1 5 2 5 3 5 4 5 5

x x x x x

x x x x x x

1 1 1 2 2

7 1 7 2 7 3 7 4 7 5

x  x  x  x  x

4

Weighted Averages

In fact, any combination scalars of a

1 , a 2 , a 3 , a 4 , and a 5 such that

allows us to calculate the weighted average

It is also possible to have negative weights:

Richardson extrapolation weights:

1 2 3 4 5

a  a  a  a  a  1

1 1 2 2 3 3 4 4 5 5

a x  a x  a x  a x  a x

1 1 1 1 1

3 1 3 2 3 3 3 4 3 5

x  x  x  x  x

1 1 1 1 1

3 3 3 3 3

4 1 16 1

3 3 15 15

5

Integration

In first year, you would have seen the approximation:

  • (^) Approximate the integral by calculating the area of the square

1 2 1

b

a

f x dxf x xx

a = = b

7

Integration

Alternatively, you could use the mid-point:

2 3 1

b

a

f x dxf x xx

a = = b

8

Integration

We could take a weighted average of three points

  • (^) This calculates the area of two trapezoids

The composite

trapezoidal rule

1 2 3 3 1

b

a

f x dx f x f x f x x x

a = = b

10

Integration

A better approximation is to give more weight to the mid

point

  • (^) This calculates the area under the interpolating quadratic

function

Simpson’s rule

1 2 3 3 1

b

a

f x dx f x f x f x x x

a = = b

11

Initial-value Problems

We will use the same weighted average idea to find

better approximations of an initial-value problem

In the last laboratory, we saw

  • (^) Euler’s method
  • (^) Heun’s method

In this laboratory, we will see:

  • (^) The 4

th-order Runge Kutta method

The Dormand-Prince method

Both use weighted averages

13

Initial-value Problems

Recall that given a 1

st-order ordinary-differential equation and an initial condition

Then, given an initial condition

we would like to approximate a solution

      

1 y tf t y t ,

14

  0 0

y ty

Initial-value Problems

For example, consider

16

       

 

1 2 1

y t y t t t t

y

Euler’s Method

Euler’s method approximates the slope by taking one

sample:

This slope is then used to approximate the next point:

k 1 k 1

y y hK

 

K 1 (^)  f (^)  t (^) k , yk

17

Euler’s Method

We follow this slope a distance h = 0.5 out:

19

       

 

1 2 1

y t y t t t t

y

 (^)     1 0

0.5 0.5 1

1 0.5 0.

yyy   

  

Euler’s Method

The approximation is not great if h is too large:

20

       

 

1 2 1

y t y t t t t

y