ZBRENT
Name
ZBRENT
Purpose
Find the zero of a 1-D function up to specified tolerance.
Explantion
This routine assumes that the function is known to have a zero.
Adapted from procedure of the same name in "Numerical Recipes" by
Press et al. (1992), Section 9.3
CALLING:
x_zero = ZBRENT( x1, x2, FUNC_NAME="name", MaX_Iter=, Tolerance=,
_EXTRA = )
Inputs
x1, x2 = scalars, 2 points which bracket location of function zero,
that is, F(x1) < 0 < F(x2).
Note: computations are performed with
same precision (single/double) as the inputs and user supplied function.
REQUIRED INPUT KEYWORD:
FUNC_NAME = function name (string)
Calling mechanism should be: F = func_name( px )
where: px = scalar independent variable, input.
F = scalar value of function at px,
should be same precision (single/double) as input.
Optional Input Keywords
MAX_ITER = maximum allowed number iterations, default=100.
TOLERANCE = desired accuracy of minimum location, default = 1.e-3.
Any other keywords are passed directly to the user-supplied function
via the _EXTRA facility.
Outputs
Returns the location of zero, with accuracy of specified tolerance.
Procedure
Brent's method to find zero of a function by using bracketing,
bisection, and inverse quadratic interpolation,
Example
Find the root of the COSINE function between 1. and 2. radians
IDL> print, zbrent( 1, 2, FUNC = 'COS')
and the result will be !PI/2 within the specified tolerance
Modification History
Written, Frank Varosi NASA/GSFC 1992.
FV.1994, mod to check for single/double prec. and set zeps accordingly.
Use MACHAR() to define machine precision W. Landsman September 2002
Added _EXTRA keyword W. Landsman December 2011
Need to check whether user function accepts keywords W.L. Jan 2012