Bisection Method And Matlab Code

Bisection method is the one of the bracketing numerical methods. This method allows us to find the roots of polynomial but this method cannot find noncomplex roots of the polynomial equation, it allows us to find only reel roots of the equation. Due to this feature, bisection method considered primitive method by mathematicians. If you use this method you cannot find the real roots of the equation but you can find the closest values of the roots with some inaccuracy

To find the roots of the equation, you must start with two initial estimates of the roots.One of these estimates should be higher value of the root and the other one should be remain under value of the root. Otherwise bisection method will not work properly.

Description Of The Bisection Method

It is known that, the function values above and below of the root is opposite in sign. So we can define the root as the point where the equation changes its sign. This statement is actually not true.

For example, let’s look at the following very simple example

As everyone knows, the root is zero. However, this problem cannot solve by the bisection method. Because, this function is a dual function. (symmetrical by y axis) basically, there are no negative root of this equation so when we multiply this roots, multiplication value must be positive.


But we have one simple rule to use this method; 

F(xu) = under value F(xl)= higher value

      F(xu) x F(xl) < 0

After providing this condition, we must find the location of the root. Estimated location of the root by bisection method can be found by this equation;

bisection method formula

This formula makes sense indeed because it is certain that the root must be found between the under value and higher value. After the calculation phase we must make a decision. The root is between xr and xu or it is between xr and xl ?

It is decided as follows.

If f(xr) x f(xu) < 0  it is between xr and xu.

Otherwise it is between xr and xl.

After deciding this, method will make new assignments and repeats itself in this way.

This methot called bisection method because of that. Bisection method approximates the root by dividing it.

Below, you can see the algorithm of Bisection method.


Matlab Code For Bisection Method

% wwww.engineershandbook.net
a=input('Enter Function:','s');
xl=input('Enter lower guess:') ;
xu=input('Enter upper guess:');
tol=input('Enter tolerance(recommended 0.001):');

if f(xu)*f(xl)<0
    fprintf('Wrong Guess!Enter new guess\n');
    xl=input('Enter lower guess:\n') ;
    xu=input('Enter upper guess:\n');

for i=2:1000
if f(xu)*f(xr)<0
if f(xl)*f(xr)<0
if abs((xnew(i)-xnew(i-1))/xnew(i))<tol,break,end
str = ['Root: ', num2str(xr), '']


There are two examples for Matlab output. In the first one, the estimates have been selected entirely true. In the other one, knowingly false predictions have been selected.

example 1 for Matlab output



example 2 for Matlab output


Uğur Dinçer

Job: Mechanical Engineering and Industrial Engineering University: Doğuş University   Speciality: Numerical Analysis, Programing Languages, Finite Element Method.   Facebook: https://www.facebook.com/uurdincer   Twitter: Eng_Handbook  

One Comment

  1. Hi, I had a deficulity in driving my function , when it comes total impedance of parallel RLC CIRCUIT .

Leave a Reply

Your email address will not be published. Required fields are marked *