Numerical Methods
Numerical Methods
By S Abinash
NUMERICAL METHOD
We use numerical method to find approximate solution of problems by numerical calculations with aid of
calculator. For better accuracy we have to minimize the error.
For example
Significant digit:
It is defined as the digits to the left of the first non-zero digit to fix the position of decimal point.
Intermediate value Theorem: If a function f(x) is continuous in closed interval [a,b] and satisfies f(a)f(b) < 0
then there exists atleast one real root of the equation f(x) = 0 in open interval (a,b).
Algebraic equations are equations containing algebraic terms ( different powers of x). For example x2-7x+6=0
Transcendental equations are equations containing non-algebraic terms like trigonometric, exponential,
logarithmic terms. For example sin x ex = 0
Step-I We rewrite the equation f(x) = 0 of the form x = h(x), x=g(x), x = D(x)
Step-II We choose that form say x = h(x) which satisfies I h I < 1 in interval (a,b) containing the
solution (called root).
Step-III We take xn+1 = h(xn) as the successive formula to find approximate solution (root) of the
equation f(x) = 0
Step-III Let x=x0 be initial guess or initial approximation to the equation f(x) = 0
Then x1=h(x1) , x2=h(x2) , x3=h(x3) and so on.We will continue this process till we get solution (root) of
the equation f(x) = 0 up to desired accuracy.
If x=a is a root of the equation f(x) = 0 and the root is in interval (a, b). The function h
defined by x = h(x) Is continuous in (a,b) .Then the approximations x1=h(x1) , x2=h(x2) , x3=h(x3) .......
converges to the root x=a provided I I < 1 in interval (a,b) containing the root for all values of x.
Problems
1. Solve x3 - sin x -1 =0 correct to two significant figures by fixed point iteration method correct up
to 2 decimal places.
As f(1)f(2)< 0 by Intermediate value Theorem the root of real root of the equation f(x) = 0 lies
between 1 and 2
We see that I h1 I < 1 in interval (1,2) containing the root for all values of x.
We use xn+1= (1 + Sin xn)1/3 as the successive formula to find approximate solution (root) of the
equation (1).
Procedure
Step-I We find the interval (a,b) containing the solution (called root) of the equation f(x) = 0 .
Step-II Let x=x0 be initial guess or initial approximation to the equation f(x) = 0
Step-III We use xn+1 =xn - [f(xn) / n)] as the successive formula to find approximate solution (root)
of the equation f(x) = 0
Step-III Then x1 , x2 , x3 ............ and so on are calculated and we will continue this process till we get
root of the equation f(x) = 0 up to desired accuracy.
2. Solve x - 2sin x - 3 = 0 correct to two significant figures by Newton Raphson method correct up
to 5 significant digits.
f(0) = -3, f(1)= -2 - 2 Sin 1 , f(2)= -1 - 2 Sin 2 ,f(3)= - 2 Sin 3, f(4)= 1- 2 Sin 4
As f(3)f(4)< 0 by Intermediate value Theorem the root of real root of the equation f(x) = 0 lies
between 3 and 4
Secant Method
Procedure
Step-I We find the interval (a,b) containing the solution (called root) of the equation f(x) = 0 .
Step-II Let x=x0 be initial guess or initial approximation to the equation f(x) = 0
Step-III We use xn+1 = xn - [ (xn - xn-1 )f(xn)] / [f(xn) - f(xn-1)] as the successive formula to find
approximate solution (root) of the equation f(x) = 0
Step-III Then x1 , x2 , x3 ............ and so on are calculated and we will continue this process till we get
root of the equation f(x) = 0 up to desired accuracy.
3 . Solve Cos x = x ex correct to two significant figures by Secant method correct up to 2 decimal
places.
As f(0)f(1)< 0 by Intermediate value Theorem the root of real root of the equation f(x) = 0 lies
between 0 and 1
Then
Let f(x) = x4 - x - 7
As f(1)f(2)< 0 by Intermediate value Theorem the root of real root of the equation f(x) = 0 lies
between 1 and 2
Interpolation is the method of finding value of the dependent variable y at any point x using the
following given data.
x x0 x1 x2 x3 .. .. .. xn
y y0 y1 y2 y3 .. .. .. yn
This means that for the function y = f(x) the known values at x = x0 , x1 , x2 , ........ , xn are respectively
For this purpose we fit a polynomial to these datas called interpolating polynomial. After getting the
polynomial p(x) which is an approximation to f(x), we can find the value of y at any point x.
i.e. x1 = x0 + h, x2 = x1 + h, ......................, xn = xn - 1 + h
i = yi + 1/2 - yi ½
Where p = (x - x0)/h
Problems
x 0 10 20 30 40
y 7 18 32 48 85
Solution
x1 - x0= 10 = x2 - x1 = x3 - x2 = x4 - x3
As x= 5 lies between 0 and 10 and at the start of the table and data is equispaced, we have to use
forward difference Interpolation.
2 3 4
x y y
0 7
11
10 18 03
14 02
20 32 05 10
19 12
30 51 17
36
40 87
Here x0 = 0, y0 = 7, h= x1 - x0 = 10-0 = 10
2
0 y0 =3 ,
4
3
y0 y0 =10
To find the approximate value of y at x=5 we put x=5 in the interpolating polynomial to get
y(5)=Pn (5) = 0.0000416 (5)4 - 0.0022 (5)3 +0.05(5)2 + 1.26 (5) +7 = 14.301
x 20 35 50 65 80
y 3 11 24 50 98
Solution
x1 - x0= 15 = x2 - x1 = x3 - x2 = x4 - x3
As x= 24 lies between 20 and 35 and at the start of the table and data is equispaced, we have to use
forward difference Interpolation.
Here x0 = 20, y0 = 3, h= x1 - x0 = 35 - 20 = 15
2
0 y0 = 5 ,
4
3
y0 y0 = 1
2 3 4
x y y
20 3
35 11 05
13 08
50 24 13 01
26 9
65 50 22
48
80 98
2 3
Pn (x) = y0 + p 0 + [ p(p y0 + [ p(p 1) (p y0
4
+ [ p(p 1) (p 2)(p- y0
2 2
i.e. y1 = y1 - y0 , y2 = y2 - y 1 and so on.
Where p = (x - xn)/h
x 0 10 20 30 40
y 7 18 32 48 85
Solution :
x1 - x0= 10 = x2 - x1 = x3 - x2 = x4 - x3
As x= 35 lies between 3 0 and 40 and at the end of the table and given data is equispaced ,we have
to use difference Interpolation.
2 3 4
x y y
0 7
11
10 18 03
14 02
20 32 05 10
19 12
30 51 17
36
40 87
2 3
Pn (x) = yn + p yn + [ p(p + 1)/2! ] yn + [ p(p + 1) (p + 2)/3! ] yn
4
+ [ p(p + 1) (p+ 2)(p +3)/4! ] yn
= 87 + (-0.5) (36) + (-0.5) (-0.5+1) (17) /2! + (-0.5) (-0.5+1) (-0.5+2) (12) /3!
= 65.734375
Inverse Interpolation
The process of finding the independent variable x for given values of f(x) is called Inverse
Interpolation .
8. Solve ln x = 1.3 by inverse Interpolation using x= G(y) with G(1)=2.718 ,G(1.5)= 4.481 , G(2)=
7.387 ,G(2.5)= 12.179 and find value of x
2 3
y x y
1 2.718
1.763
2.906 0.743
2 7.387 1.886
4.792
2.5 12.179
3 x0 = 0.743
= 3.680248
Linear interpolation is interpolation by the line through points (x1,y1) and (x0,y0)
Where l0 = (x- x1) /( x0- x1) and l1 = (x- x0) /( x1- x0)
Quadratic Lagrange Interpolation is the Interpolation through three given points (x2,y2) , (x1,y1) and
(x0,y0) given by the formula
P2(x)= l0 y0 + l1 y1 + l2 y2
Where
9. Using quadratic Lagrange Interpolation find the Lagrange interpolating polynomial P2(x)
and hence find value of y at x=2 Given y(0) = 15, y(1) = 48, y(5) = 85
Solution :
x1 - x0 = 1 x 2 - x1 = 4
General Lagrange Interpolation is the Interpolation through n given points (x0,y0), (x1,y1) ,
(x2,y2)....................... , (xn,yn) given by the formula
Pn(x)= l0 y0 + l1 y1 + l2 y2 + ................ + ln yn
x xn ............... x x2 x x1
Where l0
x0 xn ............... x0 x2 x0 x1
10. Using Lagrange Interpolation find the value of y at x=8
Solution :
x1 - x0 = 1 x 2 - x1 = 6
Problems
x 0 6 20 45
y 30 48 88 238
ivided difference table
0 30
(48-30)/6=3
6 48 (8-3)/11=0.45
11 88 (10-8)/20=0.1
(238-88)/15=10
26 238
NUMERICAL DIFFERENTIATION
When a function y = f(x) is unknown but its values are given at some points like (x0 , y0 ), (x1, y1 ),
Sometimes it is difficult to differentiate a composite or complicated function which can be done easily
in less time and less number of steps by numerical differentiation.
where p = (x - x0)/h
where p = (x - xn)/h
x0) = (1/h2 2
y0 - 3
y0 + (11/12) 4
y0 ............................. ]
x0 0 ] = (y1 - y0 )/ h
x0) = (1/h2 2
y 0 ] = ( y1 - y0 )/ h2
12. Using following data find the first and second derivative of y at x=0
x 0 10 20 30 40
y 7 18 32 48 85
Solution
2 3 4
x y y
0 7
11
10 18 03
14 02
20 32 05 10
19 12
30 51 17
36
40 87
Here x0 = 0, y0 = 7, h= x1 - x0 = 10-0 = 10
2
0 y0 =3 ,
4
3
y0 y0 =10
x0) = (1/h2 2
y0 - 3
y0 + (11/12) 4
y0 ............................. ]
Linear Interpolation
Quadratic Interpolation
The second derivative is constant i.e. same at all points because of quadratic
interpolation and the interpolating polynomial is of degree two. Hence we must have
(x0) = ( y0 -2 y1 + y2 ) /(2h)
(x1) = ( y0 -2 y1 + y2 ) /(2h)
(x2) = ( y0 -2 y1 + y2 ) /(2h)
Problems
13. Using following data find the value of first and second derivatives of y at x=30
x 10 30 50
y 42 64 88
Solution
y0 = 42, y1 = 64, y2 = 88
Linear Interpolation
Quadratic Interpolation
14. Using following data find the value of first and second derivatives of y at x=12
x 0 10 20 30 40
y 7 18 32 48 85
Solution
2 3 4
x y y
0 7
11
10 18 03
14 02
20 32 05 10
19 12
30 51 17
36
40 87
Here x0 = 0, y0 = 7, h= x1 - x0 = 10-0 = 10
2
0 y0 =3 ,
4
3
y0 y0 =10
1.7971392 at x =12
Differentiating (2) w.r. to x we get
2
- 0.0132 x +0.1
= 0.0134848 at x =12
NUMERICAL INTEGRATION
Where integrand f(x) is a given function and a, b are known which are end points of the interval [a, b]
Let us divide the interval [a, b] into n number of equal subintervals so that length of each subinterval
is h = (b a)/n
The end points of subintervals are a=x0, x1, x2, x3, ............... , xn = b
Let us approximate integrand f by a line segment in each subinterval. Then coordinate of end points
of subintervals are (x0, y 0), ( x1, y1 ) , (x2, y2), ............. ,( xn , yn ). Then from x=a to x=b the area under
curve of y = f(x) is approximately equal to sum of the areas of n trapezoids of each n subintervals.
Where integrand f(x) is a given function and a, b are known which are end points of the interval [a, b]
We are taking two strips at a time Instead of taking one strip as in trapezoidal rule. For this reason the
number of intervals in Simpsons rule of Numerical integration must be even.
The formula is
Where integrand f(x) is a given function and a, b are known which are end points of the interval [a, b]
We are taking three strips at a time Instead of taking one strip as in trapezoidal rule. For this reason
the number of intervals in Simpsons 3/8th rule of Numerical integration must be multiple of 3.
The formula is
15. Using Trapezoidal and Simpsons rule evaluate the following integral with number of subintervals n =6
Solution:
y0 y1 y2 y3 y4 Y5 y6
= (h/3) [ y 0 + y6 + 4(y1 + y3 + y5 ) + 2( y2 + y4 ) ]
= (3h/8) [ y 0 + y6 + 3(y1 + y2 + y4 + y5 ) + 2( y3 ) ]
16. Using Trapezoidal and Simpsons rule evaluate the following integral with number of subintervals n =8
Solution:
Here integrand y = f(x) = ( 4 + x2)-1
( 4 + x2)-1
y0 y1 y2 y3 y4 Y5 y6 Y7 y8
+2(1/4.04+1/4.16+ 1/4.36) ]
=10.900704743176
I=
Solution:
Y= 1
y0 y1 y2 y3 y4 Y5 y6
= (h/3) [ y 0 + y6 + 4(y1 + y3 + y5 ) + 2( y2 + y4 ) ]