Topic 10.1: Bisection Method (Maple)

Contents Previous Chapter Start of Chapter No Previous Topic Introduction Notes Theory HOWTO Examples Engineering Error Questions Matlab Maple Next Topic Next Chapter

The bisection method in Maple is quite straight-forward:

> epsilon[abs] := 1e-5:
> epsilon[step] := 1e-5:
> f := x -> x^3 - 2:
> a := 0.0:
> b := 2.0:
> while b - a >= epsilon[step] or ( abs( f(a) ) >= epsilon[abs] and abs( f(b) ) >= epsilon[abs] ) do
    c := (a + b)/2;

    if f(c) = 0 then
       break;
    elif f(a)*f(c) < 0 then
       b := c;
    else
       a := c;
    end if;
end do:
> [a, b];
                               [1.259918214, 1.259925843]
> abs( f(a) );
                                      0.000013505
> abs( f(b) );
                                      0.000022826

Thus, we would choose 1.259918214 as our approximation to the cube-root of 2, which has an actual value (to 10 digits) of 1.259921050.

Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.