Nonlinear Equation Solving Using Bisection Method
Nonlinear Equation Solving Using Bisection Method
: 02
1.2 Experiment Name
1.3 Objectives:
i) To gain knowledge about bisection method.
ii) To solve a nonlinear equation using bisection method.
1.4 Theory
The bisection method is used to find the roots of a polynomial equation. It separates the interval and
subdivides the interval in which the root of the equation lies. The principle behind this method is the
intermediate theorem for continuous functions. It works by narrowing the gap between the positive and
negative intervals until it closes in on the correct answer. This method narrows the gap by taking the
average of the positive and negative intervals. It is a simple method and it is relatively slow. The
bisection method is also known as interval halving method, root-finding method, binary search method
or dichotomy method.
To solve bisection method problems, given below is the step-by-step explanation of the working of the
bisection method algorithm for a given function f(x):
Step 1:Choose two values, a and b such that f(a) > 0 and f(b) < 0 .
Step 2:Calculate a midpoint c as the arithmetic mean between a and b such that c = (a + b) / 2. This is
called interval halving.
Step 4:The root of the function is found only if the value of f(c) = 0.
Step 5:If (c) ≠ 0, then we need to check the sign:we replace a with c if f(c) has the same sign as f(a)
and we keep the same value for bwe replace b with c if f(c) has the same sign as f(b), and we keep the
same value for a.
To get the right value with the new value of a or b, we go back to step 2 And recalculate c.
MATLAB
clc
clear all
f=@(x)x.^2-4*x-10;
x1=5;
x2=6;
e=0.001;
i=0;
fprintf(' Bisection Method\n\n\nIteration No.
Roots');
while abs(x1-x2)>e,
x=(x1+x2)/2;
if f(x)>0
x2=x
else
x1=x;
end
i=i+1;
fprintf('\n %.2f %.8f',i,x);
end
fprintf('\nThe root of the equation is %.8f',x)
1.7 Output
Bisection Method
5.7500
2.00 5.75000000
3.00 5.62500000
4.00 5.68750000
5.00 5.71875000
6.00 5.73437500
x2 =
5.7422
7.00 5.74218750
8.00 5.73828125
9.00 5.74023438
10.00 5.74121094
The root of the equation is 5.74121094>>