Some Important Methods With Example
Some Important Methods With Example
UNIT-1
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 π = 3.14159 is approximated as 3.141 for chopping (deleting all decimal)
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΄(x) 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΄(x) and h(x)
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 h΄(x) 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΄(x) 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) / f΄(xn)] 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
x3 x 2
x2 x1 f ( x2 ) 0.31465 0.31465 1 f (0.31465) 0.44672
f ( x2 ) f ( x1 ) f (0.31465) f (1)
x3 x 2 f ( x 3 )
x 4 x3 0.64748
f ( x3 ) f ( x 2 )
x 4 x3 f ( x 4 )
x5 x 4 0.44545
f ( x 4 ) f ( x3 )
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
Where p = (x - x0)/h
Problems
5. Using following data find the Newton’s interpolating polynomial and also find the value of y at x=5
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
Newton’s forward difference Interpolation.
x y Δy Δ2 y Δ3 y Δ4 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
Δ y0 = 11 , Δ2 y0 =3 ,
Δ3 y0 = 2, Δ4 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
6. Using following data find the Newton’s interpolating polynomial and also find the value of y at x=24
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
Newton’s forward difference Interpolation.
Here x0 = 20, y0 = 3, h= x1 - x0 = 35 - 20 = 15
Δ y0 = 8 , Δ2 y0 = 5 ,
Δ3 y0 = 8, Δ4 y0 = 1
x y Δy Δ2 y Δ3 y Δ4 y
20 3
35 11 05
13 08
50 24 13 01
26 9
65 50 22
48
80 98
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 Newton’s Backward difference Interpolation.
yn= 36 , 2yn = 17 ,
x y Δy Δ2 y Δ3 y Δ4 y
0 7
11
10 18 03
14 02
20 32 05 10
19 12
30 51 17
36
40 87
= 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
y x Δy Δ2 y Δ3 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 l0
x x2 x x1 , x x2 x x0 x x1 x x0
l1 and l 2
x0 x2 x0 x1 x1 x2 x1 x0 x2 x1 x2 x0
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 - x 0 = 1 ≠ x2 - x1 = 4
x x2 x x1 x 5x 1 x 2 6 x 5
l0
x0 x2 x0 x1 0 50 1 5
l1
x x2 x x0
x 5x 0 x 2 5 x
x1 x2 x1 x0 1 51 0 4
x x1 x x0 x 1x 0 x 2 x
and l 2
x2 x1 x2 x0 5 15 0 20
y l0 y0 l1 y1 l 2 y 2
x 2
6x 5
15
x 2 5x
48
x2 x
85
5 4 20
4.75x 2 37.75x 15
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
x xn ................x x2 x x0
l1
x1 xn ................x1 x2 x1 x0
x xn ...................x x1 x x0
l2
x2 xn .................x2 x1 x2 x0
.........
...........
x xn1 ...................x x1 x x0
and l n
xn xn1 .................x2 x1 x2 x0
Solution :
x1 - x 0 = 1 ≠ x2 - x1 = 6
y l 0 y 0 l1 y1 l 2 y 2 l3 y3
1
18 1 42 2 57 7 90
9 6 3 18
2 7 38 35 82
f [ x 1 , x 2 ] - f [ x 0 , x1 ]
f [ x 0 , x1 , x 2 ]
x 2 x0
f [ x 2 , x3 ] - f [ x1 , x 2 ]
f [ x1 , x 2 , x 3 ]
x 3 x1
f [ x 1 , x 2 , x 3 ] - f [ x 0 , x1 , x 2 ]
f [ x 0 , x1 , x 2 , x 3 ]
x 3 x0
f [ x 1 , x 2 , x 3 ,......., x n ] - f [ x 0 , x1 , x 2 ,......., x n -1 ]
f [ x 0 , x1 , x 2 , x 3 ,......., x n ]
x n x0
Problems
11. Using following data find the Newton’s divided difference interpolating polynomial and also
find the value of y at x= 15
x 0 6 20 45
y 30 48 88 238
Newton’s divided 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
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
x y Δy Δ2 y Δ3 y Δ4 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
Δ y0 = 11 , Δ2 y0 =3 ,
Δ3 y0 = 2, Δ4 y0 =10
Linear Interpolation
y( x 1 ) - y ( x 0 ) y y0
y ( x 0 ) 1
x 1 x0 x 1 x0
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
y΄΄(x0) = ( 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
y( x 1 ) - y( x 0 ) y y0 64 42
y ( x 0 ) 1 1.1
x 1 x0 x 1 x0 30 10
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
x y Δy Δ2 y Δ3 y Δ4 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
Δ y0 = 11 , Δ2 y0 =3 ,
Δ3 y0 = 2, Δ4 y0 =10
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.
ba 2
The error in trapezoidal rule is h f ( ) where a < θ <b
12
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
I= f ( x) dx = (h/3) [ y
a
0 + y2m + 4(y1 + y3 + ............ + y 2m-1 ) + 2( y2 + y4 + .......... + y 2m-2) ]
ba 4 v
The error in Simpson 1/3rd rule is h f ( ) where a < θ <b
180
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
I= f ( x) dx = (3h/8) [ y
a
0 + y3m + 3(y1 + y2 + y4 + y5 + ....... + y 3m - 1 ) + 2( y3 + y6 + ....... + y 3m – 3 ) ]
ba 4 v
The error in Simpson 1/3rd rule is h f ( ) where a < θ <b
80
15. Using Trapezoidal and Simpsons rule evaluate the following integral with number of subintervals n =6
e
( x2 )
dx
0
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
0 .8
dx
4 x
0
2
Solution:
Here integrand y = f(x) = ( 4 + x2)-1
( 4 + x2)-1
y0 y1 y2 y3 y4 Y5 y6 Y7 y8
0.8
1 x
0.8
dx
0 4 x 2 2 tan
1
0.5 tan 1 0.4 tan 1 0 0.5 tan 1 0.4
2 0
=10.900704743176
0 .6
dx
I= 0 1 x
Solution:
1
Here integrand y = f(x) =
1 x
Y= 1 1 1 1 1 1 1
1 .1 1 .2 1 .3 1 .4 1 .5 1 .6
1
1 x =0.953462 =0.912871 =0.877058 =0.845154 =0.816496 =0.790569
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 ) ]
= (0.3/8) [ 1+ 0.790569+
UNIT-II
This is an iterative method used to find approximate solution of a system of linear equations.
Some times in iterative method convergence is faster where matrices have large diagonal
elements. In this case Gauss elimination method require more number of steps and more row
operations. Also sometimes a system has many zero coefficients which require more space to
store zeros for example 30 zeros after or before decimal point. In such cases Gauss-Seidal
iteration method is very useful to overcome these difficulties and find approximate solution of
a system of linear equations.
Procedure:
We shall find a solution x of the system of equations Ax=b with given initial guess x0.
Step-I Rewrite the given equations in such a way that in first equation coefficient of x1 is
maximum, in second equation coefficient of x2 is maximum, in third equation coefficient of
x3 is maximum and so on.
Step-III
If initial guess is given we take that value otherwise we assume X = (1, 1, 1) as initial guess.
Put values of x1 , x2 obtained in (1) and (2) in the third equation to get value of x3.
Step-IV
18. Solve following linear equations using Gauss-Seidal iteration method starting from 1, 1, 1
x1 + x2 + 2 x3 = 8
2x1 + 3 x2 + x3 = 12
5x1 + x2 + x3 = 15
Solution Rewrite the given equations so that each equation for the variable that has coefficient largest we get
5x1 + x2 + x3 = 15 ..........................................................(1)
2x1 + 3 x2 + x3 = 12 ..........................................................(2)
x1 + x2 + 2 x3 = 10 ..........................................................(3)
5x1 = 1 5 - x2 - x3
2x1 + 3 x2 + x3 = 12
x1 + x 2 + 2 x3 =10
Step-1
Step-2
Step-3
Step-4
This is an iterative method used to find approximate value of Eigen values and Eigen vectors
of an n x n non-singular matrix A.
Procedure:
x1 = Ax0
x2 = A x1
x3 = A x2
..........................
..........................
..........................
xn = A xn-1
For any n x n non-singular matrix A we can apply this method and we get a dominant
eigen value λ such that absolute value of this eigen value λ is greater than that of other
eigen values.
Theorem: Let A be an n x n real symmetric matrix. Let x ≠ 0 be any real vector with n
components. Let y=Ax, m0 = xT x, m 1=xTy, m2=yTy
m2
Assuming r = λ - ϵ we have I ϵ I r2
m0
6 3
19 . Find the eigen values and eigen vectors of the matrix by Power method
3 2
taking x0= [ 1 1 ]T
6 3 T
Solution Let A = . Given x0= [ 1 1 ]
3 2
x1 = Ax0
6 3 1 9 1
= = = 9
3 2 1 5 5 / 9
1
Dominated eigen value is 9 and and eigen vector is
5 / 9
x2 = A x1
6 3 1 7.666 1
= 3 2 5 / 9 = 4.111 = 7.666 0.536
1
Dominated eigen value is 7.666 and and eigen vector is
0.536
x3 = A x2
6 3 1 7.608 1
= 3 2 0.536 = 4.072 = 7.608 0.535
1
Dominated eigen value is 7.608 and and eigen vector is
0.535
6 3 1
20 . Find the eigen values and eigen vectors of the matrix 3 2 0 by Power method
1 4 5
taking x0= [ 1 1 1 ]T
6 3 1
Solution Let A = 3 2 0 . Given x0= [ 1 1 1]T
1 4 5
x1 = Ax0
1
Dominated eigen value is 10 and and eigen vector is 0 .5
1
x2 = A x1
6 3 1 1 8.5 1
4 8.50.4705
= 3 2 0 0 .5 =
1 4 5 1 8 0.9411
1
Dominated eigen value is 8.5 and and eigen vector is 0.4705
0.9411
x3 = A x2
6 3 1 1 8.3526 1
= 3 2 0 0.4705 =
3.941 8.35260.4718
1 4 5 0.9411 7.5875 0.9084
1
Dominated eigen value is 8.3526 and and eigen vector is 0.4718
0.9084
Unit III: Solution of IVP by Euler’s method, Heun’s method and Runge-Kutta fourth order
method. Basic concept of optimization, Linear programming, simplex method, degeneracy,
and Big-M method.
y f ( x, y )
y (xo) = y0
The sufficient conditions for the existence of unique solution on the interval [x0 , b] are the
well-known Lipschitz conditions. However in ‘Numerical Analysis’, one finds values of y at
successive steps, x = x1 , x2 , … , xn with spacing h. There are many numerical methods
available to find solution of IVP, such as : Picards method, Euler’s method, Taylor’ series
method, Runge-Kutta method etc.
using a numerical scheme applied to discrete node xn = x0 + nh, where h is the step-size by
Euler’s method, Heun’s method and Runge-Kutta method.
In Euler’s method we use the slope evaluated at the current level ( x n , y n ) and use
that value as an approximation of the slope throughout the interval ( x n , x n 1 ) .
Hune’ method samples the slope at beginning and at the end and uses the average
as the final approximation of the slope. It is also known as Runge-kutta method of
order-2.
Runge-kutta method of order-4 improve on Euler’ s method looking at the slope at
multiple points.
y j 1 y j hf ( x j , y j ) , j = 0, 1, 2, … n - 1.
1
y j 1 y j (k1 k 2 ) , j = 0, 1, 2, … n - 1.
2
Where k1 hf ( x j , y j ), k 2 hf ( x j h, y j k1 )
The necessary formula for solution of (1) by Runge – Kutta method of order-4 is:
1
y j 1 y j (k1 2k 2 2k 3 k 4 ) , j = 0, 1, 2, …, n – 1.
6
Where k1 hf ( x j , y j )
1 1
k 2 hf ( x j h , y j k1 )
2 2
1 1
k 3 hf ( x j h, y j k 2 )
2 2
k 4 hf ( x j h, y j k 3 )
Example : Use the Euler method to solve numerically the initial value problem
u 2tu 2 , u (0) 1
We have
2
u j 1 u j 2 ht j u j , j 0,1,2,3,4. [Here x and y are replaced by t and u
respectively]
For j = 0: t0 = 0, u0 = 1
For j = 1: t1 = 0.2, u1 = 1
u(0.8) = u4 = 0.63684.
Similarly, we get
u(1.0) = u5 = 0.50706.
Note: In the similar way IVP can be solved by Heun’s method and Runge-Kutta fourth order
method.
Optimization
Optimization is the means by which scarce resources can be utilized in an efficient manner
so as to maximize the profit or minimize the loss.