fprintf ( '\n' );
fprintf ( 'trig_bisection\n' );
fprintf ( '  Use bisection2 to estimate a solution to the trig equation.\n' );

xn = 1.0;
xp = 0.0;
xtol = 0.000001;
ftol = 0.000001;
itmax = 50;

fprintf ( '\n' );
fprintf ( '  F(%g) = %g (negative)\n', xn, trig(xn) );
fprintf ( '  F(%g) = %g (positive)\n', xp, trig(xp) );

[ xn, xp, it ] = bisection2 ( @(x)trig(x), xn, xp, xtol, ftol, itmax );

fprintf ( '\n' )
fprintf ( '  After %d iterations:\n', it );
fprintf ( '  F(%g) = %g (negative)\n', xn, trig(xn) );
fprintf ( '  F(%g) = %g (positive)\n', xp, trig(xp) );
fprintf ( '\n' );
fprintf ( '  it <= itmax?  %s\n', mat2str ( it <= itmax ) );
fprintf ( '  |xn-xp| <= xtol?  %s\n', mat2str ( abs ( xn - xp ) <= xtol ) );
fprintf ( '  min(|f(xn)|,|f(xp)|) <= ftol?  %s\n', mat2str ( min(abs (trig(xn)),abs(trig(xp))) <= ftol ) );

