c05mdc is a comprehensive reverse communication function that finds a solution of a system of nonlinear equations by fixed-point iteration using Anderson acceleration.
The function may be called by the names: c05mdc, nag_roots_sys_func_aa_rcomm or nag_zero_nonlin_eqns_aa_rcomm.
3Description
The system of equations is defined as:
This homogeneous system can readily be reformulated as
A standard fixed-point iteration approach is to start with an approximate solution and repeatedly apply the function until possible convergence; i.e., , until
. Anderson acceleration uses up to previous values of to obtain an improved estimate . If a standard fixed-point iteration converges, then Anderson acceleration usually results in convergence in far fewer iterations (and, therefore, using far fewer function evaluations).
Full details of Anderson acceleration are provided in Anderson (1965). In summary, the previous iterates are combined to form a succession of least squares problems. These are solved using a decomposition, which is updated at each iteration.
You are free to choose any value for , provided . A typical choice is .
Anderson acceleration is particularly useful if evaluating is very expensive, in which case functions such as c05rdc or c05qdc, which require the Jacobian or its approximation, may perform poorly.
4References
Anderson D G (1965) Iterative Procedures for Nonlinear Integral Equations J. Assoc. Comput. Mach.12 547–560
5Arguments
Note: this function uses reverse communication. Its use involves an initial entry, intermediate exits and re-entries, and a final exit, as indicated by the argument irevcm. Between intermediate exits and re-entries, all arguments other thanfvec must remain unchanged.
1: – Integer *Input/Output
On initial entry: must have the value .
On intermediate exit:
specifies what action you must take before re-entering c05mdc with irevcmunchanged. The value of irevcm should be interpreted as follows:
Indicates the start of a new iteration. No action is required by you, but x and fvec are available for printing, and a limit on the number of iterations can be applied.
Indicates that before re-entry to c05mdc, fvec must contain the function values .
On final exit: and the algorithm has terminated.
Constraint:
, or .
Note: any values you return to c05mdc as part of the reverse communication procedure should not include floating-point NaN (Not a Number) or infinity values, since these are not handled by c05mdc. If your code inadvertently does return any NaNs or infinities, c05mdc is likely to produce unexpected results.
2: – IntegerInput
On entry: , the number of equations.
Constraint:
.
3: – doubleInput/Output
On initial entry: an initial guess at the solution vector, .
On intermediate exit:
contains the current point.
On final exit: the final estimate of the solution vector.
4: – doubleInput/Output
On initial entry: need not be set.
On intermediate re-entry: if , fvec must not be changed.
If , fvec must be set to the values of the functions computed at the current point x, .
On final exit: the function values at the final point, x.
5: – doubleInput
On initial entry: the absolute convergence criterion; see rtol.
Suggested value:
, where is the machine precision returned by X02AJC.
Constraint:
.
6: – doubleInput
On initial entry: the relative convergence criterion. At each iteration is computed. The iteration is deemed to have converged if .
Suggested value:
, where is the machine precision returned by X02AJC.
Constraint:
.
7: – IntegerInput
On initial entry: , the number of previous iterates to use in Anderson acceleration. If , Anderson acceleration is not used.
Suggested value:
.
Constraint:
.
8: – doubleInput
On initial entry: the maximum allowable condition number for the triangular factor generated during Anderson acceleration. At each iteration, if the condition number exceeds cndtol, columns are deleted until it is sufficiently small.
If , no condition number tests are performed.
Suggested value:
. If condition number tests are required, a suggested value is .
Constraint:
.
9: – IntegerInput
On initial entry: the number of iterations by which to delay the start of Anderson acceleration.
Suggested value:
.
Constraint:
.
10: – IntegerCommunication Array
11: – doubleCommunication Array
The arrays iwsav and rwsav MUST NOT be altered between calls to c05mdc.
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error 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 had an illegal value.
NE_CONVERGENCE
An error occurred in evaluating the 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 floating-point arithmetic.
NE_INT
On entry, . Constraint: .
On entry, .
Constraint: .
On initial entry, . Constraint: .
On intermediate entry, . Constraint: or .
NE_INT_2
On entry, and .
Constraint: .
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, as measured by the reduction in the norm of in the last iterations.
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, . Constraint: .
On entry, . Constraint: .
On entry, . Constraint: .
7Accuracy
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 fixed-point methods (which may only converge linearly), and in some cases can even alleviate divergence.
At each iteration, c05mdc checks whether . 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 final exit from c05mdc.
8Parallelism and Performance
c05mdc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
c05mdc 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 implementation-specific information.
9Further Comments
During each iteration, Anderson acceleration updates the factors of a decomposition and uses the decomposition to solve a linear least squares problem. This involves an additional floating-point operations per iteration compared with the unaccelerated fixed-point iteration.
c05mdc does not count the number of iterations. Thus, it is up to you to add a limit on the number of iterations and check if this limit has been exceeded when c05mdc is called. This is illustrated in the example program below.
10Example
This example determines the values which satisfy the equations