xtol = 0.000001;
a = 1.45;
b = 1.5;
[ x1, a, b ] = bisection3 ( xtol, a, b, @cubic );
fprintf ( '\n' );
fprintf ( 'Solution: F(%20.16g) = %g\n', x1, cubic ( x1 ) );
fprintf ( 'Interval: [%20.16g, %20.16g]\n', a, b );
fprintf ( 'Interval width: %g\n', b - a );

xtol = 0.000001;
a = 1.5;
b = 1.6;
[ x2, a, b ] = bisection3 ( xtol, a, b, @cubic );

fprintf ( '\n' );
fprintf ( 'Solution: F(%20.16g) = %g\n', x2, cubic ( x2 ) );
fprintf ( 'Interval: [%20.16g, %20.16g]\n', a, b );
fprintf ( 'Interval width: %g\n', b - a );

xtol = 0.000001;
a = 1.6;
b = 1.7;
[ x3, a, b ] = bisection3 ( xtol, a, b, @cubic );

fprintf ( '\n' );
fprintf ( 'Solution: F(%20.16g) = %g\n', x3, cubic ( x3 ) );
fprintf ( 'Interval: [%20.16g, %20.16g]\n', a, b );
fprintf ( 'Interval width: %g\n', b - a );

xlist = linspace ( 1.43, 1.71, 101 );
ylist = cubic ( xlist );

plot ( xlist, ylist, ...
       xlist, 0*ylist, 'k:', ...
       x1, 0, 'r.', ...
       x2, 0, 'r.', ...
       x3, 0, 'r.', ...
       'Linewidth', 3, 'Markersize', 50 );
grid on
xlabel ( '<-- X -->' )
ylabel ( '<-- Y -->' )
title ( 'Estimated zeros of cubic', 'Fontsize', 24 );
print ( '-djpeg', 'hw042.jpg' );
