Topic 10.2: False-Position Method (Maple)

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

The false-position 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:
> step_size := infinity:
> while step_size >= epsilon[step] or ( abs( f(a) ) >= epsilon[abs] and abs( f(b) ) >= epsilon[abs] ) do
    c := (f(a)*b - f(b)*a)/(f(a) - f(b));

    if f(c) = 0 then
       break;
    elif f(a)*f(c) < 0 then
       step_size := b - c;
       b := c;
    else
       step_size := c - a;
       a := c;
    end if;
end do:
> [a, b];
                               [1.259915864, 2.0]

> abs( f(a) );
                                      0.000024696
                        
> abs( f(b) );
                                      6.000

Thus, we would choose 1.259915864 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.