Unit1 - NM Solution To Equation
Unit1 - NM Solution To Equation
K OLHAPUR
S.Y. B. T ECH .
C OMPUTER S CIENCE AND E NGINEERING
Prepared by
Contents
1 Solution of Algebraic and Transcendental Equations 2
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Bisection (Bolzano) Method . . . . . . . . . . . . . . . . . . . 3
1.3 False Position Method (Regula-Falsi Method) . . . . . . . . . 6
1.4 Secant Method . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Newton Raphson Method . . . . . . . . . . . . . . . . . . . . 12
1.5.1 Geometrical Interpretation: . . . . . . . . . . . . . . . 13
CONTENTS 1
Mr. S.S. Salgare
P=Q
1st iteration:
0+1
x1 = ⇒ x1 = 0.5
2
Now f ( x1 ) = −0.3776 ; -ve
Next f (0.5) f (1) < 0 ⇒ root lies between 0.5 and 1
2nd iteration:
0.5 + 1
x2 = ⇒ x2 = 0.75
2
3rd iteration:
0.5 + 0.75
x3 = ⇒ x3 = 0.625
2
Now f ( x3 ) = −0.1860 ; -ve
Next f ( x2 ) f ( x3 ) < 0 ⇒ root lies between 0.625 and 0.75
4th iteration:
0.625 + 0.75
x4 = ⇒ x4 = 0.6875
2
Now f ( x4 ) = −0.0853 ; -ve
Next f ( x2 ) f ( x4 ) < 0 ⇒ root lies between 0.6875 and 0.75
5th iteration:
0.6875 + 0.75
x5 = ⇒ x5 = 0.7188
2
Now f ( x5 ) = −0.0338 ; -ve
Next f ( x2 ) f ( x5 ) < 0 ⇒ root lies between 0.7188 and 0.75
6th iteration:
0.7188 + 0.75
x6 = ⇒ x6 = 0.7344
2
Now f ( x6 ) = −0.0078 ; -ve
Next f ( x2 ) f ( x6 ) < 0 ⇒ root lies between 0.7344 and 0.75
7th iteration:
0.7344 + 0.75
x7 = ⇒ x7 = 0.7422
2
Now f ( x7 ) = 0.0052 ; +ve
Next f ( x7 ) f ( x6 ) < 0 ⇒ root lies between 0.7344 and 0.7422
8th iteration:
0.7344 + 0.7422
x8 = ⇒ x8 = 0.7382
2
Now f ( x8 ) = −0.0005 ; -ve
Next f ( x7 ) f ( x8 ) < 0 ⇒ root lies between 0.7344 and 0.7422
9th iteration:
0.7383 + 0.7422
x9 = ⇒ x9 = 0.7403
2
Now f ( x9 ) = 0.0020 ; +ve
Next f ( x9 ) f ( x8 ) < 0 ⇒ root lies between 0.7383 and 0.7403
10th iteration:
0.7383 + 0.7403
x10 = ⇒ x10 = 0.7393
2
Now f ( x10 ) = 0.0004 ; +ve
Next f ( x10 ) f ( x8 ) < 0 ⇒ root lies between 0.7383 and 0.7393
11th iteration:
0.7383 + 0.7393
x11 = ⇒ x11 = 0.7388
2
Now f ( x11 ) = −0.0005 ; -ve
Next f ( x10 ) f ( x11 ) < 0 ⇒ root lies between 0.7388 and 0.7393
12th iteration:
0.7388 + 0.7393
x12 = ⇒ x12 = 0.7391
2
Now f ( x12 ) = 0.0000
Here f ( x12 ) = 0 ; so x = 0.7391 is approximate root of x − cos x = 0
Example 2 Find the real root of the equation x log10 x = 1.2 by Bisection correct
to four decimal places. (Take initial approximation a=2.74 and b=2.75)
Excerise 1.1
y − f ( x0 ) f ( x1 ) − f ( x0 )
=
x − x0 x1 − x0
y − f ( x0 ) f ( x1 ) − f ( x0 )
or ( x − x0 )
= x1 − x0
The method consists in replacing the curve AB by chord AB and taking the
point of intersection of the chord with X-axis as an approximation to the
root.Put y=0, we get
x1 − x0 x0 f ( x1 ) − x1 f ( x0 )
x2 = x0 − f ( x0 ) = (1)
f ( x1 ) − f ( x0 ) f ( x1 ) − f ( x0 )
This procedure is repeated till the root is found to the desired accuracy.
Example 4 Find a real root of the equation 3x + sin x − e x = 0 by the method of
false position to four decimal place.
Ans:
Let f ( x ) = 3x + sin x − e x
Here f (0.3) = −0.154; −ve and f (0.4) = 0.0975; +ve
f (0.3) f (0.4) < 0 ⇒ Root lies between 0.3 and 0.4 ( x0 = 0.3, x1 = 0.4)
1st iteration:
x0 f ( x1 ) − x1 f ( x0 ) 0.3 × 0.0975 − 0.4 × (−0.154)
x2 = ⇒ x2 =
f ( x1 ) − f ( x0 ) 0.0975 + 0.154
x2 = 0.3612; f ( x2 ) = 0.0019 ( + ve)
2nd iteration:
0.3 f (0.3612) − 0.3612 f (0.3) 0.3 × 0.0019 − 0.3612 × (−0.154)
x3 = ⇒ x3 =
f (0.3612) − f (0.3) 0.0019 + 0.154
x3 = 0.3605; f ( x3 ) = 0.0002 ( + ve)
Now f (0.3605) f (0.3) < 0 ⇒ root lies between 0.3 and 0.3605
3rd iteration:
0.3605 f (0.3) − 0.3 f (0.3605) 0.3605 × (−0.154) − 0.3 × (0.0002)
x4 = ⇒ x4 =
f (0.3) − f (0.3605) −0.154 − 0.0002
x4 = 0.3604; f ( x4 ) = −0.0001 ( − ve)
Now f (0.3604) f (0.3605) < 0 ⇒ root lies between 0.3604 and 0.3605
4th iteration:
0.3604 f (0.3605) − 0.3605 f (0.3604) 0.3604 × 0.0002 − 0.3605 × (−0.0001)
x5 = ⇒ x5 =
f (0.3605) − f (0.3604) 0.0002 − (−0.0001)
x5 = 0.3604
Since x4 and x5 are approximately same , hence the required real root is
0.3604 correct to four decimal place.
Example 5 Given that one of the root of non-liner equation cos x − xe x = 0 lies
between 0.5 and 1.0. Find the root correct three decimal places.
Ans: Let f ( x ) = cos x − xe x
x0 =0.5 0.053
x1 =1.0 -2.1780
x2 =0.512 0.014
x3 =0.516 0.005
x4 =0.517 0.002
x5 =0.517
Ans:
a=2.5 -868
b=3.0 0.572
x1 =2.801 0.007
x2 =2.799 0.002
x3 =2.798 -0.001
x4 =2.798
Ans:
x1 =0.7358 -0.4644
x2 =0.8312 -0.0562
x3 =0.8512 -0.0062
x4 =0.8525 -0.0005
x4 =0.8526
Excerise 1.2
2) Find the root of the equation tan x + tanh x = 0 which lies in the interval
(2.35, 2.37) correct to four decimal places by method of false position.
Let initially the limits of the interval be x0 and x1 . Then the first approx-
imation is given by
x1 − x0 x1 f ( x0 ) − x0 f ( x1 )
x2 = x0 − f ( x0 ) =
f ( x1 ) − f ( x0 ) f ( x0 ) − f ( x1 )
In general
x n f ( x n −1 ) − x n −1 f ( x n )
x n +1 =
f ( x n −1 ) − f ( x n )
In case at any stage f ( xn ) = f ( xn−1 ), this method fail. Hence this method
does not converge always while false position method will always con-
verge. The only advantage in this method lies the fact that if it converges,
then it will converge more rapidly then the false position.
Remarks:
1) In case at any stage f ( xn ) = f ( xn−1 ), this method will fail.
2) This method does not converge always.
2nd approximation:
x2 –x1
x3 = x2 − f ( x2 )
f ( x2 )– f ( x1 )
x3 = 0.186441 f ( x3 ) = −0.074276
3rd approximation:
x3 –x2
x4 = x3 − f ( x3 )
f ( x3 )– f ( x3 )
x4 = 0.201736 f ( x2 ) = −0.00029
4th approximation:
x4 –x3
x5 = x4 − f ( x4 )
f ( x4 )– f ( x3 )
x5 = 0.20164
Example 9 Compute root of the equation x2 e− x/2 = 1 in the interval [0, 2] using
secant method. The root should be correct to three decimal place.
Ans:
x2 = 1.359 f ( x2 ) = −0.064
x3 = 1.436 f ( x3 ) = 0.006
x4 = 1.429 f ( x4 ) = −0.001
x5 = 1.430 f ( x2 ) = 0.000
Example 11 Find the root of the equation xe x = cos x using the secant method
correct to four decimal places.
2nd approximation:
x2 –x1
x3 = x2 − f ( x2 )
f ( x2 )– f ( x1 )
x3 = 0.4467 f ( x3 ) = 0.20354
3rd approximation:
x3 –x2
x4 = x3 − f ( x3 )
f ( x3 )– f ( x3 )
x4 = 0.517
Excerise 1.3
2) Find the real root of the equation tan x + tanh x = 0 which lies in the
interval (2, 30 correct to 3 decimal places.
f ( x0 + h ) = 0
h2
f ( x0 ) + h f 0 ( x0 ) +
f ”( x0 )+ = . . . 0 (Taylor’s series)
2!
Since h is small ,neglecting h2 and higher power of h,we get
f ( x0 ) + h f 0 ( x0 ) = 0
f ( x0 )
h=−
f 0 ( x0 )
A closer approximation to the root is given by
f ( x0 )
x1 = x0 − −
f 0 ( x0 )
Similarly starting with x1 , a still better approximation x2 is given by-
f ( x1 )
x2 = x1 −
f 0 ( x1 )
In general
f ( xn )
x n +1 = x n − (n = 0, 1, 2 . . . )
f 0 ( xn )
Which is known as the Newton – Raphson formula or Newton’s iteration
formula .
Remarks:
1. This method is useful in case of large value of f 0 ( x ) i.e. , when the
graph of f ( x ) while crossing the X-axis is nearly vertical.
2. If f ( x ) is zero or nearly 0, the method fails.
3. Newton’s formula converges provided the initial approximation x0 is
chosen sufficiently close to the root.
4. The order of convergence of Newton – Raphson method is 2.
Example 12 Set up a Newton iteration for computing the square root x of a given
positive number c and apply it to c = 2
√
Ans: Let x = c ⇒ x2 − c = 0
Let f ( x ) = x2 − c ,then f 0 ( x ) = 2x
By Newton Raphson method :
f ( xn )
x n +1 = x n −
f 0 ( xn )
Then
x2 –c
x n +1 = x n − n
2xn
1 c
x n +1 = xn +
2 xn
For c = 2, choosing x0 = 1
Then
1 2
x1 = 1+
2 1
x1 = 1.5
1 2
x2 = 1.5 +
2 1.5
x2 = 1.4167
1 2
x3 = 1.4167 +
2 1.4167
x3 = 1.4142
1 2
x4 = 1.4142 +
2 1.4142
x4 = 1.4142
√
Thus 2 = 1.4142 approximately
Example 13 Find the positive solution of 2 sin x = x by Newton Raphson method
Ans: Let f ( x ) = 2 sin x–x. Then f 0 ( x ) = 2 cos x − 1 and here f (1) = 0.6829
and f (2) = −0.1814
So f (1) f (2) < 0 root lies between 1 and 2. Let x0 = 2. By Newton Raphson
method
f ( xn )
x n +1 = x n −
f 0 ( xn )
2 sin xn − xn
= xn −
2 cos xn − 1
1st iteration:
2 sin x0 − x0
x1 = x0 −
2 cos x0 − 1
2 sin 2 − 2
= 2−
2 cos 2 − 1
= 1.9010
2nd iteration:
2 sin x1 − x1
x2 = x1 −
2 cos x1 − 1
2 sin 1.9010 − 1.9010
= 1.9010 −
2 cos 1.9010 − 1
= 1.8955
3rd iteration:
2 sin x2 − x2
x3 = x2 −
2 cos x2 − 1
2 sin 1.8955 − 1.8955
= 1.8955 −
2 cos 1.8955 − 1
= 1.8955
Thus the solution is x = 1.8955 approximately.
Example 14 Apply Newton method to the equation f ( x ) = x3 + x − 1 = 0
Ans:Let f ( x ) = x3 + x − 1 then f 0 ( x ) = 3x2 + 1. Here f (1) = 1 and f (0) =
−1. As f (1) f (0) < 0 so root lies between 0 and 1. By Newton Raphson
method
Let x0 = 1
f ( xn )
x n +1 = x n −
f 0 ( xn )
xn3 + xn − 1
= xn −
3xn2 + 1
1st iteration:
f ( x0 )
x1 = x0 −
f 0 ( x0 )
1
= 1−
4
= 0.75
2nd iteration:
f ( x1 )
x2 = x1 −
f 0 ( x1 )
(0.75)3 + 0.75 − 1
= 0.75 −
3(0.75)2 + 1
= 0.6860
3rd iteration:
f ( x2 )
x3 = x2 −
f 0 ( x2 )
(0.6860)3 + 0.6860 − 1
= 0.6860 −
3(0.6860)2 + 1
= 0.6823
4th iteration:
f ( x3 )
x4 = x3 −
f 0 ( x3 )
(0.6823)3 + 0.6823 − 1
= 0.6823 −
3(0.6823)2 + 1
= 0.6823
Example 15 Find by Newton’s method, the real root of the equation 3x = cos x +
1 correct to four decimal place. (Take x0 = 0.6)
f ( xn )
x n +1 = x n −
f 0 ( xn )
3xn – cos xn − 1
= xn −
3 + sin xn
xn sin xn + cos xn + 1
=
3 + sin xn
1st iteration:
(0.6) sin(0.6) + cos(0.6) + 1
x1 =
3 + sin(0.6)
= 0.6071
2nd iteration:
(0.6071) sin(0.6071) + cos(0.6071) + 1
x2 =
3 + sin(0.6071)
= 0.6071
√
Ans: Let x = 12,so that x2 − 12 = 0
Take f ( x ) = x2 − 12. Newton’s iterative formula gives
f ( xn )
xnn+1 = xn –
f 0 ( xn )
x2 − 12
= xn − n
2xn
1 12
= xn +
2 xn
Also f (3) = −3 (-ve) and f (4) = 4 (+ve). So root lies between 3 and 4. Take
x0 = 3.Then
1 12
x1 = 3+ ⇒ x1 = 3.5
2 3
1 12 1 12
x2 = x1 + = 3.5 + ⇒ x2 = 3.4643
2 x1 2 3.5
1 12 1 12
x3 = x2 + = 3.4643 + ⇒ x3 = 3.4641
2 x2 2 3.4643
1 12 1 12
x4 = x3 + = 3.4641 + ⇒ x4 = 3.4641
2 x3 2 3.4641
√
Since x3 = x4 upto 4 decimal places. So we have 12 = 3.4641
Example 17 Using Newton’s iterative method, find the real root of x log10 x =
1.2 correct to five decimal places.
log x
Ans: Let f ( x ) = x log10 x − 1.2 = x − 1.2
log 10
1 1
f 0 (x) = x + log x
log 10 x
1
= (1 + log x )
10
= 0.4343 + log10 x
1st iteration:
f ( x0 )
x1 = x0 −
f 0 ( x0 )
3 log(3) − 1.2)
= 3−
log(3) + 0.4343
x1 = 2.74615
2nd iteration:
f ( x1 )
x2 = x1 −
f 0 ( x1 )
2.74615 log(2.74615) − 1.2)
= 2.74615 −
log(2.74615) + 0.4343
x2 = 2.74065
3rd iteration:
f ( x2 )
x3 = x2 −
f 0 ( x2 )
2.74065 log(2.74065) − 1.2)
= 2.74065 −
log(2.74065) + 0.4343
x3 = 2.74065
Excerise 1.4
1) Find a root of the equation x sin x + cos x = 0 by Newton Raphson
method with x0 = π
*****************************