Search code examples
matlabanalysisnumericalnewtons-methodbisection

Bisection method (Numerical analysis)


How many recursions are made before every single root is found? Also, which ones are the roots?


Here's my code:

e=0.000001; 
f1=@(x) 14.*x.*exp(x-2)-12.*exp(x-2)-7.*x.^3+20.*x.^2-26.*x+12;

a=0; 
c=3; 
while abs(c-a)>e 
    b=(c+a)/2; 
    if f1(a)*f1(b)<0 
        c=b; 
    else
        a=b;
    end    
    disp(b);  
end

Solution

  • Bisection works by taking endpoints of some initial interval [a,b] and finding which half of the interval must contain the root (it evaluates the midpoint, and identifies which half has the sign change). Then bisection repeats the process on the identified half.

    Bisection converges upon only one possible root, and if your function has multiple roots inside [a,b], it is difficult to predict in general which specific root it will converge to. (Note: since bisection is a fully deterministic algorithm, it will always converge to the exact same root if you give it the same initial interval.) The iterations simply refine your approximation of found root, they do not find multiple roots.

    To directly answer your question, bisection will not discover all three of the roots of your function inside [0,3]. It will find just one root, and this is identified by the final iteration of your bisection code. All of the values outputted by the bisection iterations simply show the progress made by the algorithm towards the one root it eventually found (and these values should be a sequence converging upon the final value).