Sunteți pe pagina 1din 35

Review

Higher Order methods


Multistep methods
Summary

H IGHER O RDER M ETHODS

P.V. Johnson

School of Mathematics

Semester 1 2008

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

E ULER ’ S M ETHOD

Initial value problems for ODEs


Euler’s Method:
w0 = α
wi+1 = wi + hf (xi , wi ), for each i = 0, 1, . . . , n − 1

Local truncation error for Euler’s method:

h
|τi+1 (h)| ≤ M.
2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

E LIMINATING TRUNCATION ERRORS

A second order method should approximate the equation:

h2 ′
yi+1 = yi + hf (xi , yi ) + f (xi , yi )
2
with local truncation error O(h2 ).
Then use a scheme of the form

yi+1 = yi + a1 f (xi + α1 , yi + β1 )

such that

h2 ′
a1 f (xi + α1 , yi + β1 ) = hf (xi , yi ) + f (xi , yi )
2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

E LIMINATING TRUNCATION ERRORS

A second order method should approximate the equation:

h2 ′
yi+1 = yi + hf (xi , yi ) + f (xi , yi )
2
with local truncation error O(h2 ).
Then use a scheme of the form

yi+1 = yi + a1 f (xi + α1 , yi + β1 )

such that

h2 ′
a1 f (xi + α1 , yi + β1 ) = hf (xi , yi ) + f (xi , yi )
2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

M IDPOINT METHOD

Then using a Taylor expansion we may choose the


constants a1 , α1 and β1 to satisfy our second order
equation
One such choice is a1 = h, α1 = h/2 and β1 = (h/2)f (x, y )
gives the midpoint method
w0 = α
wi+1 = wi + hf (xi + h/2, wi + (h/2)f (xi , wi )) ,

We take evaluate the function f half way through the step


to get a better approximation
This is a Runge-Kutta method of order 2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

M IDPOINT METHOD

Then using a Taylor expansion we may choose the


constants a1 , α1 and β1 to satisfy our second order
equation
One such choice is a1 = h, α1 = h/2 and β1 = (h/2)f (x, y )
gives the midpoint method
w0 = α
wi+1 = wi + hf (xi + h/2, wi + (h/2)f (xi , wi )) ,

We take evaluate the function f half way through the step


to get a better approximation
This is a Runge-Kutta method of order 2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

M ODIFIED E ULER METHOD

Now try a scheme of the form

yi+1 = yi + a1 f (x, y ) + a2 f (xi + α1 , yi + δ1 f (x, y ))

Again using the Taylor expansion we can choose the


constants a1 = h/2, a2 = h/2, α1 = h and δ1 = h
This gives the modified Euler method
w0 = α,
h
wi+1 = wi + [f (xi , wi ) + f (xi+1 , wi + hf (xi , wi ))] .
2
This is a Runge-Kutta method of order 2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

M ODIFIED E ULER METHOD

Now try a scheme of the form

yi+1 = yi + a1 f (x, y ) + a2 f (xi + α1 , yi + δ1 f (x, y ))

Again using the Taylor expansion we can choose the


constants a1 = h/2, a2 = h/2, α1 = h and δ1 = h
This gives the modified Euler method
w0 = α,
h
wi+1 = wi + [f (xi , wi ) + f (xi+1 , wi + hf (xi , wi ))] .
2
This is a Runge-Kutta method of order 2

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

RUNGE -K UTTA O RDER F OUR


One of the most popular methods to solve an ODE is the
Runge-Kutta method:

w0 = α,
k1 = hf (xi , yi ),
µ ¶
h 1
k2 = hf xi + , wi + k1
2 2
µ ¶
h 1
k3 = hf xi + , wi + k2
2 2
k4 = hf (xi+1 , wi + k3 )
1
wi+1 =wi + (k1 + 2k2 + 2k3 + k4 ).
6
P.V. Johnson MATH65241
Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

A LGEBRA

The algebra required to arrive at the Runge-Kutta order


four (RK4) method is tedious
The idea is the same as with the midpoint and modified
Euler methods...
Match up and cancel out error terms.
The local truncation error for the RK4 is unsurprisingly
O(h4 )

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

A LGEBRA

The algebra required to arrive at the Runge-Kutta order


four (RK4) method is tedious
The idea is the same as with the midpoint and modified
Euler methods...
Match up and cancel out error terms.
The local truncation error for the RK4 is unsurprisingly
O(h4 )

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

S OLVING A S YSTEM OF F IRST O RDER E QUATIONS

We can solve a system of equations just as easily as a


single equation
Simply rewrite algorithms in vector form, for example
w0 = α
w i+1 = w i + hf (xi , w i ),

so the jth equation is


¡ ¢
wi+1,j = wi,j + hfj xi , wi,1 , . . . , wi,m ,

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

S OLVING A S YSTEM OF F IRST O RDER E QUATIONS

We can solve a system of equations just as easily as a


single equation
Simply rewrite algorithms in vector form, for example
w0 = α
w i+1 = w i + hf (xi , w i ),

so the jth equation is


¡ ¢
wi+1,j = wi,j + hfj xi , wi,1 , . . . , wi,m ,

P.V. Johnson MATH65241


Review
Midpoint and modified Euler method
Higher Order methods
Runge-Kutta Method
Multistep methods
Systems of Equations
Summary

M ODULAR P ROGRAMMING

We can use modular programming to allow functions to


return arrays
This allows for simple coding of the algorithms given above
Example code:

USE some_function_module
REAL, DIMENSION(10) :: y
x = a
DO i = 1,n
y = y + h*f(x,y)
x = x+h
ENDDO

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

O NE S TEP M ETHODS

All methods up to now have been one-step methods ...


using only wi to calculate wi+1
Methods that use more than one previous step are called
multistep methods
There are two types of multistep methods:
Explicit;
Implicit.

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

O NE S TEP M ETHODS

All methods up to now have been one-step methods ...


using only wi to calculate wi+1
Methods that use more than one previous step are called
multistep methods
There are two types of multistep methods:
Explicit;
Implicit.

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

M ODIFIED E ULER METHOD - REVISITED


In the modified Euler method we can see that the last term
is an approximation to the value of the function at xi+1 :

f (xi+1 , wi + hf (xi , wi )) ∼ f (xi+1 , wi+1 )

This suggests we may use the implicit scheme

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

M ODIFIED E ULER METHOD - REVISITED


In the modified Euler method we can see that the last term
is an approximation to the value of the function at xi+1 :

f (xi+1 , wi + hf (xi , wi )) ∼ f (xi+1 , wi+1 )

This suggests we may use the implicit scheme

w0 = α,
h
wi+1 = wi + [f (xi , wi ) + f (xi+1 , wi+1 )] .
2

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

M ODIFIED E ULER METHOD - REVISITED


In the modified Euler method we can see that the last term
is an approximation to the value of the function at xi+1 :

f (xi+1 , wi + hf (xi , wi )) ∼ f (xi+1 , wi+1 )

This suggests we may use the implicit scheme

w0 = α,
h
wi+1 = wi + [f (xi , wi ) + f (xi+1 , wi+1 )] .
2
The value we must calculate now appears on both sides

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

O UTLINE

1 R EVIEW
2 H IGHER O RDER METHODS
Midpoint and modified Euler method
Runge-Kutta Method
Systems of Equations

3 M ULTISTEP METHODS
Implicit Methods
General Multistep Methods

4 S UMMARY

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

T HE G ENERAL M - STEP M ETHOD


The general m-step method can be written as:

wi+1 =am−1 wi + am−2 wi−1 + · · · + a0 wi+1−m


·
+ h bm f (xi+1 , wi+1 ) + bm−1 f (xi , wi )
¸
+ · · · + b0 f (xi+1−m , wi+1−m )

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

T HE G ENERAL M - STEP M ETHOD


The general m-step method can be written as:

wi+1 =am−1 wi + am−2 wi−1 + · · · + a0 wi+1−m


·
+ h bm f (xi+1 , wi+1 ) + bm−1 f (xi , wi )
¸
+ · · · + b0 f (xi+1−m , wi+1−m )

If the scheme has bm = 0 then the scheme is explicit


If the scheme has bm 6= 0 the scheme is now implicit

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

E XAMPLE – A DAMS -BASHFORTH F OUR - STEP M ETHOD

This is an explicit method:

w0 = α0 , w1 = α1 , w2 = α2 and w3 = α3

are calculated using a one-step method(RK4), then for


i = 3, 4, . . . , n − 1 we use

·
h
wi+1 = wi + 55f (xi , wi ) − 59f (xi−1 , wi−1 )
24
¸
+ 37f (xi−2 , wi−2 ) − 9f (xi−3 , wi−3 )

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

U SING M ULTISTEP M ETHODS

Multistep methods don’t involve as many function calls as


their one-step equivalents
Implicit methods are more stable and have smaller errors
than their explicit counterparts
However, they do require iteration
This means that we may use them together, in a
predictor-corrector method
(1) Use the explicit method to guess solution - predict
(2) Input guess into implicit method - correct
(3) Results in small errors with small expense

P.V. Johnson MATH65241


Review
Higher Order methods Implicit Methods
Multistep methods General Multistep Methods
Summary

U SING M ULTISTEP M ETHODS

Multistep methods don’t involve as many function calls as


their one-step equivalents
Implicit methods are more stable and have smaller errors
than their explicit counterparts
However, they do require iteration
This means that we may use them together, in a
predictor-corrector method
(1) Use the explicit method to guess solution - predict
(2) Input guess into implicit method - correct
(3) Results in small errors with small expense

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

S UMMARY

To make higher order methods, we must eliminate


truncation errors
There are often different methods with the same order
We can use modular programming to implement the
algorithms on a system of equations
Multistep methods are less expensive
Implicit schemes have smaller errors, but can be more
expensive than explicit versions

P.V. Johnson MATH65241


Review
Higher Order methods
Multistep methods
Summary

S UMMARY

To make higher order methods, we must eliminate


truncation errors
There are often different methods with the same order
We can use modular programming to implement the
algorithms on a system of equations
Multistep methods are less expensive
Implicit schemes have smaller errors, but can be more
expensive than explicit versions

P.V. Johnson MATH65241

S-ar putea să vă placă și