Vous êtes sur la page 1sur 23

5.3.1 Modiﬁed Euler Method

Numerical solution of Initial Value Problem:

dY

dt

= f (t, Y ) Y (t n+1 ) = Y (t n ) +

t

n

t n+1

f (t, Y (t)) dt.

5.3.1 Modiﬁed Euler Method

Numerical solution of Initial Value Problem:

dY

dt

= f (t, Y ) Y (t n+1 ) = Y (t n ) +

t

n

t n+1

f (t, Y (t)) dt.

Approximate integral using the trapezium rule:

h

Y (t n+1 ) Y (t n ) + 2 [f (t n , Y (t n )) + f (t n+1 , Y (t n+1 ))] ,

t n+1 = t n + h.

5.3.1 Modiﬁed Euler Method

Numerical solution of Initial Value Problem:

dY

dt

= f (t, Y ) Y (t n+1 ) = Y (t n ) +

t

n

t n+1

f (t, Y (t)) dt.

Approximate integral using the trapezium rule:

h

Y (t n+1 ) Y (t n ) + 2 [f (t n , Y (t n )) + f (t n+1 , Y (t n+1 ))] ,

t n+1 = t n + h.

Use Euler’s method to approximate Y (t n+1 ) Y (t n ) + hf (t n , Y (t n )) in trapezium rule:

Y

h

(t n+1 ) Y (t n ) + 2 [f (t n , Y (t n )) + f (t n+1 , Y (t n ) + hf (t n , Y (t n )))] .

5.3.1 Modiﬁed Euler Method

Numerical solution of Initial Value Problem:

dY

dt

= f (t, Y ) Y (t n+1 ) = Y (t n ) +

t

n

t n+1

f (t, Y (t)) dt.

Approximate integral using the trapezium rule:

h

Y (t n+1 ) Y (t n ) + 2 [f (t n , Y (t n )) + f (t n+1 , Y (t n+1 ))] ,

t n+1 = t n + h.

Use Euler’s method to approximate Y (t n+1 ) Y (t n ) + hf (t n , Y (t n )) in trapezium rule:

Y

h

(t n+1 ) Y (t n ) + 2 [f (t n , Y (t n )) + f (t n+1 , Y (t n ) + hf (t n , Y (t n )))] .

Hence the modiﬁed Euler’s scheme

y n+1 = y n +

h

2

[f (t n , y n ) + f (t n+1 , y n + hf (t n , y n ))]

K 1 =
hf (t n , y n )
K 2 = hf (t n+1 , y n + K 1 )
y n+1 = y n + K 1 + K 2
2

5.3.1 Modiﬁed Euler Method — Local truncation error (1/3)

Local truncation error due to the approximation:

where

Y (t n+1 ) Y (t n ) +

1

2

(K 1 + K 2 )

K 1 = hf (t n , Y (t n )) and K 2 = hf (t n + h, Y (t n ) + K 1 ).

5.3.1 Modiﬁed Euler Method — Local truncation error (1/3)

Local truncation error due to the approximation:

where

Y (t n+1 ) Y (t n ) +

1

2

(K 1 + K 2 )

K 1 = hf (t n , Y (t n )) and K 2 = hf (t n + h, Y (t n ) + K 1 ).

Taylor Series of f (t n + h, Y (t n ) + K 1 ) in two variables:

K 2 = h f (t n , Y (t n )) + h t f (t n , Y (t n )) + K 1 Y f (t n , Y (t n )) + O h 2 , K .

2

1

5.3.1 Modiﬁed Euler Method — Local truncation error (1/3)

Local truncation error due to the approximation:

where

Y (t n+1 ) Y (t n ) +

1

2

(K 1 + K 2 )

K 1 = hf (t n , Y (t n )) and K 2 = hf (t n + h, Y (t n ) + K 1 ).

Taylor Series of f (t n + h, Y (t n ) + K 1 ) in two variables:

K 2 = h f (t n , Y (t n )) + h t f (t n , Y (t n )) + K 1 Y f (t n , Y (t n )) + O h 2 , K

2

1

Since K 1 = hf (t n , Y (t n )) = O(h),

.

2 1 (K 1 + K 2 ) = hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3 ,

Expression to be compared with Taylor expansion of Y (t n+1 )

5.3.1 Modiﬁed Euler Method — Local truncation error (2/3)

Taylor Series of Y (t n+1 ) = Y (t n + h):

Y (t n + h) = Y (t n ) + hY (t n ) + h 2 Y (t n ) + O h 3 .

2

5.3.1 Modiﬁed Euler Method — Local truncation error (2/3)

Taylor Series of Y (t n+1 ) = Y (t n + h):

Y (t n +

h) = Y (t n ) + hY (t n ) + h 2 Y (t n ) + O h 3 .

2

Substitute Y (t n ) = f (t n , Y (t n ))

5.3.1 Modiﬁed Euler Method — Local truncation error (2/3)

Taylor Series of Y (t n+1 ) = Y (t n + h):

Y (t n +

h) = Y (t n ) + hY (t n ) + h 2 Y (t n ) + O h 3 .

2

Substitute Y (t n ) = f (t n , Y (t n )) and

Y (t n ) =

=

dt f (t, Y (t))

d

t n

=

d

t f (t n , Y (t n )) + dt Y (t n ) Y f (t n , Y (t n )),

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )),

5.3.1 Modiﬁed Euler Method — Local truncation error (2/3)

Taylor Series of Y (t n+1 ) = Y (t n + h):

Y (t n +

h) = Y (t n ) + hY (t n ) + h 2 Y (t n ) + O h 3 .

2

Substitute Y (t n ) = f (t n , Y (t n )) and

Y

(t n ) =

=

dt f (t, Y (t))

d

t n

=

d

t f (t n , Y (t n )) + dt Y (t n ) Y f (t n , Y (t n )),

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )),

to get

Y (t n + h) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3 .

(5.10)

5.3.1 Modiﬁed Euler Method — Local truncation error (3/3)

Now, the equations

Y (t n+1 ) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3

5.3.1 Modiﬁed Euler Method — Local truncation error (3/3)

Now, the equations

Y

and

1

2

(t n+1 ) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n ))

(K 1 + K 2 ) = hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n ))

+

+

f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3

f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3

5.3.1 Modiﬁed Euler Method — Local truncation error (3/3)

Now, the equations

Y

and

1

2

(t n+1 ) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n ))

+

(K 1 + K 2 ) = hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n ))

+

f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3

f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3

imply that Y (t n+1 ) = Y (t n ) + 1

2 (K 1 + K 2 ) + O h 3 .

The local truncation error is τ n = O h 3 : the modiﬁed Euler method is second order accurate. (A method is conventionally called p th order if the local truncation error is of order p + 1.)

5.3.2 Second order Runge-Kutta schemes (1/3)

Modiﬁed Euler is an example of 2 nd order R-K method.

5.3.2 Second order Runge-Kutta schemes (1/3)

Modiﬁed Euler is an example of 2 nd order R-K method.

The general 2 nd order Runge-Kutta scheme takes the form

K 1 = hf (t n , y n );

K 2 = hf (t n + αh, y n + βK 1 );

y n+1 = y n + a 1 K 1 + a 2 K 2 .

(5.11)

5.3.2 Second order Runge-Kutta schemes (1/3)

Modiﬁed Euler is an example of 2 nd order R-K method.

The general 2 nd order Runge-Kutta scheme takes the form

K 1 = hf (t n , y n );

K 2 = hf (t n + αh, y n + βK 1 );

y n+1 = y n + a 1 K 1 + a 2 K 2 .

(5.11)

Repeating the earlier analysis, K 1 = hf (t n , Y (t n )) and

K 2 = hf (t n , Y (t n ))

+

h 2 α t f (t n , Y (t n )) + βf (t n , Y (t n )) Y f (t n , Y (t n )) + O(h 3 );

a 1 K 1 + a 2 K 2 = h(a 1 + a 2 )f (t n , Y (t n ))

+

a 2 h 2 α t f (t n , Y (t n )) + βf (t n , Y (t n )) Y f (t n , Y (t n )) + O(h 3 ).

5.3.2 Second order Runge-Kutta schemes (2/3)

Comparing

a 1 K 1 + a 2 K 2 = h(a 1 + a 2 )f (t n , Y (t n ))

+

a 2 h 2 α t f (t n , Y (t n )) + βf (t n , Y (t n )) Y f (t n , Y (t n )) + O(h 3 )

5.3.2 Second order Runge-Kutta schemes (2/3)

Comparing

a 1 K 1 + a 2 K 2 = h(a 1 + a 2 )f (t n , Y (t n ))

+

a 2 h 2 α t f (t n , Y (t n )) + βf (t n , Y (t n )) Y f (t n , Y (t n ))

with equation (5.10)

+

O(h 3 )

Y (t n+1 ) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3 ,

5.3.2 Second order Runge-Kutta schemes (2/3)

Comparing

a 1 K 1 + a 2 K 2 = h(a 1 + a 2 )f (t n , Y (t n ))

+

a 2 h 2 α t f (t n , Y (t n )) + βf (t n , Y (t n )) Y f (t n , Y (t n ))

with equation (5.10)

+

O(h 3 )

Y (t n+1 ) = Y (t n ) + hf (t n , Y (t n ))

+ h 2

2

t f (t n , Y (t n )) + f (t n , Y (t n )) Y f (t n , Y (t n )) + O h 3 ,

one gets a second order scheme Y (t n+1 ) = Y (t n ) + a 1 K 1 + a 2 K 2 + O h 3 if

a 1 + a 2 = 1;

  αa 2 = βa 2 = 1

2 .

(5.12)

5.3.2 Second order Runge-Kutta Schemes (3/3)

General 2 nd order Runge-Kutta scheme:

K 1 =

K 2 = hf (t n + αh, y n + βK 1 );

y n+1 = y n + a 1 K 1 + a 2 K 2 .

hf (t n , y n );

with

a 1 + a 2 = 1;

αa 2 = βa 2 = 2 1 .

Since we have 3 equations and 4 unknowns (a 1 , a 2 , α, β), there are inﬁnitely many solutions.

5.3.2 Second order Runge-Kutta Schemes (3/3)

General 2 nd order Runge-Kutta scheme:

K 1 = hf (t n , y n );

K 2 = hf (t n + αh, y n + βK 1 );

y n+1 = y n + a 1 K 1 + a 2 K 2 .

with

a 1 + a 2 = 1;

αa 2 = βa 2 = 2 1 .

Since we have 3 equations and 4 unknowns (a 1 , a 2 , α, β), there are inﬁnitely many solutions.

The most popular are,

Modiﬁed Euler: a 1 = a 2 = 1/2, α = β = 1.

K 1 = hf (t n , y n ), K 2 = hf (t n + h, y n + K 1 ) and y n+1 = y n + (K 1 + K 2 )/2.

Midpoint method: a 1 = 0, a 2 = 1, α = β = 1/2.

K 1 = hf (t n , y n ), K 2 = hf (t n + h/2, y n + K 1 /2) and y n+1 = y n + K 2 .

Heun’s method: a 1 = 1/4, a 2 = 3/4, α = β = 2/3.

K 1 = hf (t n , y n ), K 2 = hf (t n + 2h/3,

y n+1 = y n + (K 1 + 3K 2 )/4.

y n + 2K 1 /3) and

5.3.3 Higher order Runge-Kutta methods

Schemes of the form (5.11) can be extended to higher order methods. The most widely used Runge-Kutta scheme is the 4 th order scheme RK4 based on Simpson’s rule.

y n+1 = y n +

1

6 (K 1 + 2K 2 + 2K 3 + K 4 ),

where K 1 = hf (t n , y n ),

K 2 = hf t n +

K 3 = hf t n +

h

2

h

,

2

,

y n + K 1 ,

2

y n + K 2 ,

2

K 4 = hf (t n + h, y n + K 3 ).

(5.13)

This scheme has local truncation error of order h 5 , which can be checked in the same way as the second order scheme, but involves rather messy algebra.