You are on page 1of 10

College of Engineering Pune

Department of Mechanical Engineering

Computational Methods & Programming

Welcome!!
Session 5
Some more numerical on
Bisection method
Bisection method
Determine the root of equation cos x – 1.3 x = 0 using bisection method
with the accuracy of 0.01.
Given:

𝑓 𝑥 = cos 𝑥 − 1.3𝑥
The accuracy = 0.01
Initial guesses are not given.

Solution:
Lets start with finding out initial guesses.
Note: whenever the equation contains trigonometric terms, keep the calculator
in RADIAN mode.
Assume initial guess as 0 and find f(x), we get f(x) = 1
Assume initial guess as 0.5 and find f(x), we get f(x) = 0.2275
Assume initial guess as 1 and find f(x), we get f(x) = – 0.7596
Or check the condition f(0.5)*f(1) < 0 or not,
hence 0.2275* – 0.7596 = – 0.1728 < 0
Hence lets assume x1 = 0.5 and x2 = 1
Bisection method
Iteration 1:
x1 = 0.5 and x2 = 1 as f(x1) = 0.2275 and f(x2) = – 0.7596
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 1)/2 = 0.75
Find f(x3) = cos (0.75) – 1.3*0.75 = – 0.2433 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater
than zero, or remember replace x1 or x2; whose f(x) has same sign as
that of f(x3).
Hence here replace x2 with x3.
x2 = 0.75
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.75 – 0.5 I = 0.25 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.75
Bisection method
Iteration 2:
x1 = 0.5 and x2 = 0.75 as f(x1) = 0.2275 and f(x2) = – 0.2433
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.75)/2 = 0.625
f(x3) = cos (0.625) – 1.3*0.625 = – 1.5368 * 10^ – 3 or – 0.0015368 (Negative)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = – ve
Hence if we check, f(x1)*f(x3) is less than zero and f(x2)*f(x3) is greater than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x2 with x3.
x2 = 0.625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5 I = 0.125 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 as it is = 0.5 and x2 = 0.625
Bisection method
Iteration 3:
x1 = 0.5 and x2 = 0.625 as f(x1) = 0.2275 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5 + 0.625)/2 = 0.5625
f(x3) = cos (0.5625) – 1.3*0.5625 = 0.1146 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5625
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5625 I = 0.0625 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5625 and x2 as it is 0.625
Bisection method
Iteration 4:
x1 = 0.5625 and x2 = 0.625 as f(x1) = 0.1146 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5625 + 0.625)/2 = 0.5937
f(x3) = cos (0.5937) – 1.3* 0.5937 = 0.0570 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.5937
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.5937 I = 0.0313 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.5937 and x2 as it is 0.625
Bisection method
Iteration 5:
x1 = 0.5937 and x2 = 0.625 as f(x1) = 0.0570 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.5937 + 0.625)/2 = 0.6093
f(x3) = cos (0.6093) – 1.3* 0.6093 = 0.0278 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6093
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6093 I = 0.0157 > 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6093 and x2 as it is 0.625
Bisection method
Iteration 6:
x1 = 0.6093 and x2 = 0.625 as f(x1) = 0.0278 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6093 + 0.625)/2 = 0.6171
f(x3) = cos (0.6171) – 1.3* 0.6171= 0.0132 (Positive)
Now compare signs of f(x1), f(x2) and f(x3)
f(x1) = + ve
f(x2) = – ve
f(x3) = + ve
Hence if we check, f(x1)*f(x3) is greater than zero and f(x2)*f(x3) is less than
zero, or remember replace x1 or x2; whose f(x) has same sign as that of f(x3).
Hence here replace x1 with x3.
x1 = 0.6171
Let’s check the accuracy, I x2 – x1 I < accuracy or not
I 0.625 – 0.6171 I = 0.0079 < 0.01
Hence go for next iteration considering new values of initial guesses as
x1 = 0.6171 and x2 as it is 0.625
Bisection method
Iteration 7:
x1 = 0.6171 and x2 = 0.625 as f(x1) = 0.0132 and f(x2) = – 0.0015368
Calculate new approximated root using formula x3 = (x1 + x2)/2
We get x3 = (0.6171 + 0.625)/2 = 0.6210

Hence root of equation is 0.6210

Iteration 1 x1 F(x1) x2 F(x2) x3 F(x3) Accuracy


1 0.5 0.2275 1 -0.7596 0.75 -0.2433 0.25
2 0.5 0.2275 0.75 -0.2433 0.625 – 0.0015368 0.125
3 0.5 0.2275 0.625 – 0.0015368 0.5625 0.1146 0.0625
4 0.5625 0.1146 0.625 – 0.0015368 0.5937 0.0570 0.0313
5 0.5937 0.0570 0.625 – 0.0015368 0.6093 0.0278 0.0157
6 0.6093 0.0278 0.625 – 0.0015368 0.6171 0.0132 0.0079
7 0.6171 0.0132 0.625 – 0.0015368 0.6210 0.0059

You might also like