Professional Documents
Culture Documents
Chapter 12
Euler’s &
Taylor’s
Method
At the end of this chapter, students should be able to:
Recall ordinary differential equation and Taylor’s series
Derive and apply Euler’s method
Apply Taylor’s series of higher order in approximation problem involving
differential equation
12.1 Introduction
Differential equations serve as mathematical descriptions for many physical
phenomena. A few examples of commonly occurring differential equations
are:
a) ay(x) + by(x) + cy(x) = F(x)
w
c) y(x) 1 (y(x))
y
Equation (1) occurs in the study of vibrating or oscillating mechanical
systems or in electrical circuits.
Equation (2) arises in the study of beam deflections.
Equation (3) deals with problems in cable suspension.
193
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Definition
A differential equation (DE) is an equation containing one or more derivatives
of an unknown function.
dn y dn1y d2 y dy
an a n1 a2 a1 a0 y f ( x )
dxn dxn1 dx 2
dx
Order Notation
dy
First order D y y
dx
d2 y
Second order 2
D 2 y y
dx
The order of DE is the order of the highest derivative that it contains. Usually
x is used as independent variable, and y for dependent variable.
194
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Example 1
dy
Consider a differential equation - y 0 . Find the function y that will
dx
satisfy the equation.
Solution
Applying method of variable separable in ordinary differential equation
yields
1
dy dx
y
1
dy dx
y
ln y = x + c
e x c exec y
Hence,
y ke x (k = ec a constant)
What we can say about the above equation is that it has many solutions
If y(0) = 1 : y 0 1, x0 0 y ex
If y(0) = 3 : y 0 3 , x0 0 y 3ex
195
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
y 3ex
y 2ex
y ex
Figure 12.1
The conditions above (i.e. x 0 , y 0 ) are called initial values. Solving differential
equations with initial conditions are sometimes called initial value problems.
Thus, an initial value problem always consists of two parts:
(i) the differential equation y ' (x) f(x, y(x)) , x defined on [a, b]
Example 2
Solve the initial value problem.
dy
x2 6x2 y , y(0) 2
dx
Solution
dy
x 2 6x 2 y
dx
dy
6x 2 y x 2
dx
Identify p(x) 6x2
3
e2x
Rewrite the standard form
ye2x e2x x 2 dx
3 3
Let u 2x3
du 6x 2 dx
1 u
6e du
196
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
1 u
e C
6
1
e2x C
3
6
Hence the general solution is given by
1 3
y Ce2x
6
To determine the particular solution used the initial value given.
x0 ; y 2
1
2 C 1
6
11
C
6
Therefore the particular solution is;
1 11 2x3
y e
6 6
Warm up exercise
dy
(i) Given the differential equation, ( 4 x ) x 1 y .
dx
a. Separate the common terms.
b. Integrate both side.
c. Write the equation in a general form.
dy
(ii) Given the initial value problem, x y x2 x 1 , y(1) 2 .
dx
a. Write the differential equation in a standard form of linear equation.
b. Find the Integrating Factor.
c. Find the particular solution for the differential equation.
197
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Definition
Let y(x) be a function with derivatives of all orders throughout some interval
containing c as an interior point. Then the Taylor series generated by y(x) at
x = c is
(n )
y( x ) y(c ) y' (c )(x c )
y ' ' (c )
x c 2 ... y (c ) x c n ...
2! n!
yn c
x c n
n 0 n !
Corollary
A function y(x + c) can be expanded in a series of positive integral powers of
x:
y' ' ( c ) 2 y (n ) (c ) n
y( x c ) y(c ) y' (c )x x ... x ...
2! n!
Steps
Identify the function
Identify the center
Identify the form
Differentiate f(x) and evaluate at the center
Example 3
1
Represent as a power series in
x 1
(a) x 1 (b) x
Solution
1
(a) Identify function: f (x)
x 1
Identify center: c=1
Identify form:
f (c ) (n )
f ( x ) f (c ) f (c )(x c ) x c 2 ... f (c ) x c n ...
2! n!
198
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
x 11
1 1
f (x) f (1)
x 1 2
1 1
f ( x ) x 1 2 f (1)
x 1 2
22
f iv ( x ) 24x 1 5
24 24
f iv (1)
x 1 5
25
Plug into the identify form.
f (1) iv
f ( x ) f (1) f (1)(x 1) x 12 f (1) x 13 f (1) x 14 ...
2! 3! 4!
1 1 1
( x 1)
2
x 12
6
x 13
24
x 14 ...
x 1 2 22 2!2 3
3!2 4
4!2 5
1 x 1 x 1 2
x 1 x 1 ...
3 4
1
2 2 22 23 24
When determining the Taylor series in term of (x – c), do not do any
simplification. Just leave it as it is.
1
(b) Identify function: f ( x 1)
x 1
Identify center: c = 1
f (c ) 2 f (n ) ( c ) n
Identify form: f ( x c ) f (c ) f (c )x x ... x ...
2! n!
Differentiate f(x) and evaluate at center c = 1
Differentiate Evaluate
1
f ( x) x 1 f (1) 1
x
1
f ( x ) x 2 f (1) 1
x2
2
f ( x ) 2x 3 f (1) 2
x3
199
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
6
f ( x ) 6x 4 f (1) 6
x4
24
f iv ( x ) 24x 5 f iv (1) 24
5
x
Plug into the identify form.
Warm up exercise
Consider the following function and represent f(x) as a power series
in (x – c) and x.
(i) f ( x) x 1 ; c=1
(ii) f ( x) ln(x 1) ; c = -1
y' ' ( x ) 2 y (n ) ( x ) n
y( x h) y( x ) y' ( x )h h ... h ...
2! n!
In the first step we compute
y( x0 h) y( x0 ) y' ( x0 )h
y( x1) y( x0 ) y' ( x0 )h
y1 y0 hy'0
dy
Let y' ( x ) f ( x, y ) , then Euler’s method can be written as:
dx
y( x0 h) y( x0 ) hf( x0, y0 )
y( x1) y( x0 ) hf ( x0, y0 )
200
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
For i = 0, 1, 2, 3, …
y( xi1) y( xi ) hf ( xi, y( xi ))
or
yi1 yi hf(xi, y(xi ))
dy
Note that y' ( x ) is the first order derivatives and rewritten as function of
dx
two variables f(x, y). Hence, f(xi, yi) implies that the function is evaluated at xi
and yi. Geometrically it is an approximation of the curve y(x) by a polygon
whose side is tangent to the curve at x 0 .
Estimate
True
h
x
xi xi+1
Figure 12.1
Example 4
Given
dy
y, y(0) 1.
dx
Using h 0.01 , estimate y(0.01), y(0.02), y(0.03), y(0.04) using Euler’s
method.
201
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Solution
dy
Identify y' ( x )
dx
dy
y
dx
Rewrite y' ( x) f ( x, y)
f ( x, y) y
Identify x 0 , y0 y( x0 ) and h
x0 0 y0 1 h 0.01
Compute f ( x0, y0 )
f ( x0, y0 ) y0
f (0,1) 1
Apply Euler’s method
yi1 yi hf( xi, yi )
y1 y 0 hf ( x 0 , y 0 )
1 (0.01)f (0,1)
1 (0.01)(1) 1.01
Repeat for i = 1, 2, 3 :
y2 = y1 + h f(x1 , y1)
=1.01 + (0.01) (1.01)
=1.0201
y3 = y2 + h. f(x2 , y2)
=1.0201 + (0.01) (1.0201)
=1.0303
y4 = y3 + h f(x3 , y3)
=1.0303 + (0.01) (1.0303)
=1.0406
202
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Example 5
Given y ' t y where y(0) = 2. Apply Euler’s method to the initial value
problems to find y(1.0) choosing:
(a) h = 0.5.
(b) h = 0.2.
Compare with the exact solution; y(t) 3et - t - 1. What is your observation?
Solution
Given
y ' t y and y(0) = 2
rewrite
y ' f (t, y) t y
where
t0 0 y0 2
a) h 0.5 (2 steps)
y(0.5) = y1 = y0 + h(t0 , y0)
= 2 + (0.5) (2)
= 3
b) h = 0.2 (5 steps)
y(0.2) = y1 = 2.4
y(0.4) = y2 = 2.92
y(0.6) = y3 = 3.584
y(0.8) = y4 = 4.4208
y(1.0) = y5 = 5.4650
203
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
h = 0.2
i t f(t, y) Euler Exact Error
0 0 2 2.4 2 0.4000
1 0.2 2.6 2.92 2.464208 0.4558
2 0.4 3.32 3.584 3.075457 0.5085
3 0.6 4.184 4.4208 3.866456 0.5544
4 0.8 5.2208 5.46496 4.876623 0.5883
5 1.0 6.46496 6.757952 6.154845 0.6031
To increase accuracy use a smaller step size (h) or use more steps.
Example 6
Consider the initial value problem y ' 1 t sin(ty) , 0 ≤ t ≤ 2 , y(0) = 0. Use
Euler’s method to approximate y(0.2).
Solution
h = 0.1
0 0 1 0.1
1 0.1 1.001 0.2001
Warm up exercise
dy
Consider x 2 6x 2 y with y(0) = -2.
dx
(i) Identify x 0 and y 0
204
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
h2 h3 3 h4 4
y(x h) y(x) hy ' (x) y ' ' (x) y (x) y (x) ........
2! 3! 4!
h2
y(x h) y(x) hy ' (x) y ' ' (x) 2
2!
h2 h3 3
y(x h) y(x) hy ' (x) y ' ' (x) y (x) 3
2! 3!
h2 h3 3 h4 4
y(x h) y(x) hy ' (x) y ' ' (x) y (x) y (x)
2! 3! 4!
4
.
.
h2 hn n
y(x h) y(x) hy ' (x) y ' ' (x) ............ y (x) n
2! n!
h2 h3 h4
y(x h) y(x) hf(x, y(x)) f' (x, y(x)) f' ' (x, y(x)) f' ' ' (x, y(x)) ...
2! 3! 4!
where f, f ' , f ' ' , f ' ' ' are evaluated at (x, y(x)).
205
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
For a small value of h, the higher powers h 2 , h3 , h 4 , ..... will be very small
and the corresponding terms can be ignored. The omission of further terms
causes an error, which is called the truncation error. In calculating the
approximation, the more number of terms used means the more accurate is
our answer.
Example 7
Use Taylor series of order 2 to estimate y(0.2) if
Solution
h2
yi1 yi hf(xi, yi ) f' (xi, yi )
2!
Identify f ( x, y )
f ( x, y) y x2 1
Determine f ' ( x, y) , f ' ' ( x, y) ; etc
f ' ( x, y) y'2x
f ( x, y) 2x
Identify x i , y i and h
f ( x 0 , y 0 ) y 0 x 02 1
f (0, 0.5) 0.5 0 1
1.5
f ' ( x 0 , y 0 ) f ( x 0 , y 0 ) 2x 0
1.5
Apply relevant Taylor’s method
h2
y(0.2) y(0) hy'(0) y' ' (0)
2!
h2
y1 y0 (0.2)f(x0 , y 0 ) f' (x0 , y 0 )
2!
206
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
(0.2)2
y1 0.5 (0.2)(1.5) (1.5)
2
0.83
Example 8
Derive the Taylor’s series method of order 4 for the ODE
dy
y et
dt
y( 0 ) 1
and estimate y(0.1) and y(0.2).
Solution
h2 h3 h4
yi1 yi hf(ti, yi ) f' (ti, yi ) f' ' (ti, yi ) f' ' ' (ti, yi )
2! 3! 4!
f (t, y) y et
f ' ( t, y ) y'e t
f ( t, y ) e t
f ' ' ( t, y ) y' ' e t
f ( t, y ) e t e t
f ( t, y ) 2e t
f ' ' ' ( t, y ) f ' ( t, y ) 2e t
f ( t, y ) e t 2e t
f ( t, y ) 3e t
h2 h3 h4
y i 1 yi hf(ti , y i ) f' (ti , y i ) f' ' (ti , y i ) f' ' ' (ti , y i )
2! 3! 4!
h2
y i hf(ti , y i )
2!
f (ti, yi ) e t i
h3
3!
f ( t i , y i ) 2e t i
h4
4!
f ( t i , y i ) 3e t i
2 3
h
4 h 2 3
h ti
4
f(ti , y i )
h h h
y i h e
2! 3! 4! 2 3 8
Given
t0 0 y0 1 and h = 0.1
207
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
h 2 h3 h 4 h 2 h3 h 4 t
y i 1 y i h f(ti , y i ) e
2! 3! 4! 2 3 8
y(0.1) y 0 0.1
0.12 0.13 0.14
2!
3!
4!
t
y0 e 0
0.12 0.13 0.14 t
2
3
e 0
8
1 0.1052 1 e 0 0.0053e0
1 0.10522 0.0053
1.2157
Example 9
For the IVP
y0 1 ;
dy
2y 2 - e- 4t
dt
estimate y(0.1) using:
a) Euler’s method.
b) Taylor’s method of order 2.
c) Taylor’s method of order 4.
e4t e2t
Compare them to the exact solution y( t ) 1 .
2 2
Solution
208
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
h2
y(x h) y(x) hy ' (x) y ' ' (x)
2!
y' ( t ) f ( t, y ) 2 - e-4t 2y
f (0,1) 2 1 2 1
(0.1)2
y(0.1) y(0) (0.1)(-1) (6)
2!
1 - 0.1 0.03
0.93
c) Taylor’s method of order 4
h2 h3 3 h4 4
y(x h) y(x) hy ' (x) y ' ' (x) y (x) y (x)
2! 3! 4!
y' ( t ) f ( t, y ) 2 - e-4t 2y
f (0,1) 2 1 2 1
Exact value is
e4(0.1) e2(0.1)
y(0.1) 1
2 2
0.9258
209
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
Taylor's Taylor's
Exact Euler's
2nd 4th
Computation 0.9258 0.9 0.93 0.9258
Absolute
0 0.0258 0.0042 0
Error
Warm up exercise
dy
Consider x 2 6x 2 y with y(0) = -2.
dx
(i) Identify f ( x, y )
(iv) Compute f ( x0, y0 ) , f ' ( x0, y0 ) , f ' ' ( x0, y0 ) and f ' ' ' ( x0, y0 ) .
(v) Approximate y(0.5).
Exercise 12
dy
1. Let 2xy with initial condition y0 2 and x0 2 . Approximate the
dx
solution at x1 1.1 by performing one iteration of Euler’s method with h = 0.1.
dy
3. Use Euler’s method to determine the solution to y 2 t 2 with y(1) = 0,
dt
a) when t =2 for h = 0.2
b) when t = 5 for h = 0.5
210
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
dy y
4. Let with initial condition y 0 4 and t 0 0 . Approximate the solution
dt 2
at t 0.4 by performing
a) two iterations of Taylor’s method of order two.
b) one iteration of Taylor’s method of order four.
5. Construct a table of x and y values for x [0, 1] with h = 0.1 for the initial value
1
problem y , y(0) = 2 using:
xy
a) Euler’s method
b) Taylor’s method of order 2
dy
6. Solve the differential equation x y xy with initial condition y(0) = 0
dx
to approximate y(0. 1), y(0.2), y(0.3) and y(0.5) by
a) Euler’s method.
b) Taylor’s method of order 2.
c) Taylor’s method of order 3.
d) Taylor’s method of order 4.
211
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
#6
i x h y f(x,y) Euler's
0 0 0.1 0 0 0
1 0.1 0.1 0 0.1 0.01
2 0.2 0.1 0.01 0.212 0.0312
3 0.3 0.1 0.0312 0.3406 0.0653
4 0.5 0.2 0.0653 0.598 0.1849
212
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
(7.6.2)
213
Part 7 NUMERICAL SOLUTION OF ODE MAT 575
214