initial value problems: powerpoint slides

53
INITIAL VALUE PROBLEMS INITIAL VALUE PROBLEMS

Upload: vuhanh

Post on 07-Feb-2017

282 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Initial Value Problems: PowerPoint Slides

INITIAL VALUE PROBLEMSINITIAL VALUE PROBLEMS

Page 2: Initial Value Problems: PowerPoint Slides

REMEMBERREMEMBERNUMERICAL DIFFERENTIATIONNUMERICAL DIFFERENTIATION

Forward Difference Formula

The derivative of y(x) at x0 is:

0 00 0

limh

y x h y xy x

h

An approximation to this is:

for small values of h. 0 00

y x h y xy x

h

Page 3: Initial Value Problems: PowerPoint Slides

0 00

( )y x h y xy x

h

0 0 0( )hy x y x h y x

0 0 0( )y x hy x y x h

0 0 0( )y x h y x hy x

Provided h is small.

Page 4: Initial Value Problems: PowerPoint Slides

0 0 0( )y x h y x hy x

0hy x

0x

0y x

0y x

h

0y x herror

x1

Page 5: Initial Value Problems: PowerPoint Slides

0 0 0( )y x h y x hy x

The value of a function at hx 0can be approximated if we know its value

and its slope at an earlier point, 0xprovided h is small.

A sequence can be written as:

001 yhyy

Page 6: Initial Value Problems: PowerPoint Slides

1n n ny y hy

001 yhyy

In an initial value problem, ny is given

and often written as: nn yxf ,

nnnn yxhfyy ,1Therefore,

2 1 1y y hy

Page 7: Initial Value Problems: PowerPoint Slides

Euler’s Method

nnnn yxhfyy ,1

)( nn xyy Value of y at nxx

)( 11 nn xyy Value of y at 1 nxx

Page 8: Initial Value Problems: PowerPoint Slides

nnn xyyxf ,First derivative of y at nxx h is a small number by which x is incremented.

hxx 01

hxhxx 2012 hxhxx 3023

nhxxn 0

Page 9: Initial Value Problems: PowerPoint Slides

So what are we doing in Euler’s method?

We are approximating the value of the function y at x = xn+1 based on the information that we obtained at the previous point, x = xn .

The previous information are:

The value of y at x = xn

The value of the first derivative of y at x = xn

Page 10: Initial Value Problems: PowerPoint Slides

nnnn yxhfyy ,1

Consider the following initial value problem.

500 .)( , yxyyFind the value of y(0.8).

10. Let h

Page 11: Initial Value Problems: PowerPoint Slides

Given:

nnnnn xyxxyyxf ) at(,

5000 .)( yxxy atwhere 00 x

Our starting point.

30103032010202

10100

03

02

01

....

..

hxxhxx

hxx

Page 12: Initial Value Problems: PowerPoint Slides

Based on the sequence generated by Euler’s method we can write:

0001 yxhfyy ,

5505010501 .... y

500500000 ..),( xyyxf

Page 13: Initial Value Problems: PowerPoint Slides

1112 yxhfyy ,

5950450105502 .... y

450105501111 ...),( xyyxf

1010001 .. hxx

Page 14: Initial Value Problems: PowerPoint Slides

2223 yxhfyy ,

6345039501059503 .... y

39502059502222 ...),( xyyxf

201020202 .. hxx

Approximate value of y at x = x3 is 0.6345.

Page 15: Initial Value Problems: PowerPoint Slides

Therefore, we can write that

728205080

634503059502055010

8

3

2

1

.).(..

.).(.).(.).(

yy

yyyyyy

Page 16: Initial Value Problems: PowerPoint Slides

Modified Euler’s Method (Heun’s Method)

In the Modified Euler’s method an average value of the slope is used.

*,, 111 21

nnnnnn yxfyxfhyy

Where*

1ny is calculated using the Euler’s method.

nnnn yxhfyy ,* 1

Page 17: Initial Value Problems: PowerPoint Slides

*1ny as calculated using the Euler’s

method shown above is used to obtain the 2nd slope.

nnnn yxhfyy ,* 1

*nn y,xf 11

Page 18: Initial Value Problems: PowerPoint Slides

*,, 111 21

nnnnnn yxfyxfhyy

Page 19: Initial Value Problems: PowerPoint Slides

Consider the previous initial value problem.

500 .)( , yxyy

Find the value of y(0.8).

10.h let Again,

Page 20: Initial Value Problems: PowerPoint Slides

5505010501 ....* y

500500000 ..),( xyyxf

450105501111 ...),( ** xyyxf

*,, 110001 21 yxfyxfhyy

Page 21: Initial Value Problems: PowerPoint Slides

*,, 110001 21 yxfyxfhyy

54750450502110501 .....

y

Page 22: Initial Value Problems: PowerPoint Slides

5922504475010547502

. ...*

y

4475010547501111

. ..),(

xyyxf

392250205922502222

. ..),( **

xyyxf

Page 23: Initial Value Problems: PowerPoint Slides

*,, 221112 21 yxfyxfhyy

5894870

392250447502110547502

.

....

y

Page 24: Initial Value Problems: PowerPoint Slides

Taylor’s Method of Order Two

2

2

2Rxyhxyhxyhxy )(

!)()()(

R2 is called Taylor’s remainder.

If h is small then:

)(!

)()()( xyhxyhxyhxy 2

2

Page 25: Initial Value Problems: PowerPoint Slides

Taylor’s method of order two can be written in the form of the following sequence.

)(!

)()()( xyhxyhxyhxy 2

2

nnnn yhyhyy 2

2

1

Page 26: Initial Value Problems: PowerPoint Slides

Solve the following IVP by using Taylor’s method of order two.

10101 )( , , yxxyy

Solution:

xyxyyy 111 )(

nnnn yhyhyy 2

2

1

Page 27: Initial Value Problems: PowerPoint Slides

nnn

nnn

xyyxyy

1

nnnn yhyhyy 2

2

1

)()( nnnnnn xyhxyhyy 21

2

1

Page 28: Initial Value Problems: PowerPoint Slides

hxhhyhhy nnn

22

122

1

Let h = 0.1

10095090501 ... nnn xyy

Page 29: Initial Value Problems: PowerPoint Slides

n xn yn+1

0 0.0 1.005

1 0.1 1.019025

2 0.2 1.041218

3 0.3 1.070802

4 0.4 1.107076

Results with Taylor’s Method of Order Two

Page 30: Initial Value Problems: PowerPoint Slides

Interpolation produces a function that matches the given data exactly. The function then should provide a good approximation to the data values at intermediate points.

INTERPOLATIONINTERPOLATION

Page 31: Initial Value Problems: PowerPoint Slides

Interpolation may also be used to produce a smooth graph of a function for which values are known only at discrete points, either from measurements or calculations.

Page 32: Initial Value Problems: PowerPoint Slides

Given data points

Obtain a function, P(x)

P(x) goes through the data points

Use P(x)

To estimate values at intermediate points

Page 33: Initial Value Problems: PowerPoint Slides

x

y

2 5

3

8

?

4

P(x)

Page 34: Initial Value Problems: PowerPoint Slides

Assume that a function goes through three points:

0 0 1 1 2 2, , , and , .x y x x y x x y x

( ) ( )y x P x

0 0 1 1 2 2P x L x y x L x y x L x y x

Lagrange Interpolating Polynomial

Page 35: Initial Value Problems: PowerPoint Slides

1 20

0 1 0 2

0 21

1 0 1 2

0 12

2 0 2 1

( )( )( )( )( )( )

( )( )( )( )

( )( )

x x x xP x y x

x x x xx x x x

y xx x x xx x x x

y xx x x x

0 0 1 1 2 2P x L x y x L x y x L x y x

Page 36: Initial Value Problems: PowerPoint Slides

( ) ( )y x P x

1 20

0 1 0 2

0 21

1 0 1 2

0 12

2 0 2 1

2( )( )

2

( )( )2

( )( )

x x xP x y x

x x x xx x x

y xx x x x

x x xy x

x x x x

Page 37: Initial Value Problems: PowerPoint Slides

NUMERICAL INTEGRATIONNUMERICAL INTEGRATION

( )b

a

y x dx area under the curve f(x) between. to bxax

In many cases a mathematical expression for y(x) is unknown and in some cases even if y(x) is known its complex form makes it difficult to perform the integration.

Page 38: Initial Value Problems: PowerPoint Slides

Simpson’s Rule:

hxxhxx 20201 and

2 2

0 0

x x

x xy x dx P x dx

Page 39: Initial Value Problems: PowerPoint Slides

2 2

0 0

2

0

2

0

1 20

0 1 0 2

0 21

1 0 1 2

0 12

2 0 2 1

( )( )( )( )

( )( )

( )( )( )( )

( )( )

x x

x x

x

x

x

x

x x x xP x dx y x dx

x x x xx x x x

y x dxx x x xx x x x

y x dxx x x x

Page 40: Initial Value Problems: PowerPoint Slides

2 2

0 0

0 1 243

x x

x xy x dx P x dx

hy x y x y x

Page 41: Initial Value Problems: PowerPoint Slides

Runge-Kutta Method of Order Four

Runge-Kutta method uses a sampling of slopes through an interval and takes a weighted average slope to calculate the end point. By using fundamental theorem as shown in Figure 1 we can write:

Page 42: Initial Value Problems: PowerPoint Slides

0hy x

0x

0( )y x

hx 0

0y x

h

0y x herror

0 0 0( )y x h y x hy x

Page 43: Initial Value Problems: PowerPoint Slides

0hy x

0x

0( )y x

hx 0

0y x

h

0y x herror

Page 44: Initial Value Problems: PowerPoint Slides

(1) dxxydy

hxy n

nxy dxdy

nx hxn

Page 45: Initial Value Problems: PowerPoint Slides

Integrating both sides of Eqn. (1) we get

(2) dxxydy

Applying appropriate limits to Eqn. (2) we get

(3) 1

1 dxxyxyxyn

n

x

xnn

(4) dxxyxyhxyhx

xnnn

n

Page 46: Initial Value Problems: PowerPoint Slides

Let us now concentrate on the right-hand side of Eqn. (4).

(5) dxxPdxxyhx

x

hx

x

n

n

n

n

P(x) can be generated by utilizing Lagrange Interpolating Polynomial. Assume that the only information we have about a function, f(x) is that it goes through three points:

0 0 1 1 2 2, , , and , .x y x x y x x y x

Page 47: Initial Value Problems: PowerPoint Slides

( ) ( )P x y x 0 0 1 1 2 2P x L x y x L x y x L x y x

1 20

0 1 0 2

0 21

1 0 1 2

0 12

2 0 2 1

( )( )( )( )( )( )

( )( )( )( )

( )( )

x x x xP x y x

x x x xx x x x

y xx x x xx x x x

y xx x x x

Page 48: Initial Value Problems: PowerPoint Slides

Using Simpson’s Integration,

2 2

0 0

1 0 2 0and 2

x x

x xy x dx P x dx

x x h x x h

Page 49: Initial Value Problems: PowerPoint Slides

...………………….(6)

2 2

0 0

2

0

2

0

1 20

0 1 0 2

0 21

1 0 1 2

0 12

2 0 2 1

( )( )( )( )

( )( )

( )( )( )( )

( )( )

x x

x x

x

x

x

x

x x x xP x dx y x dx

x x x xx x x x

y x dxx x x xx x x x

y x dxx x x x

2 2

0 00 1 24

3x x

x x

hy x dx P x dx y x y x y x

Page 50: Initial Value Problems: PowerPoint Slides

We can apply Simpson’s Integration to Eqn. (6) with the following substitutions:

nxx 0 hxx n 2; ;

2/hh and the midpoint, 21hxx n

hxyhxyxyhdxxy nnn

hx

x

n

n 24

6

….(7)

Page 51: Initial Value Problems: PowerPoint Slides

Compared to Euler’s Formula, an average of six slopes is used in Eqn. (7) instead of just one slope. Actually, the slope at the midpoint has a weight of 4. The slope at the midpoint can be estimated in two ways.

hxyhxyhxyxyhdxxy nnnn

hx

x

n

n 22

22

6

hxyhxyhxyxyhxyhxy nnnnnn 2

22

26

hxyhxyhxyxyhxyhxy nnnnnn 2

22

26

Page 52: Initial Value Problems: PowerPoint Slides

The slopes can be estimated in the following manner:

nnn yxfkxy ,1

12 2

,22

khyhxfkhxy nnn

11 2

22

26 nnnnnn xy

hxy

hxyxy

hxyxy

........... (8)

Page 53: Initial Value Problems: PowerPoint Slides

23 2

,22

khyhxfkhxy nnn

34 , hkyhxfkhxy nnn

Substituting the estimated slopes into Eqn. (8) gives the formula for Runge-Kutta Method of Fourth Order:

43211 226

kkkkhyy nn