NAG Library Routine Document
c05mdf (sys_func_aa_rcomm)
1
Purpose
c05mdf is a comprehensive reverse communication routine that finds a solution of a system of nonlinear equations by fixed-point iteration using Anderson acceleration.
2
Specification
Fortran Interface
Subroutine c05mdf ( |
irevcm, n, x, fvec, atol, rtol, m, cndtol, astart, iwsav, rwsav, ifail) |
Integer, Intent (In) | :: | n, m, astart | Integer, Intent (Inout) | :: | irevcm, iwsav(14+m), ifail | Real (Kind=nag_wp), Intent (In) | :: | atol, rtol, cndtol | Real (Kind=nag_wp), Intent (Inout) | :: | x(n), fvec(n), rwsav(2*m*n+m*m+m+2*n+1+min(m,1)*max(n,3*m)) |
|
C Header Interface
#include <nagmk26.h>
void |
c05mdf_ (Integer *irevcm, const Integer *n, double x[], double fvec[], const double *atol, const double *rtol, const Integer *m, const double *cndtol, const Integer *astart, Integer iwsav[], double rwsav[], Integer *ifail) |
|
3
Description
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 QR decomposition, which is updated at each iteration.
You are free to choose any value for , provided . A typical choice is .
4
References
Anderson D G (1965) Iterative Procedures for Nonlinear Integral Equations J. Assoc. Comput. Mach. 12 547–560
5
Arguments
Note: this routine 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 than fvec must remain unchanged.
- 1: – IntegerInput/Output
-
On initial entry: must have the value .
On intermediate exit:
specifies what action you must take before re-entering
c05mdf with
irevcm unchanged. 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 c05mdf, fvec must contain the function values .
On final exit: and the algorithm has terminated.
Constraint:
, or .
Note: any values you return to c05mdf 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 c05mdf. If your code does inadvertently return any NaNs or infinities, c05mdf is likely to produce unexpected results.
- 2: – IntegerInput
-
On entry: , the number of equations.
Constraint:
.
- 3: – Real (Kind=nag_wp) arrayInput/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: – Real (Kind=nag_wp) arrayInput/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: – Real (Kind=nag_wp)Input
-
On initial entry: the absolute convergence criterion; see below.
Suggested value:
, where
is the
machine precision returned by
x02ajf.
Constraint:
.
- 6: – Real (Kind=nag_wp)Input
-
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
x02ajf.
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: – Real (Kind=nag_wp)Input
-
On initial 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 , 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: – Integer arrayCommunication Array
- 11: – Real (Kind=nag_wp) arrayCommunication Array
-
The arrays
iwsav and
rwsav must not be altered between calls to
c05mdf.
The size of
rwsav is bounded above by
.
- 12: – IntegerInput/Output
-
On initial entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, because for this routine the values of the output arguments may be useful even if
on exit, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On final exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On initial entry, .
Constraint: .
On intermediate entry, .
Constraint: or .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
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.
-
The iteration is not making good progress, as measured by the reduction in the norm of in the last iterations.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
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 fixed-point methods (which may only converge linearly), and in some cases can even alleviate divergence.
At each iteration,
c05mdf 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
c05mdf.
8
Parallelism and Performance
c05mdf 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 routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific 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 floating-point operations per iteration compared with the unaccelerated fixed-point iteration.
c05mdf 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 c05mdf is called. This is illustrated in the example program below.
10
Example
This example determines the values
which satisfy the equations
10.1
Program Text
Program Text (c05mdfe.f90)
10.2
Program Data
None.
10.3
Program Results
Program Results (c05mdfe.r)