XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ dfzero()

void dfzero ( double(*)(double)  f,
double *  b,
double *  c,
double  r,
double  re,
double  ae,
int *  info 
)

Solution of a single general nonlinear equation

Purpose
dfzero searches for a zero of a function f(x) between the given values b and c until the width of the interval [b, c] has collapsed to within a tolerance specified by the stopping criterion, abs(b - c) <= 2*(re*abs(b) + ae).
It is designed primarily for problems where f(b) and f(c) have opposite signs. The method used is an efficient combination of bisection and the secant rule.
Parameters
[in]fUser supplied function which evaluates f(x) for the equation f(x) = 0 defined as follows:
double f(double x)
{
return (computed function value f(x));
}
[in,out]b[in] Lower endpoint of the initial interval.
[out] Lower endpoint of the final interval (the approximation to a zero).
[in,out]c[in] Upper endpoint of the initial interval.
[out] Upper endpoint of the final interval.
[in]rA (better) guess of a zero of f which could help in speeding up convergence. When no better guess is known, it is recommended that r be set to b or c.
[in]reRelative error used for the stopping criterion. If the requested re is less than machine precision, then it is set to approximately machine precision.
[in]aeAbsolute error used in the stopping criterion. If the given interval [b, c] contains the origin, then a nonzero value should be chosen for ae.
[out]info= 0: Normal return
= 1: f(x) = 0, however the interval may not have collapsed to the requested tolerance
= 2: b may be near a singular point of f(x)
= 3: No change in sign of f(x) was found although the interval
= 4: Too many (> 500) function evaluations used
Reference
D. Kahaner, C. Moler, S. Nash, "Numerical Methods and Software", Prentice-Hall (1989)