Bisection method (Numerical analysis)

2019-03-01 08:53发布

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

2条回答
Animai°情兽
2楼-- · 2019-03-01 09:19

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).

查看更多
乱世女痞
3楼-- · 2019-03-01 09:19

The algorithm of bisection method is such that it can only find one root between a defined interval. In your problem, all three roots cannot be found, but if you define different intervals to find out individual roots, you may succeed. You may go through this sample program for bisection method in Matlab with full theoretical background and example.

查看更多
登录 后发表回答