initial value problems: powerpoint slides
TRANSCRIPT
INITIAL VALUE PROBLEMSINITIAL VALUE PROBLEMS
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
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.
0 0 0( )y x h y x hy x
0hy x
0x
0y x
0y x
h
0y x herror
x1
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
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
Euler’s Method
nnnn yxhfyy ,1
)( nn xyy Value of y at nxx
)( 11 nn xyy Value of y at 1 nxx
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
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
nnnn yxhfyy ,1
Consider the following initial value problem.
500 .)( , yxyyFind the value of y(0.8).
10. Let h
Given:
nnnnn xyxxyyxf ) at(,
5000 .)( yxxy atwhere 00 x
Our starting point.
30103032010202
10100
03
02
01
....
..
hxxhxx
hxx
Based on the sequence generated by Euler’s method we can write:
0001 yxhfyy ,
5505010501 .... y
500500000 ..),( xyyxf
1112 yxhfyy ,
5950450105502 .... y
450105501111 ...),( xyyxf
1010001 .. hxx
2223 yxhfyy ,
6345039501059503 .... y
39502059502222 ...),( xyyxf
201020202 .. hxx
Approximate value of y at x = x3 is 0.6345.
Therefore, we can write that
728205080
634503059502055010
8
3
2
1
.).(..
.).(.).(.).(
yy
yyyyyy
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
*1ny as calculated using the Euler’s
method shown above is used to obtain the 2nd slope.
nnnn yxhfyy ,* 1
*nn y,xf 11
*,, 111 21
nnnnnn yxfyxfhyy
Consider the previous initial value problem.
500 .)( , yxyy
Find the value of y(0.8).
10.h let Again,
5505010501 ....* y
500500000 ..),( xyyxf
450105501111 ...),( ** xyyxf
*,, 110001 21 yxfyxfhyy
*,, 110001 21 yxfyxfhyy
54750450502110501 .....
y
5922504475010547502
. ...*
y
4475010547501111
. ..),(
xyyxf
392250205922502222
. ..),( **
xyyxf
*,, 221112 21 yxfyxfhyy
5894870
392250447502110547502
.
....
y
Taylor’s Method of Order Two
2
2
2Rxyhxyhxyhxy )(
!)()()(
R2 is called Taylor’s remainder.
If h is small then:
)(!
)()()( xyhxyhxyhxy 2
2
Taylor’s method of order two can be written in the form of the following sequence.
)(!
)()()( xyhxyhxyhxy 2
2
nnnn yhyhyy 2
2
1
Solve the following IVP by using Taylor’s method of order two.
10101 )( , , yxxyy
Solution:
xyxyyy 111 )(
nnnn yhyhyy 2
2
1
nnn
nnn
xyyxyy
1
nnnn yhyhyy 2
2
1
)()( nnnnnn xyhxyhyy 21
2
1
hxhhyhhy nnn
22
122
1
Let h = 0.1
10095090501 ... nnn xyy
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
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
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.
Given data points
Obtain a function, P(x)
P(x) goes through the data points
Use P(x)
To estimate values at intermediate points
x
y
2 5
3
8
?
4
P(x)
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
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
( ) ( )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
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.
Simpson’s Rule:
hxxhxx 20201 and
2 2
0 0
x x
x xy x dx P x dx
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 0
0 1 243
x x
x xy x dx P x dx
hy x y x y x
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:
0hy x
0x
0( )y x
hx 0
0y x
h
0y x herror
0 0 0( )y x h y x hy x
0hy x
0x
0( )y x
hx 0
0y x
h
0y x herror
(1) dxxydy
hxy n
nxy dxdy
nx hxn
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
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
( ) ( )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
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
...………………….(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
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)
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
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)
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