fprintf ( '\n' );
fprintf ( 'cubic_regula_falsi2\n' );
fprintf ( '  Use modified regula_falsi to estimate a root of a cubic function.\n' );

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

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

[ xn, xp, it ] = regula_falsi2 ( @(x)cubic(x), xn, xp, xtol, ftol, itmax );

fprintf ( '\n' )
fprintf ( '  After %d iterations:\n', it );
fprintf ( '  F(%20.16g) = %g (negative)\n', xn, cubic(xn) );
fprintf ( '  F(%20.16g) = %g (positive)\n', xp, cubic(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 (cubic(xn)),abs(cubic(xp))) <= ftol ) );

