Professional Documents
Culture Documents
Page 1 of 5
MSA / L-9 CSE-3512 - Numerical Methods 28th January, 2005
these values in the general solution, a unique solution known as exact solution can be
obtained.
Initial Conditions
In order to obtain the values of the integration constants, we need additional information.
If the order of the equation is n, we will have to obtain n constants and, therefore, we
need n conditions in order to obtain an exact solution. These conditions are called initial
conditions. For example, if the initial condition is y (0) = 2 then c = 2 and hence y = 3x2 +
x + 2 is the exact solution of y’ = 6x + 1.
Initial Value & Boundary Value Problem
When all the conditions are specified at a particular value of the independent variable x,
then the problem is called an initial value problem. If the initial conditions are specified
at different values of the independent variable, then such problem is called boundary
value problem.
Page 2 of 5
MSA / L-9 CSE-3512 - Numerical Methods 28th January, 2005
dy
= y’’’ = y’’ y0’’’ = 2
dx
dy
= y iv = y’’’ yiv = 2
dx
Substitute the above values in the Taylor’s series method,
h ’ h2 h3 h 4 iv
y1 = y0 + y0 + y0’’ + y0’’’ + y0 + …..
1! 2! 3! 4!
= 0 + 0.1/1 * 1 + (0.1)2 /2 * 2 + (0.1)3 /6 * 2 + (0.1)4 /24 * 2 + …..
= 0.11033846
y1 = y (1.1) ≈ 0.110
Now, x1 = x0 + h = 1 + 0.1 = 1.1 and y1 = 0.11
We have,
y1’ = x1 + y1 = 1.1 + 0.11 = 1.21
y1’’ = 1 + y1’ = 1 + 1.21 = 2.21
y1’’’ = y1’’ = 2.21
y1 iv = y1’’’ = 2.21
Substitute the above values in the Taylor’s series method,
h h2 h3 h 4 iv
y2 = y0 + y1’ + y1’’ + y1’’’ + y1 + …..
1! 2! 3! 4!
= 0.11 + 0.1/1 * 1.21 + (0.1)2 /2 * 2.21 + (0.1)3 /6 * 2.21 + (0.1)4 /24 * 2.21
= 0.232 (approximately)
y2 = y (1.2) ≈ 0.232
Euler’s Method
Consider the Taylor’s series method
( x x 0) ( x x 0) ( x x 0) n
y (x ) = y (x0 ) + y‘(x0) + y‘’(x0) + . . . . . + y (x0)
1! 2! n!
Taking the first two terms,
y (x ) = y (x0 ) + ( x - x0 ) y‘(x0)
Given the Differential Equation
y’ (x0 ) = f ( x , y ) with y(x0) = y0
We have,
y’ (x0 ) = f (x0 , y0 )
y (x ) = y (x0 ) + ( x - x0 ) f (x0, y0 )
Then, the value of y(x) at x = x1 is given by
y (x1) = y (x0 ) + (x1 - x0 ) f (x0, y0 )
Letting h = x1 - x0, we obtain
y1 = y0 + h f (x0, y0 )
Similarly,
y1 = y0 + h f (x0, y0 )
In general form,
yi + 1 = yi + h f (xi, yi )
The above formula is known as Euler’s method and can be used recursively to evaluate
y1, y2, …. of y(x1), y(x2), … starting from the initial condition y0 = y(x0).
Page 3 of 5
MSA / L-9 CSE-3512 - Numerical Methods 28th January, 2005
Euler’s method is the simplest method and has a limited application because of its
low accuracy.
In this method the new value is obtained by extrapolating linearly over the step size h
using the slope at its previous value i.e. New value = Old value + Slope * Step size.
[See Fig 13.1, Page-420, E Balagusamy]
dy
Example: Solve the equation = 1 – y, with the initial condition x = 0, y = 0, using
dx
Euler’s method and tabulate the solutions at x = 0.1, 0.2, 0.3
Solution: Here, f ( x, y ) = 1 – y
We have,
h = 0.1
x0 = 0 , y0 = 0
x1 = x0 + h = 0 + 0.1 = 0.1
x2 = 0.2
x3 = 0.3
Taking n = 0 in
yn+1 = yn + h f (xn , yn )
We get,
y1 = y0 + h f (x0, y0 )
= 0 + (0.1) (1 – 0 )
= 0.1
Now, y2 = y1 + h f (x1, y1 )
= 0.1 + (0.1) (1 – 0.1)
= 0.19
y3 = y2 + h f (x2, y2 )
= 0.19 + (0.1) (1 – 0.19)
= 0.271
Heun’s method
In Euler’s method, the slope at the beginning of the interval is used to extrapolate yi to
yi+1 over the entire interval. Thus, yi+1 = yi + m1h where m1 is the slope at (xi, yi). As
shown in Fig 13.2 [Page-425, Balagurusamy], yi+1 is clearly an underestimate of y (xi+1).
An alternative is to use the line which is parallel to the tangent at this point (xi+1, y (xi+1))
to extrapolate from yi to yi+1, as shown in Fig 13.2. i.e. yi+1 = yi + m2h where m2 is the
slope at (xi+1, y (xi+1)). Note that the estimate appears to be overestimated.
A third approach is to use a line whose slope is the average of the slopes at the end points
of the interval. Then yi+1 = yi + ((m1+ m2)/2)h. As shown in Fig 13.2, this gives a better
approximation to yi+1. This approach is known as Heun’s method.
The formula for implementing Heun’s method can be constructed easily. Given the
equation, y’ (x) = f (x, y), we can obtain
m1 = y’ (xi) = f (xi, yi)
m2 = y’ (xi+1) = f (xi+1, yi+1)
and therefore, m = (f (xi, yi) + f (xi+1, yi+1)) / 2
So, yi+1 = yi + h/2 [f (xi, yi) + f (xi+1, yi+1)] ……. (1)
Page 4 of 5
MSA / L-9 CSE-3512 - Numerical Methods 28th January, 2005
But the term yi+1 appears on both sides of Eq. (1) and therefore, yi+1 cannot be evaluated
until the value of yi+1 inside the function f (xi+1, yi+1) is available. This value can be
predicted using the Euler’s formula as yi + 1 = yi + h f (xi, yi ).
Then Heun’s formula becomes
yi+1 = yi + h/2 [f (xi, yi) + f (xi+1, yi + h f (xi, yi ))]
Example 13.6: See page-427 [E Balagurusamy].
1
m= ( m1 + 2 m2 + 2 m3 + m4 )
6
1
yi+1 = yi + ( m1 + 2 m2 + 2 m3 + m4 ) h
6
Example 13.8: See page-439 [E. Balagurusamy].
Page 5 of 5