NUMERICAL METHODS
Numerical methods are systems or algorithms for solving equations that cannot be solved by using
normal techniques or analytical methods.
Examples
1.1. APPROXIMATE INTEGRAL BY SIMPSON’S RULE:
An estimate of the area under the curve y f x can be found by adding the area of a number of
rectangles whose tops closely match the shape of a curve. Simpson’s rule gives a fairly close result. A
good approximation can be obtained by dividing the intervals from a to b in to a number of smaller
intervals and applying the Simpson’s rule to the sub intervals as follows.
b
h
f x dx 3 f x f x 4 x
a
0 n 1 x3 x5 ... 2 x2 x4 x6 ...
h
b n n
i.e. f x dx f x0 f xn 4 x2 n 1 x2 n ,
a
3 n 0 n 0
ba
where h , n number of ordinates
n 1
Example1
3
1
Find, by Simpson’s rule, an approximate value of
x
0
5
1
dx , using 7 ordinates
Solution:
30
n7h 0.5
7 1
x 0 0.5 1.0 1.5 2.0 2.5 3.0
f x 1.000 0.970 0.500 0.116 0.030 0.010 0.004
3
1 0.5
x dx 1.00 0.004 4 0.970 0.116 0.010 2 0.500 0.030 1.074915
0
5
1 3
1.2. APPROXIMATE SOLUTION TO DIFFERENTIAL EQUATIONS
The Taylor’s series can be used to establish an approximate analytical solution to a differential
equation based on the initial conditions provided. Recall that the Taylor’s series is given as
x xo f xo x xo f xo x xo f xo
2 3
f x f xo ...
1! 2! 3!
This can be conveniently written in terms of differential coefficients with respect to x as
x xo dy x xo x xo d 3 y ... Where
2 3
d2y
f x yo 2
3
1! dx o 2! dx o 3! dx o
dy d y d y d n y are the respective values of y, y f x at x xo
2 3
yo , , 2
, 3
,.... n
dx o dx o dx o dx o
Example 2
dy
Solve the differential equation x 2 y as a power series in ascending powers of x as far as the
dx
term in x . Given that when x 0, y 1 .
3
Solution:
x xo dy x xo x xo d 3 y ...
2 3
d2y
f x yo 2
3
1! dx o 2! dx o 3! dx o
dy
xo 0, yo 1 x o yo 1 0 1
2 2
But
dx o
d2y d3y x2 x3
2
2 xo 1 2 0 1 1, 3
2 y 1 x
dx o dx o 2 3
Example 3
Use the Taylor series expansion to obtain a solution in a series of ascending powers of x u the
d2y dy dy
2 x 3 y 2 0 for which y 1, and 0 when x 0
4
term in x of the differential equation 2
dx dx dx
Solution
x xo dy x xo x xo d 3 y ...
2 3
d2y
f x yo 2
3
1! dx o 2! dx o 3! dx o
dy d2y
yo 1, 0 , xo 0 2 3
dx o dx o
d3y d2y dy d3y
2 x 6 y 0 3 0;
dx3 dx 2 dx dx o
d4y
2
d4y d3y d2y d2y dy
2 x 2 6 y 6 0 4 21
dx 4 dx3 dx 2 dx 2 dx dx o
x dy x2 d 2 y x3 d 3 y 3 2 5 4
f x yo 2
3
... y 1 x x ...
1! dx o 2! dx o 3! dx o 2 4
Example 4
dy
Given that 3 x y and that y = 1 when x = 1, find the first three non – zero terms of the
dx
Taylor’s series expansion of y about x = 1
Solution
x xo dy x xo x xo d 3 y ...
2 3
d2y
f x yo 2 3
1! dx o 2! dx o 3! dx o
dy d2 y dy
xo 1, yo 1 3(1) 1 2; 2
3 3 2 1
dx o dx o dx o
x 1
2
x2 2 x 1 1 x2
y 1 x 1 2 1 1 2 x 2 x
2! 2 2 2
1.3. LINEAR APPROXIMATION FOR FIRST ORDER LINEAR DIFFERENTIAL EQUATIONS
Let the points P xn , yn and P xn1 , yn1 lie on the curve y f x , where xn1 xn h as shown
below.
Q
P
As h 0, Q P; PQ straightline with gradient
dy yn 1 yn y yn dy dy
n 1 yn 1 yn h yn 1 yn h
dx n xn 1 xn h dx n dx n
This formula can also be obtained from the Taylor series expansion of y about x xo
x xn dy x xn x xn d 3 y ...
2 3
d2y
i.e y y 2
3
n
1! dx n 2! dx n 3! dx n
h dy h2 d 2 y h3 d 3 y
If y yn 1 , when x xn h , then yn 1 y n ...
1! dx n 2! dx 2 n 3! dx 3 n
2
If h is fairly small, then h and higher powers of h can be neglected therefore
dy
yn 1 y n h
dx n
To improve the accuracy of the approximation for a better approximation, consider three points
P xn1 , yn1 , Q xn , yn and R xn1 , yn1 on the curve y f x , where
xn 1 xn xn xn 1 h as shown below
R
dy yn 1 yn 1 yn 1 yn 1 y yn 1
At Q, gradient of PR n 1
dx n xn 1 xn 1 xn 1 xn xn xn 1 2h
yn 1 yn 1 dy dy
yn 1 yn 1 2h
2h dx n dx n
1.4. APPLICATIONS OF THE APPROXIMATIONS FORMULAE
(i) STEP – BY STEP SOLUTION OF DIFFERENTIAL EQUATIONS
This method with the use of the above formulae will provide numerical values of y at regular
intervals along the x – axis and not the analytical solution to the differential equation.
If the given differential equation has the initial values y y0 when x x0 then a step–by–step
solution will give a sequence of values for y1 , y2 , y3 ,...., yn corresponding to x1 , x2 , x3 ,...., xn , where
x1 xo h, x2 xo 2h, x3 xo 3h,.... as shown below
y
y1 y2 y3 y4 ……. ------ yn
o x1 x2 x3 x4 xn x
Example 5
dy
Using the approximation yn 1 yn h with h 0.1 , find an approximation to the value of y
dx n
dy
when x 0.3 , given that 2 xy 2 and y 1 when x 0 .
dx
Solution
dy dy
2 xy 2 2 xn yn 2
dx dx n
step1: n 0, x xo 0, y yo 1, h 1, y1 yo h 2 x0 y0 2 1 0.1 2 0 1 2
1
step 2 : n 1, x1 0.1, y1 1 y2 y1 h 2 x1 y12 1 0.1 2 0.1 1 0.99
2
step3 : n 2, x2 0.2, y2 0.99
y3 y2 h 2 x2 y2 2 0.99 0.1 2 0.2 0.99 0.9704
2
x3 x2 h 0.3, y3 y2 h 2 x2 y2 2 0.99 0.1 2 0.2 0.99 0.9704
2
Example 6
dy
Using the approximation yn 1 yn h with a step length of 0.1, find an approximation to the
dx n
dy
value of y when x 0.2 , given that xy and y 1 when x 0
dx
Solution
dy dy
xn yn yn 1 yn h yn 1 yn hxn yn
dx n dx n
n 0, x0 0, y0 1, h 0.1 y1 y0 hx0 y0 1 0.1 0 1 1
n 1, x1 0.1, y1 1, h 0.1 y2 y1 hx1 y1 1 0.1 0.11 1.01
n 2, x2 0.2, y2 1.01, h 0.1 y3 y2 hx2 y2 1.01 0.1 0.2 1.01 1.0302
Example 7
4
Find, as a series of ascending powers of x up to and including the term in x an approximate solution
dy
to the differential equation xy , given that y 1 when x 0 . Use the approximation
dx
dy
yn 1 yn 1 2h with a step length of 0.1, to find an approximation to the value of y when
dx n
x 0.3 , given that y 1 when x 0
Solution
dy dy
xn yn 0, y0 1 x0 y0 0 1 0
dx n dx 0
d2 y dy d2y dy
2
xn y n , 2
x0 y0 0 0 1 1
dx n dx n dx 0 dx 0
d3 y d2 y dy d3 y d2y dy
3
xn 2
2 3
x0 2
2 0 1 2 0 0
dx n dx n dx n dx 0 dx 0 dx 0
d4 y d2 y d3 y d4y d2 y d3y
4 3
2 3 4 3 2 3 31 0 3
dx n dx n dx n dx 0 dx 0 dx 0
x x0 dy x x0 x x0 d 3 y ...
2 3
d2y
y yn 2
3
1! dx n 2! dx n 3! dx n
1 2 1 4
y 1 x x ....
2 8
Using the approximation and differential equation
yn 1 yn 1 2hxn yn ; n 0, y1 y1 2 0.11 0 0 y1 y1
The value of y1 is not given but can be calculated using Taylor series.
1 2 1 4
i.e y 1 x x .... one step is for each x – value. Then one step back ward
2 8
x x0 h 0 0.1 0.1 y1 is one step backward or in the direction of the negative x – axis.
1 1
0.1 0.1 1.00505
2 4
Hence when x 0.1, y1 1
2 8
y1 y1 2 0.1 0 1 1.00505 y1 y1 1.00505
n 1, x1 xo h 0.1, yo 1, y1 1.00505 y2 y1 2 0.1 0.11.00505 1.0201
n 2, x2 x1 h 0.2, y2 1.0201, y1 1.00505 y3 1.00505 2 0.1 0.2 1.0201 1.045854
1.5. APPROXIMATION TO SECOND ORDER DIFFERENTIAL EQUATIONS
To estimate the solutions of second order formula, involve a second order differential equation.
Taylor series expansion of f x in ascending powers of x x0 , where x x0 h . We have
x xn dy x xn x xn d 3 y ...
2 3
d2y
yn 1 y n 2 3
1! dx n 2! dx n 3! dx n
Putting x xn h gives
dy h2 d 2 y h3 d 3 y h4 d 4 y
yn 1 y n h 4 ........................(1)
dx n 2! dx n 3! dx n 4! dx n
2 3
Putting x xn h , we have
Example 8
d2y dy dy
Given that 4 1 x 2
2 y 0 and that y 0 and 1 when x 0 , find, as a series of
dx dx dx
4
ascending powers of x, up to and including the term in x , the solution of this differential equation.
Hence, using the approximations
d2y dy
h 2 2 yn 1 2 yn yn 1 and 2h yn 1 yn 1 where h 0.2 to find, correct to 3 decimal
dx n dx n
places an approximate value of y when x 0.6 .
Solution
d2y dy
4 1 x 2
2 20
dx dx
dy d2y 1
y0 0, 1, x0 0 2
dx 0 dx 0 2
d3y 6 d2y 1 dy d3y 1
3
dx 3
4(1 x) dx 2
4(1 x) dx dx 0 2
d4y 10 d 3 y 1 d2y d4y 9 y x
1 2 1 3 3 4
x x x .....
4
dx 4 4(1 x) dx 3 4(1 x) dx 2 dx 0 8 4 12 64
yn 1 h 4 xn 8 yn 1 xn yn h 2 3.8 y1
yn1 ; n 0, x0 0, y0 0, h 0.2 y1
4 4 xn h 4.2
0.2 0.2 3 0.2
2 3 4
3.8
y1 0.2 0.1907 y1 0.1907 0.1726
4 12 64 4.2
n 1, x1 0.2, y1 0.1726
y0 h 4 4 x1 8 y1 1 x1 y1 h 2 8 0.1726 1 0.2 0.1726 0.2
2
1.6499
y2 0.33
4 4 x1 h 4 4 0.2 0.2 5
n 2, x2 0.4, y2 0.33, h 0.2
y1 h 4 4 x2 8 y2 1 x2 y2 h2 0.1726 0.2 4 4 0.4 8 0.331 0.4 0.33 0.4
2
y3
4 4 x2 h 4 4 0.4 0.2
4.5752
0.7888 n 3, x3 0.6 y y3 0.7888
5.8