Bisection method is used for finding root of the function in given interval.

Algorithm:

IN:
Function f, which is continous function and interval [a,b]. Function must satisfy given equation: f(a) * f(b) < 0 - signs of that values are different, which means that given function in given interval has at least one root in interval [a,b].
OUT: 
Root in given interval.
1. Calculate c - midpoint of given interval using formula: c = (a + b) / 2.
2. Calculate f(c).
3. If b - a is small enough or abs(f(c)) is small enough: return c - which is the root we were searching for;
4. If(f(a) * f(c) < 0) assign c to b, else assign c to a.
5. Go to step 1.

Step By Step:

  • Bisection Method Step 1
    Bisection Method Step 1

Sample Output:

f(x) = x * (x * (x * (x * (x)) + 2)) - 2
[0,2]

root: 0.8515625

Bisection Method Step By Step

Iteration Numberacbf(cn)
10121
200.51-1.4375
30.50.751-0.55859375
40.750.87510.117431640625
50.750.81250.875-0.2438812255859375
60.81250.843750.875-0.0693502426147461
70.843750.8593750.875 0.022470533847808838
80.843750.85156250.859375 -0.023827489465475082

Pros:

  • easy to implement.
  • no need to calculate derivative of given function.

Cons:

  • slow compared to other methods.
Python Implementation C++ Implementation C# Implementation Java Implementation Matlab Implementation R Implementation



Bisection Method Algorithm
Tagged on:         

Leave a Reply

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

By continuing to use the site, you agree to the use of cookies. You can read more about it the Cookies&Privacy Policy Section Above. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this. You can read more about it the Cookies&Privacy Policy Section.

Close