BisectionZero:

Path: Math/Solvers

% Use bisection method to find the zero crossing of a function.
   The limits are evaluated before the algorithm begins. If both values
   either less than or greater than zero, the function returns an
   appropriate message and n will be 0.

   Since version 10.
--------------------------------------------------------------------------
   Form:
   [x,n] = BisectionZero( f, x0, xLim, xTol, nmax )

--------------------------------------------------------------------------

   ------
   Inputs
   ------
   f         (1,1)   Function handle
   x0        (1,1)   Initial guess for x
   xLim      (1,2)   Limits for x: [min,max]
   xTol      (1,1)   Tolerance for exit
   nmax      (1,1)   Maximum iterations

   -------
   Outputs
   -------
   x         (1,1)   Value of x for f(x) = 0
   n         (1,1)   Number of iterations (number of function evaluations)
   msg       (1,:)   Message if boundary failure

--------------------------------------------------------------------------

Back to the Math Module page