nag_zero_cont_func_cntin_rcomm (c05axc) attempts to locate a zero of a continuous function using a continuation method based on a secant iteration. It uses reverse communication for evaluating the function.
nag_zero_cont_func_cntin_rcomm (c05axc) uses a modified version of an algorithm given in
Swift and Lindfield (1978) to compute a zero
$\alpha $ of a continuous function
$f\left(x\right)$. The algorithm used is based on a continuation method in which a sequence of problems
are solved, where
$1={\theta}_{0}>{\theta}_{1}>\cdots >{\theta}_{m}=0$ (the value of
$m$ is determined as the algorithm proceeds) and where
${x}_{0}$ is your initial estimate for the zero of
$f\left(x\right)$. For each
${\theta}_{r}$ the current problem is solved by a robust secant iteration using the solution from earlier problems to compute an initial estimate.
You must supply an error tolerance
tol.
tol is used directly to control the accuracy of solution of the final problem (
${\theta}_{m}=0$)
in the continuation method, and
$\sqrt{{\mathbf{tol}}}$ is used to control the accuracy in the intermediate problems
(
${\theta}_{1},{\theta}_{2},\dots ,{\theta}_{m1}$).
Swift A and Lindfield G R (1978) Comparison of a continuation method for the numerical solution of a single nonlinear equation Comput. J. 21 359–362
Note: this function uses
reverse communication. Its use involves an initial entry, intermediate exits and reentries, and a final exit, as indicated by the argument
ind. Between intermediate exits and reentries,
all arguments other than fx must remain unchanged.
 1:
x – double *Input/Output

On initial entry: an initial approximation to the zero.
On intermediate exit:
the point at which $f$ must be evaluated before reentry to the function.
On final exit: the final approximation to the zero.
 2:
fx – doubleInput

On initial entry: if
${\mathbf{ind}}=1$,
fx need not be set.
If
${\mathbf{ind}}=1$,
fx must contain
$f\left({\mathbf{x}}\right)$ for the initial value of
x.
On intermediate reentry: must contain
$f\left({\mathbf{x}}\right)$ for the current value of
x.
 3:
tol – doubleInput

On initial entry: a value that controls the accuracy to which the zero is determined.
tol is used in determining the convergence of the secant iteration used at each stage of the continuation process. It is used directly when solving the last problem (
${\theta}_{m}=0$ in
Section 3), and
$\sqrt{{\mathbf{tol}}}$ is used for the problem defined by
${\theta}_{r}$,
$r<m$. Convergence to the accuracy specified by
tol is not guaranteed, and so you are recommended to find the zero using at least two values for
tol to check the accuracy obtained.
Constraint:
${\mathbf{tol}}>0.0$.
 4:
ir – Nag_ErrorControlInput

On initial entry: indicates the type of error test required, as follows. Solving the problem defined by
${\theta}_{r}$,
$1\le r\le m$, involves computing a sequence of secant iterates
${x}_{r}^{0},{x}_{r}^{1},\dots \text{}$. This sequence will be considered to have converged only if:
for
${\mathbf{ir}}=\mathrm{Nag\_Mixed}$,
for
${\mathbf{ir}}=\mathrm{Nag\_Absolute}$,
for
${\mathbf{ir}}=\mathrm{Nag\_Relative}$,
for some
$i>1$; here
$\mathit{eps}$ is either
tol or
$\sqrt{{\mathbf{tol}}}$ as discussed above. Note that there are other subsidiary conditions (not given here) which must also be satisfied before the secant iteration is considered to have converged.
Constraint:
${\mathbf{ir}}=\mathrm{Nag\_Mixed}$, $\mathrm{Nag\_Absolute}$ or $\mathrm{Nag\_Relative}$.
 5:
scal – doubleInput

On initial entry: a factor for use in determining a significant approximation to the derivative of
$f\left(x\right)$ at
$x={x}_{0}$, the initial value. A number of difference approximations to
${f}^{\prime}\left({x}_{0}\right)$ are calculated using
where
$\lefth\right<\left{\mathbf{scal}}\right$ and
$h$ has the same sign as
scal. A significance (cancellation) check is made on each difference approximation and the approximation is rejected if insignificant.
Suggested value:
$\sqrt{\epsilon}$, where
$\epsilon $ is the
machine precision returned by
nag_machine_precision (X02AJC).
Constraint:
${\mathbf{scal}}$ must be sufficiently large that ${\mathbf{x}}+{\mathbf{scal}}\ne {\mathbf{x}}$ on the computer.
 6:
c[$26$] – doubleCommunication Array

(${\mathbf{c}}\left[4\right]$ contains the current ${\theta}_{r}$, this value may be useful in the event of an error exit.)
 7:
ind – Integer *Input/Output

On initial entry: must be set to
$1$ or
$1$.
 ${\mathbf{ind}}=1$
 fx need not be set.
 ${\mathbf{ind}}=1$
 fx must contain $f\left({\mathbf{x}}\right)$.
On intermediate exit:
contains
$2$,
$3$ or
$4$. The calling program must evaluate
$f$ at
x, storing the result in
fx, and reenter nag_zero_cont_func_cntin_rcomm (c05axc) with all other arguments unchanged.
On final exit: contains $0$.
Constraint:
on entry ${\mathbf{ind}}=1$, $1$, $2$, $3$ or $4$.
 8:
fail – NagError *Input/Output

The NAG error argument (see
Section 3.6 in the Essential Introduction).
 NE_BAD_PARAM
On entry, argument $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_CONTIN_AWAY_NOT_POSS
Continuation away from the initial point is not possible.
This error exit will usually occur if the problem has not been properly
posed or the error requirement is extremely stringent.
 NE_CONTIN_PROB_NOT_SOLVED
Current problem in the continuation sequence cannot be solved.
Perhaps the original problem had no solution or the
continuation path passes through a set of insoluble problems:
consider refining the initial approximation to the zero.
Alternatively,
tol is too small, and the accuracy requirement is
too stringent, or too large and the initial approximation too poor.
 NE_FINAL_PROB_NOT_SOLVED
Final problem (with ${\theta}_{m}=0$) cannot be solved.
It is likely that too much accuracy has been requested,
or that the zero is at $\alpha =0$ and ${\mathbf{ir}}=\mathrm{Nag\_Relative}$.
 NE_INT
On initial entry, ${\mathbf{ind}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ind}}=1$ or $1$.
On intermediate entry, ${\mathbf{ind}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{ind}}=2$, $3$ or $4$.
 NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
 NE_REAL
On entry, ${\mathbf{scal}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{x}}+{\mathbf{scal}}\ne {\mathbf{x}}$ (to machine accuracy).
On entry, ${\mathbf{tol}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{tol}}>0.0$.
 NE_SIGNIF_DERIVS_NOT_COMPUT
Significant derivatives of
$f$ cannot be computed.
This can happen when
$f$ is almost constant and nonzero,
for any value of
scal.
The accuracy of the approximation to the zero depends on
tol and
ir. In general decreasing
tol will give more accurate results. Care must be exercised when using the relative error criterion (
${\mathbf{ir}}=2$).
If the zero is at
${\mathbf{x}}=0$, or if the initial value of
x and the zero bracket the point
${\mathbf{x}}=0$, it is likely that an error exit with
${\mathbf{fail}}\mathbf{.}\mathbf{code}=\text{}$NE_CONTIN_AWAY_NOT_POSS,
NE_CONTIN_PROB_NOT_SOLVED or
NE_FINAL_PROB_NOT_SOLVED will occur.
It is possible to request too much or too little accuracy. Since it is not possible to achieve more than machine accuracy, a value of
${\mathbf{tol}}\ll \mathit{machineprecision}$ should not be input and may lead to an error exit with
${\mathbf{fail}}\mathbf{.}\mathbf{code}=\text{}$NE_CONTIN_AWAY_NOT_POSS,
NE_CONTIN_PROB_NOT_SOLVED or
NE_FINAL_PROB_NOT_SOLVED. For the reasons discussed under
${\mathbf{fail}}\mathbf{.}\mathbf{code}=\text{}$NE_CONTIN_PROB_NOT_SOLVED in
Section 6,
tol should not be taken too large, say no larger than
${\mathbf{tol}}=\text{1.0e\u22123}$.
For most problems, the time taken on each call to nag_zero_cont_func_cntin_rcomm (c05axc) will be negligible compared with the time spent evaluating
$f\left(x\right)$ between calls to nag_zero_cont_func_cntin_rcomm (c05axc). However, the initial value of
x and the choice of
tol will clearly affect the timing. The closer that
x is to the root, the less evaluations of
$f$ required. The effect of the choice of
tol will not be large, in general, unless
tol is very small, in which case the timing will increase.
None.