Numerical solutions of ordinary differential equations

Post on 24-Dec-2021

12 views 0 download

Transcript of Numerical solutions of ordinary differential equations

2 هذه المذكرات لا تغني عن الكتاب

Numerical solutions of ordinary differential equations

In this chapter we discuss numerical method for ODE .

We will discuss the two basic methods, Euler’s Method and

Runge-Kutta Method.

Numerical solution is a table of approximate values of solution

function at discrete set of points

Ch 9

There are many numerical methods that produce numerical

approximations to solutions of differential equations.

3 هذه المذكرات لا تغني عن الكتاب

Numerical solutions of ODEs involves two types of error:

1-Truncation error:

Local truncation error (it is occurs at each step of

numerical method).

Propagated truncation error

The sum of the two is the total or global truncation

error

2-Round-off errors (this error results from the fact that any

calculator or computer can represent numbers using only a

finite number of digits.

Error Analysis:

4 هذه المذكرات لا تغني عن الكتاب

EULER METHODS AND ERROR ANALYSIS

Sec(9.1)

1 ( , ), 0,1,2, (1)n n n ny y hf x y n

Euler’s method is the formula

( , )y f x y 1–n nh x x

where f is the function obtained from the differential

equation and h is a step- size

5 هذه المذكرات لا تغني عن الكتاب

Example 1 Euler’s Method

Use the Euler method to obtain the approximate value of y(1.5)

for the solution of the initial-value problem

Compare the results for h=0.1 and h=0.05.

2 , (1) 1y xy y

Solution

We can obtain the analytic solution

and results similar to those given in Tables 9.1 and 9.2

21xy e

100 Error RelativePercent

exact

approxexact

y

yyNote :

6 هذه المذكرات لا تغني عن الكتاب

7 هذه المذكرات لا تغني عن الكتاب

8 هذه المذكرات لا تغني عن الكتاب

In this case, with a step size h=0.1 a 16% relative error in the

calculation of the approximation to y(1.5) is totally unacceptable.

At the expense of doubling the number of calculations, some

improvement in accuracy is obtained by halving the step size to

h=0.05.

9 هذه المذكرات لا تغني عن الكتاب

2

3

22 2

1

( , )

2!

( , )( ) ( )

2! 2!

where

i ia

i ia

i i

f x yE h R

f x y hE h y c O h

x c x

" ( )' 2

1

' ( 1)2 1

1

Given ' ( , )

...2! !

( , ) ( , )( , ) ... ( )

2! !

nni i

i i i n

nn ni i i i

i i i i

y f x y

y yy y y h h h R

n

f x y f x yy y f x y h h h O h

n

EULER Local Truncation ERROR

We can use Taylor series to quantify the local truncation error

in Euler’s method

Truncation Error for Euler’s Method

10 هذه المذكرات لا تغني عن الكتاب

Solution

Example 2 Bound for Local Truncation Errors

Find a bound for the local truncation errors for Euler’s method

applied to 2 , (1) 1y xy y

From the solution we get

so the local truncation error is

2 1xy e 2 2 1(2 4 ) xy x e

22 2

2 ( 1)( ) (2 4 )2! 2

ch hy c c e

where c is between xn and xn+h. In particular, for h=0.1

we can get an upper bound on the local truncation error for

y1 by replacing c by 1.1:

22

2 ((1.1) 1) (0.1)(2 (4)(1.1) ) 0.0422

2e

11 هذه المذكرات لا تغني عن الكتاب

From Table 9.1 we see that the error after the first step is

0.0337, less than the value given by the bound. Similarly, we

can get a bound for the local truncation error for any of the

five steps given in Table 9.1 by replacing c by 1.5 (this value of c

gives the largest value of for any of the steps and may

be too generous for the first few steps). Doing this gives

as an upper bound for the local truncation error in each step.

22

2 ((1.5) 1) (0.1)(2 (4)(1.5) ) 0.1920

2e

( )y c

12 هذه المذكرات لا تغني عن الكتاب

1-The local truncation error for Euler’s method is

2- The total error in yn+1 is an accumulation of the errors in

each of the previous steps. This total error is called the global

truncation error.

3-The global truncation error for Euler’s method is

4- In general it can be shown that if a method for the numerical

solution of a differential equation has local truncation

error then global truncation error is

2( )O h

Remarks:

( )O h

1( )O h ( )O h

13 هذه المذكرات لا تغني عن الكتاب

5- We expect that, for Euler's method, if the step size is halved

the error will be approximately halved as well. This is borne out

in Tables 9.1 and 9.2 where the absolute error at x=1.50 with

h=0. 1 is 0.5625 and with h=0.05 is 0.3171, approximately half as

large .

14 هذه المذكرات لا تغني عن الكتاب

IMPROVED EULUR’S METHOD

The numerical method defined by the formula

is commonly known as the improved Euler's

method (or Heun's method).

1

1

*1

*1

( , ) ( , )(3)

2

where = ( , ), 0,1,2, (4)

n n n

n n

n n n

n

n

f x y f x yy y h

y y hf x y n

15 هذه المذكرات لا تغني عن الكتاب

Example 3 Improved Euler’s Method

Use the improved Euler’s method to obtain the approximate

value of y(1.5)for the solution of the initial-value problem

Compare the results for h=0.1 and h=0.05. 2 , (1) 1y xy y

Solution

0 0

*

1 0 0 0

1

*

0 0 1 11 0

With 1, 1 , ( , ) 2 , 0, 0.1,

we first compute (4):

y (0.1)(2 ) 1 (0.1)2(1)(1) 1.2

We use this last value in (3) along with 1 1 0.1 1.1

2 2 2(1(0.1) 1 (0.1)

2

n n n nx y f x y x y n and h

y x y

x h

x y x yy y

)(1) 2(1.1)(1.2)1.232

2

The compartive values of the calculation for 0.1 and 0.05

are given in Table 9.3 and 9.4,respectively.

h h

16 هذه المذكرات لا تغني عن الكتاب

17 هذه المذكرات لا تغني عن الكتاب

18 هذه المذكرات لا تغني عن الكتاب

1-The local truncation error for the improved Euler’s method

is

2-The global truncation error for the improved Euler’s method

is

3- Thus the improved Euler’s method is a second order method,

whereas Euler’s method is a first order method.

4-We can not compute all the values of first and then

substitute these values into formula (3). In other words, we

cannot use the data in Table 9.1 to help construct the values in

Table 9.3.

3( )O h

Remarks:

2( )O h

*ny