NAG Library Chapter Introduction
C05 – Roots of One or More Transcendental Equations
This chapter is concerned with the calculation of zeros of continuous functions of one or more variables. The majority of problems considered are for realvalued functions of real variables, in which case complex equations must be expressed in terms of the equivalent larger system of real equations.
The chapter divides naturally into two parts.
The first deals with the real zeros of a real function of a single variable
fx
.
The two other routines are both designed for the case where you are unable to specify an interval containing the simple zero. One starts from an initial point and performs a search for an interval containing a simple zero. If such an interval is computed then the method described above is used next to determine the zero accurately. The other method uses a ‘continuation’ method based on a secant iteration. A sequence of subproblems is solved; the first of these is trivial and the last is the actual problem of finding a zero of
fx
. The intermediate problems employ the solutions of earlier problems to provide initial guesses for the secant iterations used to calculate their solutions.
Three other routines are also supplied. They employ reverse communication and use the same core algorithms as the routines described above.
Finally, two routines are provided to return values of Lambert's
W function (sometimes known as the ‘product log’ or ‘Omega’ function), which is the inverse function of
that is, if Lambert's
W function
Wx=a for
x,a∈C, then
a is a zero of the function
Fw=wewx. One routine uses the iterative method described in
Barry et al. (1995) to return values from the real branches of
W (restricting
x,a∈R). The second routine enforces no such restriction, and uses the approach described in
Corless et al. (1996).
The routines can be divided into two classes. There are three routines (C05AVF,
C05AXF and
C05AZF) all written in reverse communication form and three (
C05AUF,
C05AWF and
C05AYF) written in direct communication form. The direct communication routines are designed for inexperienced users and, in particular, for solving problems where the function
fx
whose zero is to be calculated, can be coded as a usersupplied (sub)program. These routines find the zero by using the same core algorithms as the reverse communication routines. Experienced users are recommended to use the reverse communication routines directly as they permit you more control of the calculation. Indeed, if the zerofinding process is embedded in a much larger program then the reverse communication routines should always be used.
The recommendation as to which routine should be used depends mainly on whether you can supply an interval
a,b
containing the zero; that is, where
fa×fb<0
. If the interval can be supplied, then
C05AYF (or, in reverse communication,
C05AZF) should be used, in general. This recommendation should be qualified in the case when the only interval which can be supplied is very long relative to your error requirements
and you can also supply a good approximation to the zero. In this case
C05AWF (or, in reverse communication,
C05AXF)
may prove more efficient (though these latter routines will not provide the error bound available from
C05AZF).
If an interval containing the zero cannot be supplied then you must choose between
C05AUF (or, in reverse communication,
C05AVF followed by
C05AZF) and
C05AWF (or, in reverse communication,
C05AXF).
C05AUF first determines an interval containing the zero, and then proceeds as in
C05AYF; it is particularly recommended when you do not have a good initial approximation to the zero. If a good initial approximation to the zero is available then
C05AWF is to be preferred. Since neither of these latter routines has guaranteed convergence to the zero, you are recommended to experiment with both in case of difficulty.
The routines for solving a set of nonlinear equations can also be divided into classes. There are five routines (
C05QBF,
C05QCF,
C05QSF,
C05RBF and
C05RCF) all written in direct communication form and two (
C05QDF and
C05RDF) written in reverse communication form. The direct communication routines are designed for inexperienced users and, in particular, these routines require the
fi
(and possibly their derivatives) to be calculated in usersupplied subroutines. These should be set up carefully so the Library routines can work as efficiently as possible. Experienced users are recommended to use the reverse communication routines as they permit you more control of the calculation. Indeed, if the zerofinding process is embedded in a much larger program then the reverse communication routines should always be used.
The main decision you have to make is whether to supply the derivatives
∂fi
∂xj
. It is advisable to do so if possible, since the results obtained by algorithms which use derivatives are generally more reliable than those obtained by algorithms which do not use derivatives.
C05RBF,
C05RCF and
C05RDF require you to provide the derivatives, whilst
C05QBF,
C05QCF,
C05QDF and
C05QSF do not.
C05QBF,
C05QSF and
C05RBF are easytouse routines; greater flexibility may be obtained using
C05QCF and
C05RCF (or, in reverse communication,
C05QDF and
C05RDF), but these have longer parameter lists.
C05QSF is an easytouse routine specially adapted for sparse problems, that is, problems where each function depends on a small subset of the
n variables so that the Jacobian matrix has many zeros. It employs sparse linear algebra methods and consequently is expected to take significantly less time to complete than the other routines, especially if
n is large.
C05ZDF is provided for use in conjunction with
C05RBF,
C05RCF and
C05RDF to check the usersupplied derivatives for consistency with the functions themselves. You are strongly advised to make use of this routine whenever
C05RBF,
C05RCF or
C05RDF is used.
Firstly, the calculation of the functions and their derivatives should be ordered so that cancellation errors are avoided. This is particularly important in a routine that uses these quantities to build up estimates of higher derivatives.
Secondly, scaling of the variables has a considerable effect on the efficiency of a routine. The problem should be designed so that the elements of x are of similar magnitude. The same comment applies to the functions, i.e., all the
fi
should be of comparable size.
The accuracy is usually determined by the accuracy parameters of the routines, but the following points may be useful.
(i) 
Greater accuracy in the solution may be requested by choosing smaller input values for the accuracy parameters. However, if unreasonable accuracy is demanded, rounding errors may become important and cause a failure. 
(ii) 
Some idea of the accuracies of the
xi
may be obtained by monitoring the progress of the routine to see how many figures remain unchanged during the last few iterations. 
(iii) 
An approximation to the error in the solution x is given by e where e is the solution to the set of linear equations
where
fx
=
f1x,f2x,…,fnxT
.
Note that the
QR
decomposition of J is available from C05QCF and C05RCF (or, in reverse communication, C05QDF and C05RDF) so that
and
QTf
is also provided by these routines. 
(iv) 
If the functions
fix
are changed by small amounts
ε
i
, for i=1,2,…,n, then the corresponding change in the solution x is given approximately by σ, where σ is the solution of the set of linear equations
Thus one can estimate the sensitivity of x to any uncertainties in the specification of
fix
, for i=1,2,…,n. As noted above, the sophisticated routines C05QCF and C05RCF (or, in reverse communication, C05QDF and C05RDF) provide the
QR
decomposition of J. 
Is reverse communication required? 
_ yes 
Is there available an interval
a,b
containing a simple zero, and no others? 
_ yes 
C05AZF 
 
 no  

 
 Is a good approximation to the zero available? 
_ yes 
C05AXF 
 
 no  

 
 C05AVF followed by C05AZF 
no  

Do you wish to compute the values of Lambert's W function? 
_ yes 
do you require values from only the real branches? 
_ yes 
C05BAF 
 
 no  

 
 C05BBF 
no  

Is there available an interval
a,b
containing a simple zero, and no others? 
_ yes 
C05AYF 
no  

Is a good approximation to the zero available? 
_ yes 
C05AWF 
no  

C05AUF 
Is the Jacobian matrix sparse? 
_ yes 
C05QSF 
no  

Is reverse communication required? 
_ yes 
Is the Jacobian matrix available? 
_ yes 
C05RDF and C05ZDF 
 
 no  

 
 C05QDF 
no  

Is the Jacobian matrix available? 
_ yes 
Is flexibility required? 
_ yes 
C05RCF and C05ZDF 
 
 no  

 
 C05RBF and C05ZDF 
no  

Is flexibility required? 
_ yes 
C05QCF 
no  

C05QBF 
Zeros of functions of one variable:   
binary search followed by Brent algorithm   C05AUF 
Zeros of functions of several variables:   
Checks usersupplied Jacobian   C05ZDF 
no derivatives required   C05QBF 
no derivatives required, sparse   C05QSF 
no derivatives required   C05QCF 
no derivatives required   C05QDF 
None.