lecture 40 numerical analysis. chapter 7 ordinary differential equations

52
Lecture 40 Numerica l Analysis

Upload: ralf-alexander

Post on 18-Jan-2018

234 views

Category:

Documents


1 download

DESCRIPTION

Introduction Taylor Series Euler Method Runge-Kutta Method Predictor Corrector Method

TRANSCRIPT

Page 1: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Lecture 40

NumericalAnalysis

Page 2: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Chapter 7Ordinary

Differential Equations

Page 3: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

IntroductionIntroductionTaylor SeriesTaylor SeriesEuler MethodEuler MethodRunge-Kutta MethodRunge-Kutta MethodPredictor Corrector Predictor Corrector MethodMethod

Page 4: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

RUNGA- RUNGA- KUTTA KUTTA

METHODSMETHODS

Page 5: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

We considered the IVPWe considered the IVP( , ), ( )n n

dy f t y y t ydt

We also defined We also defined 1 2 1( , ), ( , )n n n nk hf t y k hf t h y k

and took the weighted and took the weighted average of average of kk1 1 and and kk2 2 and and added to added to yynn to get to get yyn+1n+1

Page 6: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

We obtainedWe obtained

1 2 21, ( )2

t yt y

f ffW W W f ff

ImplyingImplying

1 2 2 211,2

W W W W

Page 7: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

We considered two cases,We considered two cases,

Case ICase I We choose W We choose W22 = 1/3, = 1/3, then Wthen W11 = 2/3 and = 2/3 and 3/ 2.

1 1 21 (2 )3n ny y k k

1 2 13 3( , ), ,2 2

k hf t y k hf t h y k

Page 8: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Case II: We considered Case II: We considered WW22 = ½, then = ½, then WW11 = ½ and = ½ and

1.

ThenThen 1 21 2n n

k ky y

1 2 1( , ), ( , )k hf t y k hf t h y k

Page 9: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The fourth-order R-K The fourth-order R-K method was described asmethod was described as

1 1 2 3 41 ( 2 2 )6n ny y k k k k

Page 10: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

1

12

23

4 3

( , )

,2 2

,2 2

( , )

n n

n n

n n

n n

k hf t y

khk hf t y

khk hf t y

k hf t h y k

wherewhere

Page 11: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

PREDICTOR – PREDICTOR – CORRECTOR CORRECTOR

METHODMETHOD

Page 12: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Milne’s MethodMilne’s MethodIt is a multi-step method It is a multi-step method where we assume that the where we assume that the solution to the given IVP is solution to the given IVP is known at the past four known at the past four equally spaced point equally spaced point tt00, , tt11, , tt22 and and tt33. .

Page 13: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Alternatively, it can also be Alternatively, it can also be written aswritten as

44 0 1 2 3 0

4 28(2 2 )3 90hy y y y y h y

This is known as This is known as Milne’s Milne’s predictor formulapredictor formula..

Page 14: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Similarly, integrating the Similarly, integrating the original over the interval original over the interval tt00 to to tt22 or or ss = 0 to 2 and repeating = 0 to 2 and repeating the above steps, we getthe above steps, we get

42 0 0 1 2 0

1( 4 )3 90hy y y y y h y

which is known as which is known as Milne’s Milne’s predictor formulapredictor formula..

Page 15: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

In general, Milne’s predictor-In general, Milne’s predictor-corrector pair can be written corrector pair can be written asas

1 3 2 1

1 1 1 1

4: (2 2 )3

: ( 4 )3

n n n n n

n n n n n

hP y y y y y

hC y y y y y

Page 16: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Adam-Moulton Method Adam-Moulton Method It is another predictor-It is another predictor-corrector method, where we corrector method, where we use the fact that the solution use the fact that the solution to the given initial value to the given initial value problem is known at past problem is known at past four equally spaced points four equally spaced points ttnn, , ttn-1n-1, , ttn-2n-2, , ttn-3n-3. .

Page 17: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The task is to compute the The task is to compute the value of value of yy at at ttn+1n+1..

Let us consider the Let us consider the differential equation differential equation

( , )dy f t ydt

Page 18: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Integrating between the Integrating between the limits limits ttnn to to ttn+1n+1, we have, we have

1 1 ( , )n n

n n

t t

t t

dy dt f t y dtdt

That is, That is,

1

1 ( , )n

n

t

n n ty y f t y dt

Page 19: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

To carry out integration, we To carry out integration, we proceed as follows. We proceed as follows. We employ employ Newton’s backward Newton’s backward interpolation formulainterpolation formula, so that, so that

2

3

( 1)( , )2

( 1)( 2)6

n n n

n

s sf t y f s f f

s s s f

nt ts h

Page 20: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

After substitution, we obtainAfter substitution, we obtain

1 21

3 4

( 1)2

( 1)( 2) ( 1)( 2)( 3)6 24

n

n

t

n n n n nt

n n

s sy y f s f f

s s s s s s sf f dt

Page 21: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Now by changing the variable Now by changing the variable of integration (from of integration (from tt to to ss), the ), the limits of integration also limits of integration also changes (from 0 to 1), and changes (from 0 to 1), and thus the above expression thus the above expression becomesbecomes

1 2

1 0

3 4

( 1)2

( 1)( 2) ( 1)( 2)( 3)6 24

n n n n n

n n

s sy y h f s f f

s s s s s s sf f ds

Page 22: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Actual integration reduces Actual integration reduces the above expression to the above expression to

2 3 41

1 5 3 2512 12 8 720n n n n n n ny y h f f f f f

Now substituting the Now substituting the differences such asdifferences such as

1n n nf f f 2

1 22n n n nf f f f

31 2 33 3n n n n nf f f f f

Page 23: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Equation simplifies to Equation simplifies to 4

1 1 2 3251(55 59 37 9 )

24 720n n n n n n nhy y f f f f h f

Alternatively, it can be Alternatively, it can be written aswritten as

41 1 2 3

25155 59 37 924 720n n n n n n nhy y y y y y h y

This is known as Adam’s This is known as Adam’s predictor formula.predictor formula.

Page 24: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The truncation error is The truncation error is 4(251/ 720) .nh y

To obtain corrector To obtain corrector formula, we use Newton’s formula, we use Newton’s backward interpolation backward interpolation formula about formula about ffn+1n+1 instead instead of of ffnn. .

Page 25: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

We obtain We obtain

Carrying out the integration Carrying out the integration and repeating the steps, we and repeating the steps, we get the corrector formula asget the corrector formula as

41 1 1 2 1

199 19 524 720n n n n n n nhy y y y y y h y

0 21 1 1 11

3 41 1

( 1)2

( 1)( 2) ( 1)( 2)( 3)6 24

n n n n n

n n

s sy y h f s f f

s s s s s s sf f ds

Page 26: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Here, the truncation error is Here, the truncation error is

4119 20 .nh y

The truncation error in Adam’s The truncation error in Adam’s predictor is approximately predictor is approximately thirteen times more than that thirteen times more than that in the corrector, but with in the corrector, but with opposite sign. opposite sign.

Page 27: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

In general, Adam-Moulton In general, Adam-Moulton predictor-corrector pair can predictor-corrector pair can be written asbe written as

1 1 2 3

1 1 1 2

: 55 59 37 924

: 9 19 524

n n n n n n

n n n n n n

hP y y y y y y

hC y y y y y y

Page 28: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Example Example Using Adam-Moulton Using Adam-Moulton predictor-corrector method, predictor-corrector method, find the solution of the initial find the solution of the initial value problemvalue problem 2 , (0) 1dy y t y

dt

at at tt = 1.0, taking = 1.0, taking hh = 0.2. = 0.2. Compare it with the analytical Compare it with the analytical solution.solution.

Page 29: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Solution Solution In order to use Adam’s P-C In order to use Adam’s P-C method, we require the method, we require the solution of the given solution of the given differential equation at the differential equation at the past four equally spaced past four equally spaced points, for which we use R-K points, for which we use R-K method of 4method of 4thth order which is order which is self starting. self starting.

Page 30: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Thus taking Thus taking tt00 =0, =0, yy00 = 1, = 1, hh = 0.2, we compute = 0.2, we compute kk11 = 0.2, = 0.2, kk22 = 0.218, = 0.218, kk33 = 0.2198, = 0.2198, kk44 = 0.23596, = 0.23596, and getand get

1 0 1 2 3 41 ( 2 2 ) 1.218596

y y k k k k

Page 31: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Taking Taking tt11 = 0.2, = 0.2, yy11 = 1.21859, = 1.21859, hh = 0.2, = 0.2, we compute we compute kk11 = 0.23571, = 0.23571, kk22 = 0.2492, = 0.2492, kk33 = 0.25064, = 0.25064, kk44 = 0.26184, = 0.26184, and getand get

2 1 1 2 3 41 ( 2 2 ) 1.468136

y y k k k k

Page 32: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Now, we take Now, we take tt22 = 0.4, = 0.4, yy22 = 1.46813, = 1.46813, hh = 0.2, and = 0.2, and compute compute kk11 = 0.2616, = 0.2616, kk22 = 0.2697, = 0.2697, kk33 = 0.2706, = 0.2706, kk44 = 0.2757 = 0.2757 to getto get3 2 1 2 3 4

1(0.6) ( 2 2 ) 1.737796

y y y k k k k

Page 33: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Thus, we have at our disposalThus, we have at our disposal

0

1

2

3

(0) 1(0,2) 1.21859

(0.4) 1.46813(0.6) 1.73779

y yy yyy y

Page 34: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Now, we use Adam’s P-C Now, we use Adam’s P-C pair to calculate pair to calculate y (0.8)y (0.8) and and y y (1.0) as follows:(1.0) as follows:

1 1 2 3

1 1 1 2

: 55 59 37 924

: 9 19 524

n n n n n n

n n n n n n

hP y y y y y y

hC y y y y y y

ThusThus

4 3 3 2 1 055 59 37 924

p hy y y y y y (1)(1)

Page 35: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

From the given differential From the given differential equation, we have equation, we have

2.y y t

Therefore,Therefore, 20 0 0

21 1 1

22 2 2

23 3 3

1.0

1.17859

1.30813

1.37779

y y t

y y t

y y t

y y t

Page 36: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Hence, from Eq. (1), we getHence, from Eq. (1), we get 4

0.2(0.8) 1.73779 75.77845 77.17967 43.60783 924

py y

2.01451

Now to obtain the corrector Now to obtain the corrector value of value of yy at at tt = 0.8, we use = 0.8, we use

4 3 4 3 2 1(0.8) 9 19 524

c c hy y y y y y y (2)(2)

Page 37: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

But,But,2 2

4 4 49 9( ) 9[2.01451 (0.8) ] 12.37059py y t

Therefore,Therefore, 4

0.2(0.8) 1.73779 12.37059 26.17801 6.54065 1.1785924

cy y

2.01434Proceeding similarly, we getProceeding similarly, we get

5 4 4 3 2 1(1.0) 55 59 37 924

p p hy y y y y y y

(3)(3)

Page 38: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Noting that Noting that 24 4 4 1.3743,y y t

we calculatewe calculate 5

0.22.01434 75.5887 81.28961 48.40081 10.6073124

py

2.28178

Now, the corrector formula Now, the corrector formula for computing for computing yy55 is given by is given by

5 4 5 4 3 2(1.0) 9 19 524

c c hy y y y y y y (4)(4)

Page 39: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

But, But, 25 5 59 9 11.53602py y t

Thus, finally we getThus, finally we get 5

0.2(1.0) 2.01434 11.53602 26.17801 6.54065 1.1785924

y y

2.28393 (5)(5)

Page 40: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The analytical solution can be The analytical solution can be seen in the following steps.seen in the following steps.

2dy y tdt

After finding integrating After finding integrating factor and solving, we getfactor and solving, we get

1 2td ye e tdt

Page 41: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Integrating, we get Integrating, we get 2 2 2( ) 2t t t t tye e t dt t d e t e te c

That is, That is, 2 2 2 t

cy t te

Now using the initial Now using the initial condition, condition, yy(0) = 1, (0) = 1, we get c = – 1. we get c = – 1.

Page 42: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Therefore, the analytical Therefore, the analytical solution is given bysolution is given by

2 2 2 ty t t e

from which, we getfrom which, we get(1.0) 5 2.2817y e

Page 43: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Convergence Convergence and Stability and Stability

ConsiderationsConsiderations

Page 44: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The numerical solution The numerical solution of a differential equation of a differential equation can be shown to can be shown to converge to its exact converge to its exact solution, if the step size solution, if the step size hh is very small. is very small.

Page 45: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

The numerical solution of The numerical solution of a differential equation is a differential equation is said to be stable if the said to be stable if the error do not grow error do not grow exponentially as we exponentially as we compute from one step to compute from one step to another. another.

Page 46: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Stability consideration are Stability consideration are very important in finding very important in finding the numerical solutions of the numerical solutions of the differential equations the differential equations either by either by single-stepsingle-step methods or by using methods or by using multi-multi-stepstep methods. methods.

Page 47: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

However, theoretical analysis However, theoretical analysis of stability and convergence of stability and convergence of R -K methods and P –C of R -K methods and P –C methods are highly involved methods are highly involved and obtain numerically stable and obtain numerically stable solution using 4solution using 4thth order R – K order R – K method to the simple problem method to the simple problem y’ = Ay y’ = Ay gives us stability gives us stability condition as condition as -2.78-2.78<<AhAh

Page 48: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

In practice, to get numerically In practice, to get numerically stable solutions to similar stable solutions to similar problems, we choose the problems, we choose the value of h much smaller than value of h much smaller than the value given by the above the value given by the above condition and also check for condition and also check for consistency of the result.consistency of the result.

Page 49: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Another topic of interest which Another topic of interest which is not considered, namely the is not considered, namely the stiff system of differential stiff system of differential equations that arises in many equations that arises in many chemical engineering systems, chemical engineering systems, such as chemical reactors, such as chemical reactors, where the rate constants for the where the rate constants for the reactions involved are widely reactions involved are widely different.different.

Page 50: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Most of the realistic stiff Most of the realistic stiff DE do not have analytical DE do not have analytical solutions and therefore solutions and therefore only numerical solutions only numerical solutions can be obtained. can be obtained.

Page 51: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

However, to get numerically However, to get numerically stable solutions, a very small stable solutions, a very small step size h is required, to use step size h is required, to use either R-K methods or P – C either R-K methods or P – C methods. methods.

More computer time is More computer time is requiredrequired

Page 52: Lecture 40 Numerical Analysis. Chapter 7 Ordinary Differential Equations

Lecture 40

NumericalAnalysis