Académique Documents
Professionnel Documents
Culture Documents
02
Eulers Method for Ordinary Differential Equations
1.
2.
3.
4.
in
dy
+ 2 y = 1.3e x , y (0 ) = 5
dx
dy
= f ( x, y ), y (0) = y 0 form.
dx
Solution
dy
+ 2 y = 1.3e x , y (0 ) = 5
dx
dy
= 1.3e x 2 y, y (0 ) = 5
dx
In this case
08.02.1
08.02.2
Chapter 08.02
f ( x, y ) = 1.3e x 2 y
Example 2
Rewrite
ey
in
dy
+ x 2 y 2 = 2 sin(3 x), y (0 ) = 5
dx
dy
= f ( x, y ), y (0) = y 0 form.
dx
Solution
dy
+ x 2 y 2 = 2 sin(3 x), y (0 ) = 5
dx
dy 2 sin(3 x) x 2 y 2
=
, y (0 ) = 5
dx
ey
In this case
2 sin(3 x) x 2 y 2
f ( x, y ) =
ey
ey
True value
( x0 , y 0 )
y1,
Predicted
value
Step size, h
x1
Figure 1 Graphical interpretation of the first step of Eulers method.
Eulers Method
08.02.3
(2)
y1 = y 0 + f (x0 , y 0 )h
One can now use the value of y1 (an approximate value of y at x = x1 ) to calculate y 2 , and
that would be the predicted value at x2 , given by
y 2 = y1 + f (x1 , y1 )h
x 2 = x1 + h
Based on the above equations, if we now know the value of y = y i at xi , then
(3)
yi +1 = yi + f ( xi , yi )h
This formula is known as Eulers method and is illustrated graphically in Figure 2. In some
books, it is also called the Euler-Cauchy method.
y
True Value
h
Step size
xi
xi+1
08.02.4
Chapter 08.02
Example 3
A ball at 1200K is allowed to cool down in air at an ambient temperature of 300K .
Assuming heat is lost only due to radiation, the differential equation for the temperature of
the ball is given by
d
= 2.2067 10 12 ( 4 81 10 8 ), (0 ) = 1200K
dt
where is in K and t in seconds. Find the temperature at t = 480 seconds using Eulers
method. Assume a step size of h = 240 seconds.
Solution
d
= 2.2067 10 12 4 81 10 8
dt
f (t , ) = 2.2067 10 12 4 81 10 8
Per Equation (3), Eulers method reduces to
i +1 = i + f (t i , i )h
For i = 0 , t 0 = 0 , 0 = 1200
1 = 0 + f (t 0 , 0 )h
= 1200 + f (0,1200 ) 240
))
))
Eulers Method
08.02.5
Temperature, (K)
1400
1200
1000
Exact Solution
800
600
400
h =240
200
0
0
100
200
300
400
500
Time, t (sec)
Temperature, (K)
1500
Exact solution
1000
500
h =120
0
0
-500
100
200
Time, t (sec)
h =240
300
400
500
h = 480
-1000
-1500
08.02.6
Chapter 08.02
The values of the calculated temperature at t = 480 s as a function of step size are plotted in
Figure 5.
Temperature, (K)
800
400
0
0
100
200
300
400
500
-400
1
1
2
3
f ' ( xi , y i )( xi +1 xi ) + f ' ' ( xi , y i )( xi +1 xi ) + ... (6)
2!
3!
As you can see the first two terms of the Taylor series
yi +1 = yi + f (xi , y i )h
are Eulers method.
The true error in the approximation is given by
f ( xi , yi ) 2 f ( xi , yi ) 3
(7)
Et =
h +
h + ...
3!
2!
The true error hence is approximately proportional to the square of the step size, that is, as
the step size is halved, the true error gets approximately quartered. However from Table 1,
we see that as the step size gets halved, the true error only gets approximately halved. This is
because the true error, being proportioned to the square of the step size, is the local truncation
= y i + f ( xi , y i )( xi +1 xi ) +
Eulers Method
08.02.7
error, that is, error from one point to the next. The global truncation error is however
proportional only to the step size as the error keeps propagating from one point to another.
Can one solve a definite integral using numerical methods such as Eulers method of
solving ordinary differential equations?
Let us suppose you want to find the integral of a function f (x)
b
I = f ( x )dx .
a
Both fundamental theorems of calculus would be used to set up the problem so as to solve it
as an ordinary differential equation.
The first fundamental theorem of calculus states that if f is a continuous function in the
interval [a,b], and F is the antiderivative of f , then
b
f (x )dx = F (b ) F (a )
a
The second fundamental theorem of calculus states that if f is a continuous function in the
open interval D , and a is a point in the interval D , and if
x
F ( x ) = f (t )dt
a
then
F ( x ) = f (x )
at each point in D .
Asked to find
f (x )dx ,
differential equation (here is where we are using the second fundamental theorem of
calculus)
dy
= f ( x ), y (a ) = 0,
dx
where then y (b ) (here is where we are using the first fundamental theorem of calculus) will
give the value of the integral
f (x )dx .
a
Example 4
Find an approximate value of
8
6 x dx
3
using Eulers method of solving an ordinary differential equation. Use a step size of h = 1.5 .
Solution
8
Given 6 x 3 dx , we can rewrite the integral as the solution of an ordinary differential equation
5
08.02.8
Chapter 08.02
dy
= 6 x 3 , y (5) = 0
dx
8
dy
= 6 x 3 = f ( x, y ) , y (5) = 0
dx
The Eulers method equation is
yi +1 = yi + f ( xi , yi )h
Step 1
i = 0, x0 = 5, y 0 = 0
h = 1.5
x1 = x0 + h
= 5 + 1.5
= 6.5
y1 = y 0 + f ( x0 , y 0 )h
= 0 + f (5,0 ) 1.5
= 0 + (6 5 3 ) 1.5
= 1125
y (6.5)
Step 2
i = 1, x1 = 6.5, y1 = 1125
x 2 = x1 + h
= 6.5 + 1.5
=8
y 2 = y1 + f ( x1 , y1 )h
= 1125 + f (6.5,1125) 1.5
Hence
8
6 x dx = y(8) y(5)
5
3596.625 0
= 3596.625
Eulers Method
08.02.9