UNIT-III - Numerical Methods
UNIT-III - Numerical Methods
UNIT - III
NUMERICAL METHODS
The study of numerical analysis is aimed at providing convenient methods for obtaining useful
solutions to problems of advanced learning in science and technology. Besides this, analytical
solutions to a large number of problems are not available. Numerical analysis provides methods
for obtaining approximate solutions to such problems also. Numerical methods, in general, are of
repeated nature. In each step, better approximation to the exact solution of the problem is
obtained and the process is continued till accuracy to the desired degree is arrived at. In this unit
some numerical methods to solve algebraic, transcendental and ordinary differential equations
are discussed.
n n−1 n−2
An expression of the form f ( x )=a 0 x +a1 x +a2 x +.. .+a n−1 x+an , where ai (i = 0, 1, 2,
3…) are constants (a 0≠0) and n is a positive integer, is called a polynomial in x of degree n.
The polynomial f (x) =0 is called an algebraic equation of degree n.
Examples:
2
(1) 3 x −6 x +9=0
If f ( x ) contains some other functions such as trigonometric, logarithmic, exponential etc., then
f ( x )=0 is called a transcendental equation.
Examples:
x
(1) 2 e −4=0
x
(2) cos x−xe =0
Root of an equation: The value ‘a’ of x which satisfies f ( x )=0 is called a root of f ( x )=0 .
Geometrically, a root of f ( x )=0 is that value of x where the graph of y=f ( x ) crosses the
x-axis.
1
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
'
Simple root: A number ξ is a simple root of f ( x )=0 if f ( ξ )=0 , f ( ξ )≠0 .
Example:
Solution:
Since one root is , the other root must be
Therefore, the factors corresponding to these roots are and
or = =
3 2
is a divisor of 3 x −4 x + x +88=0
3x+8 = 0
x = - 8/3
Initial approximation:
2
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
The common method used to obtain the initial approximation to the root is based upon the
intermediate value theorem which states that “If f(x) is a continuous function in the closed
interval [a, b] and if f(a) and f(b) are of opposite signs [i.e., f(a).f(b)<0] then the equation f(x) = 0
has atleast one simple root (or odd number of roots) lying between a and b”. By using this
property, we take a (or) b as the initial approximation of the root to start the Iterative process.
Regula-Falsi method (Method of false position):
This is method of finding the real root of an equation f ( x )=0 . Here we choose two points
such that and are of opposite signs i.e., the graph of y=f(x) crosses the x- axis
between these points a root lies between 0
x and x
1 and consequently f ( x 0 ) f ( x1 )<0 .
Consider the equation f(x) = 0, where f(x) may be Algebraic (or) Transcendental which is known
to have a root between [x0 , x1 ] then f ( x 0 ) f ( x1 )<0 .
Approximate the function f(x) by the straight line joining the points [x 0 , f(x0 )] and [x1 , f(x1 )].
Let this straight line cut the x-axis at x2 .
The equation of the chord joining the two points [x0 , f(x0 )] and [x1 , f(x1 )] is given by,
y−f ( x 0 ) x−x 0 f ( x 1 )−f ( x 0 )
= ⇒ y−f 0= ( x −x 0 ) ---------( 1)
f ( x 1 )−f ( x 0 ) x 1−x 0 x 1 −x0
The method consists in replacing the curve AB by means of the chord AB and taking the point of
intersection of the chord with x - axis as an initial approximation to the root. The point of
intersection is obtained by putting y = 0
f ( x 1 )−f ( x 0 )
0−f (x 0 )= (x 2 −x 0 )
∴ Equation (1) becomes, x 1− x0
f ( x 0 )( x 1−x 0 )
⇒ x 2 −x 0 =−
f ( x 1 )−f ( x 0 )
3
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
( x 1 −x 0 )
⇒ x 2 =x 0 − f ( x0 )
f ( x 1 )−f ( x 0 )
x 0 f ( x 1 )−x1 f ( x 0 )
x 2= ----(2 )
f ( x1 )−f ( x 0 )
Examples:
1. Find a real root of the equation by the method of false position correct to three
decimal places.
Solution: Let f(x) =
f (1) = -6 (-ve), f (2) = -1 (-ve), f(3) = 16 (+ve)
A root lies between 2 and 3
therefore x 0 =2 x1 =3 f ( x 0 )=−1 f ( x 1 )=16
By the method of false position,
4
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
1
x 2 =2+ =2. 0588
We get, 17
Since f (2. 0588 )=−0 . 3908(−ve) , therefore the root lies between 2.0588 and 3.
0 . 9412
x 3 =2. 0588− (−0. 3908 )=2. 0813
16 .3908
Repeating this process, the successive approximations are
2. Find the root of the equation using Regula - Falsi method correct to four decimal
places.
Solution:
x
Let f ( x )=cos x −xe =0
f (0) = 1 (+ve), f (1) = -2.17798 (-ve)
Root lies between 0 and 1.
therefore, x 0 =0 , x 1=1 , f (x 0 )=1 , f ( x 1 )=−2. 17798
By the method of false position,
0 .68533
x 3 =0 .31467− (0 . 51987)=0 . 44673
2. 69785
5
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
3. Find a real root of the equation by Regular - Falsi method correct to four decimal
places.
Solution: Let
f (1)=−ve , f (2)=−ve and f (3 )=+ ve
Therefore, a root lies between 2 and 3
Now, x 0 =2 , x 1 =3 , f ( x 0 )=−0 .59794 , f ( x 1 )=0 . 23136
By Regular-Falsi method
= 2.72102
0 . 27898
x 3 =2. 72102+ (0 . 01709)=2. 74021
0. 23136+0. 01709
Let f(x) = 0 ---------- (1), be the given equation, where f(x) may be Algebraic (or) Transcendental
and x0 be the initial approximation to the root.
Let x1 = x0 + h ---------- (2) be the exact root of the equation f(x) = 0, where h is very small
quantity.
6
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
Similarly starting with x1 and repeating the above procedure we get the second approximation to
the root given by,
f ( x1 )
x 2 =x1 −
f ' ( x1 )
th
Proceeding like this, we get the n approximation to the root given by,
f ( xn )
x n+1=x n − ---------( 6 )
f ' ( xn )
The formula given in (6) is known as Newton-Raphson Iterative formula to find the root of the
equation f(x) = 0.
7
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
Geometrical Interpretation:
8
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
replacing the part of the curve between the point and the x- axis by means of tangent to the
curve at .
Examples:
1. Apply Newton-Raphson’s method to obtain the smallest positive root of the equation
cos(x) - x ex = 0.
Solution: Given cos(x) - x ex = 0.
' x x
⇒ f(x) = cos(x) - x ex and f ( x )=−sinx−xe −e
Since f (0) = 1>0 and f (1) =-2.1780 <0, the root lies in the interval (0,1)
Let x0 = 1 be the initial approximation to the root.
k xk Δx k =
f ( xk ) x k +1=x k−Δx k f ( x k+1 )
f ' ( xk )
0 1.0 0.3469 0.65307940 -0.4606
1 0.65307940 0.1217 0.53134337 -0.4180
3 0.53134337 0.1343 0.51790991 -0.4641
4 0.51790991 0.1525 0.51775738 -0.5926
5 0.51775738 0.1948 0.51775736 -0.2910
9
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
3. Using Newton’s iterative method, find the real root of correct to five decimal
places.
Solution:
Take
10
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
k x k +1=x k−Δx k
1 2.81
2 2.741
3 2.74064
4 2.74065
5 2.74065
Since
Hence the required root is 2.74065.
Therefore
11
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
Let y= y (x ) be the exact solution of equation (1) expanding y(x) in Taylor series about the
point x0 , we get,
( x−x 0 ) ( x−x 0 )2 ( x−x 0 )3
y ( x )= y ( x0 )+ y '( x 0 )+ y ''( x 0 )+ y '''( x 0 )+…
1! 2! 3!
' ''
Since y ( x 0 )= y 0 , y ( x 0 )= y , y ( x 0 )= y etc., the above equation becomes
' 0 '' 0
12
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
( x−x 0 ) ( x−x 0 )2 (x −x 0 )3
y ( x )= y 0 + y '0 + y ''0 + y '''0 +…
1! 2! 3!
Setting h = x1 - x0 and denoting y(x) = y(x1 ) = y1 , the above equation becomes,
h h2 h3
y 1= y 0+ y' 0 + y ''0 + y'''0 +....
1! 2! 3! --------------(2)
This is the Taylor series solution at the point x 1 = x0 + h. Starting with this x1 and repeating the
above procedure we get the solution at the point x2 as,
th
Proceeding like this we get the Taylor series solution at the n step given by,
h h2 h3
y n+1 = y n + y ' n + y ''n + y'''n +.. ..
1! 2! 3! ---------------(3)
The formula given in (3) is known as Taylor’s series method.
Note: It is a single step method.
Example:
dy
=x 2 + y 2
1. Use Taylor’s series method to find y at the points x = 0.1 and x = 0.2, given that
1 2 dx ,
y (0) = 1.
Solution: Here x0 = 0, the Taylor’s series solution of the given problem is
x 2 '' x3 x4
y= y ( 0 )+xy ' ( 0 )+ y ( 0 )+ y ''' ( 0 )+ y iv ( 0 )+.. .. .
2! 3! 4! with y (0) = 1. (i)
y ' =x 2 + y 2 , y ''=2 x+ 2 yy ' , y''' =2+2 { yy '' + ( y ' ) } , y iv =2 { yy ''' +3 y ' y '' }
2
Also, and so on.
y=1+ x + ( x2
2!
×2 + )(
x3
3!
×8 +
x4
4! )(
×28 + .. .. . .. )
13
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
4 7
=1+ x + x 2 + x 3 + x 4 +. . .. .. (ii )
3 6
x 0 =0
.
x=x 1 =0 .1 x 1=0. 1
For , expression (ii) yields the solution at as,
4 7
y ( 0 .1 ) =1+ ( 0 .1 ) + ( 0 . 1 )2 + ( 0 . 1 )3 + ( 0 . 1 )4 +.. . .. ..≈1 .11145
3 6
x=x 2 =0 .2 x 2 =0 .2
For , expression (ii) yields the solution at as,
4 7
y ( 0 .2 ) =1+ ( 0 .2 ) + ( 0 . 2 )2 + ( 0 . 2 )3 + ( 0 .2 ) 4 +. .. . .. .≈1 . 25253 .
3 6
The general formula for finding the solution of the initial value problem
dy
=f ( x,y ),y (x 0 )= y 0
dx is given by:
1
6[ 1
y n+1 = y n + K +2K2 +2K3 + K 4 ]
Where K 1 =h f ( x n ,y n ) (
K 2 =h f x n +
h
2
K
,y n + 1
2 )
,
(
K 3 =h f x n +
h K
,y + 2
2 n 2 ) and K 4 =h f ( x n + h,y n + K 3 )
14
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
Example:
' 2
1. Using fourth – order Runge – Kutta method, solve the problem y =x + y , y (0) = 1 at the
points x = 0.1 and x = 0.2 in steps of 0.1.
f ( x , y )=x + y 2 , x 0=0 , y 0 =1 x =x +h=0 .1
Solution: Here, , h=0.1, so that 1 0 and
x 2 =x1 + h=0. 2
y 1 = y ( x 1 )= y ( 0 . 1 ) and y 2 = y ( x 2 ) = y ( 0 .2 )
Step 1: We have to find . Hence,
k 1=hf ( x 0 , y 0 ) =( 0 .1 )×f ( 0 , 1 )=( 0 . 1 )×( 0+ 1 )=0. 1 ,
2
( h k
)
k 2=hf x 0 + , y 0 + 1 =( 0 .1 )×f ( 0 . 05 ,1 . 05 )
2 2
= ( 0. 1 )× {0 .05+ ( 1. 05 )2 }=0 . 11525
( h k
)
k 3=hf x 0 + , y 0 + 2 =( 0 . 1 )×f ( 0 . 05 , 1. 057625 )
2 2
= ( 0. 1 )× {0 .05+ ( 1. 057625 )2 }=0. 116857
k 4 =hf ( x 0 + h , y 0 +k 3 ) =( 0 .1 ) ×f ( 0 . 1, 1 .116857 )
h
( k
)
k 2=hf x 1 + , y 1 + 1 =( 0 . 1 )×f ( 0 .15 , 1. 1838 )=0. 15514
2 2
,
( h
k 3=hf x 1 + , y 1 +
2
k2
2 )
= ( 0. 1 )×f ( 0 .15 , 1 .1941 )=0. 15759 ,
15
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
1
= ( 0 .134657+2×0 . 15514+2×0. 15759+0 . 18233 )=0. 15708
6 .
x 2 =0 .2 y 2 = y 1 + k=1 .1165+0 .15708=1 .27358
Hence, the solution at is, .
Predictor-Corrector Method:
The methods discussed above to solve a first order differential equation, require information
about the solution at a single point say xn for computing the solution at xn+1 . Hence these
methods are called single-step methods.
In the Predictor-Corrector Methods, a predictor formula is used to predict the value y i+1 of y at x
i+1 and then a corrector formula is used to improve the value of y i+1 .The corrector formula is used
repeatedly until two consecutive values of yi+1 are almost equal.
16
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
The need for a corrector formula arises because the predictor alone is numerically unstable; it
gives spurious solutions growing exponentially. Milne's predictor uses four previous values of y,
these values can be obtained by using Taylor’s or Runge-Kutta method.
Example:
1. Using Milne's Predictor-Corrector method evaluate the integral of
y '−4 y=0 at 0. 4 , given that y(0)=1, y(0 .1)=1.492, y(0 . 2)=2 .226, y(0.3)=3 . 320
Solution:
dy
=4 y
Here, dx So f ( x , y )= y '=4 y
x =0 , x 1=0 . 1 , x 2 =0 . 2, x 3 =0 . 3 , x 4 =0 . 4
h=0.1, 0
For predictor value of y (0.4):
4h
y (n+1
p)
= y n−3 +
3
[ 2 y 1n−2− y 1n−1 +2 y 1n] with n=3
4h
y (4p )= y 0 +
3
[ 2 y 11 − y 12 +2 y 13 ]
Here, h=0.1,
y 0 =1 , y 11=4 y 1 =4 (1. 492)=5 . 968
y 12 =4 y 2=4(2 . 226)=8 . 904
y 13 =4 y 3 =4 (3. 32)=13 .28
p 4(0 . 1)
∴ y 4 = y ( x 4 )= y (0 . 4 )=1+ [ 2(5 . 968)−8. 904 +2(13 .28 )]=4 . 9456
3
So y 14 =4 y 4 =4 (4 . 9456 )=19 .7824
For corrector value of y (0.4):
h 1
y (n+1
c)
= y n−1 +
3
[ y n−1 +4 y 1n + y n+1
p
]
h
y (4c )= y 2 + [ y 12 + 4 y 13 + y 14 ]
with n = 3, 3
0.1
∴ y 4 = y (0. 4 )=2. 226+ (2 .226 +4 (13 .28 )+19 .7824=4 . 95288
3 (First approximation of y4)
(C ) h 1
y4 1 = y2 +
3
[ y2 + 4 y3 + y4 ]
1 ( c)
17
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
0.1
∴ y 4 = y (0. 4 )=2. 226+ (2 .226 +4 (13 .28 )+19 .. 81152)= 4 .731251
3 .
0.1
∴ y 4 = y (0. 4 )=2. 226+ (2 .226 +4 (13 .28 )+4 (4 . 731251))=4 .701700
3 .
0.1
∴ y 4 = y (0. 4 )=2. 226+ (2 .226 +4 (13 .28 )+4 (4 . 701700 ))=4 . 69776
3 .
0.1
∴ y 4 = y (0. 4 )=2. 226+ (2 .226 +4 (13 .28 )+4 (4 . 69776 ))=4 . 697234
3 .
∴ The approximate value of y (0.4) is 4.697.
2. Using the Milne’s predictor-corrector method, find an approximate solution of the initial value
problem at the point x = 2, given y (1) = 2, y (1.25) = 3.13, y (1.5) = 4.5 and y
(1.75) = 6.13. Apply the corrector twice.
= 8.0027,
Further computing f4(p) = f (x4, y4) = 8.0027, applying the corrector again y4(c) = 8.0021
18
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
Exercise:
x
1. Determine the smallest positive real root of xe −2=0 to four significant figures using
false position method.
(Ans: 0.8526)
2. Solve the equation x tan x=−1 by Regular - Falsi method between 2.5 and 3 correct to
three decimal places.
(Ans: 2.7982)
3. Find the real root of the following equations by Newton - Raphson’s method
i) x3 – x – 11 = 0 in the interval (2, 3) (Ans: x = 1.532)
ii) x3 – 3x + 11 = 0 in the interval (1, 2) (Ans: x = 1.532)
4. The volume ‘V’ of a liquid in a spherical tank of radius ‘a’ is related to the depth ‘l’ of the liquid
given by l3 - 3l2 + 0.4775 = 0, using Newton-Raphson method find a positive real root of the
equation which lies between 0 and 1.
(Ans: 0.431137997)
5. If y '=1+xy and y = 2 when x = 0, use Taylor's series method to obtain the value of y for
x = 0.4.
(Ans: 2.5884139)
x
6. Solve the differential equation y '=2 y+3e with y (0) = 0 using Taylor's series method
and find the value of y for x = 0.1, 0.2. Compare your answer with exact values.
dy
=log( x + y )
7. Solve the initial value problem dx when the initial condition that y = 1 when
x = 0 use Runge - Kutta method to find y (0.2) and y (0.5) in more accurate form.
19
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)
Department of Mathematics
dy
=1+ xy 2
10. Solve the initial value problem dx , y (0) = 1 for x = 0.4 by using Milne's
method when it is given that:
x: 0.1 0.2 0.3
y: 1.105 1.223 1.335
(Ans: y =1.538 at x = 0.4)
Video link:
https://www.youtube.com/watch?v=QwyjgmqbR9s
20
Second Semester Vector Calculus, Laplace Transforms and Numerical Methods (22MA21A)