NAG CL Interface
c05mbc (sys_func_aa)
1
Purpose
c05mbc finds a solution of a system of nonlinear equations by fixedpoint iteration using Anderson acceleration.
2
Specification
void 
c05mbc (
void 
(*f)(Integer n,
const double x[],
double fvec[],
Nag_Comm *comm, Integer *iflag),


Integer n,
double x[],
double fvec[],
double atol,
double rtol,
Integer m,
double cndtol,
Integer astart,
Nag_Comm *comm,
NagError *fail) 

The function may be called by the names: c05mbc, nag_roots_sys_func_aa or nag_zero_nonlin_eqns_aa.
3
Description
The system of equations is defined as:
This homogeneous system can readily be reformulated as
A standard fixedpoint iteration approach is to start with an approximate solution
${\hat{x}}_{0}$ and repeatedly apply the function
$g$ until possible convergence; i.e.,
${\hat{x}}_{i+1}=g\left({\hat{x}}_{i}\right)$, until
$\Vert {\hat{x}}_{i+1}{\hat{x}}_{i}\Vert <\text{tol}$. Anderson acceleration uses up to
$m$ previous values of
$\hat{x}$ to obtain an improved estimate
${\hat{x}}_{i+1}$. If a standard fixedpoint iteration converges, Anderson acceleration usually results in convergence in far fewer iterations (therefore using far fewer function evaluations).
Full details of Anderson acceleration are provided in
Anderson (1965). In summary, the previous
$m$ iterates are combined to form a succession of least squares problems. These are solved using a
$QR$ decomposition, which is updated at each iteration.
You are free to choose any value for $m$, provided $m\le n$. A typical choice is $m=4$.
4
References
Anderson D G (1965) Iterative Procedures for Nonlinear Integral Equations J. Assoc. Comput. Mach. 12 547–560
5
Arguments

1:
$\mathbf{f}$ – function, supplied by the user
External Function

f must return the values of the functions
${f}_{k}$ at a point
$x$.
The specification of
f is:
void 
f (Integer n,
const double x[],
double fvec[],
Nag_Comm *comm, Integer *iflag)



1:
$\mathbf{n}$ – Integer
Input

On entry: $n$, the number of equations.

2:
$\mathbf{x}\left[{\mathbf{n}}\right]$ – const double
Input

On entry: the components of the point $x$ at which the functions must be evaluated.

3:
$\mathbf{fvec}\left[{\mathbf{n}}\right]$ – double
Output

On exit: the function values
${f}_{k}\left(x\right)$ (unless
iflag is set to a negative value by
f).

4:
$\mathbf{comm}$ – Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to
f.
 user – double *
 iuser – Integer *
 p – Pointer
The type Pointer will be
void *. Before calling
c05mbc you may allocate memory and initialize these pointers with various quantities for use by
f when called from
c05mbc (see
Section 3.1.1 in the Introduction to the NAG Library CL Interface).

5:
$\mathbf{iflag}$ – Integer *
Input/Output

On entry: ${\mathbf{iflag}}\ge 0$.
On exit: in general,
iflag should not be reset by
f. If, however, you wish to terminate execution (perhaps because some illegal point
x has been reached),
iflag should be set to a negative integer. This value will be returned through
fail.
Note: f should not return floatingpoint NaN (Not a Number) or infinity values, since these are not handled by
c05mbc. If your code inadvertently
does return any NaNs or infinities,
c05mbc is likely to produce unexpected results.

2:
$\mathbf{n}$ – Integer
Input

On entry: $n$, the number of equations.
Constraint:
${\mathbf{n}}>0$.

3:
$\mathbf{x}\left[{\mathbf{n}}\right]$ – double
Input/Output

On entry: an initial guess at the solution vector, ${\hat{x}}_{0}$.
On exit: the final estimate of the solution vector.

4:
$\mathbf{fvec}\left[{\mathbf{n}}\right]$ – double
Output

On exit: the function values at the final point,
x.

5:
$\mathbf{atol}$ – double
Input

On entry: the absolute convergence criterion; see
rtol.
Suggested value:
$\sqrt{\epsilon}$, where
$\epsilon $ is the
machine precision returned by
X02AJC.
Constraint:
${\mathbf{atol}}\ge 0.0$.

6:
$\mathbf{rtol}$ – double
Input

On entry: the relative convergence criterion. At each iteration $\Vert f\left({\hat{x}}_{i}\right)\Vert $ is computed. The iteration is deemed to have converged if $\Vert f\left({\hat{x}}_{i}\right)\Vert \le \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{atol}},{\mathbf{rtol}}\times \Vert f\left({\hat{x}}_{0}\right)\Vert \right)$.
Suggested value:
$\sqrt{\epsilon}$, where
$\epsilon $ is the
machine precision returned by
X02AJC.
Constraint:
${\mathbf{rtol}}\ge 0.0$.

7:
$\mathbf{m}$ – Integer
Input

On entry: $m$, the number of previous iterates to use in Anderson acceleration. If $m=0$, Anderson acceleration is not used.
Suggested value:
${\mathbf{m}}=4$.
Constraint:
$0\le {\mathbf{m}}\le {\mathbf{n}}$.

8:
$\mathbf{cndtol}$ – double
Input

On entry: the maximum allowable condition number for the triangular
$QR$ factor generated during Anderson acceleration. At each iteration, if the condition number exceeds
cndtol, columns are deleted until it is sufficiently small.
If ${\mathbf{cndtol}}=0.0$, no condition number tests are performed.
Suggested value:
${\mathbf{cndtol}}=0.0$. If condition number tests are required, a suggested value is ${\mathbf{cndtol}}=1.0/\sqrt{\epsilon}$.
Constraint:
${\mathbf{cndtol}}\ge 0.0$.

9:
$\mathbf{astart}$ – Integer
Input

On entry: the number of iterations by which to delay the start of Anderson acceleration.
Suggested value:
${\mathbf{astart}}=0$.
Constraint:
${\mathbf{astart}}\ge 0$.

10:
$\mathbf{comm}$ – Nag_Comm *

The NAG communication argument (see
Section 3.1.1 in the Introduction to the NAG Library CL Interface).

11:
$\mathbf{fail}$ – NagError *
Input/Output

The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
 NE_ALLOC_FAIL

Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
 NE_BAD_PARAM

On entry, argument $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_CONVERGENCE

An error occurred in evaluating the
$QR$ decomposition during Anderson acceleration. This may be due to slow convergence of the iteration. Try setting the value of
cndtol. If condition number tests are already performed, try decreasing
cndtol.
 NE_DIVERGENCE

The iteration has diverged and subsequent iterates are too large to be computed in floatingpoint arithmetic.
 NE_INT

On entry, ${\mathbf{astart}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{astart}}\ge 0$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}>0$.
 NE_INT_2

On entry, ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$ and ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: $0\le {\mathbf{m}}\le {\mathbf{n}}$.
 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.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
 NE_NO_IMPROVEMENT

The iteration is not making good progress. This failure exit may indicate that the system does not have a zero, or that the solution is very close to the origin. Rerunning c05mbc from a different starting point may avoid the region of difficulty.
 NE_NO_LICENCE

Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
 NE_REAL

On entry, ${\mathbf{atol}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{atol}}\ge 0.0$.
On entry, ${\mathbf{cndtol}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{cndtol}}\ge 0.0$.
On entry, ${\mathbf{rtol}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{rtol}}\ge 0.0$.
 NE_TOO_MANY_FEVALS

There have been at least
$200\times \left({\mathbf{n}}+1\right)$ calls to
f. Consider restarting the calculation from the point held in
x.
 NE_USER_STOP

Termination requested in
f.
7
Accuracy
There are no theoretical guarantees of global or local convergence for Anderson acceleration. However, extensive numerical tests show that, in practice, Anderson acceleration leads to significant improvements over the underlying fixedpoint methods (which may only converge linearly), and in some cases can even alleviate divergence.
At each iteration,
c05mbc checks whether
$\Vert f\left({\hat{x}}_{i}\right)\Vert \le \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{atol}},{\mathbf{rtol}}\times \Vert f\left({\hat{x}}_{0}\right)\Vert \right)$. If the inequality is satisfied, then the iteration is deemed to have converged. The validity of the answer may be checked by inspecting the value of
fvec on exit from
c05mbc.
8
Parallelism and Performance
c05mbc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
c05mbc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
During each iteration, Anderson acceleration updates the factors of a $QR$ decomposition and uses the decomposition to solve a linear least squares problem. This involves an additional $\mathit{O}\left(mn\right)$ floatingpoint operations per iteration compared with the unaccelerated fixedpoint iteration.
c05mdc also performs a fixedpoint iteration with Anderson acceleration. It has a reverse communication interface, so may be preferred to
c05mbc when function evaluations are difficult to encapsulate in a function argument.
10
Example
This example determines the values
${x}_{1},\dots ,{x}_{4}$ which satisfy the equations
10.1
Program Text
10.2
Program Data
None.
10.3
Program Results