c05rd is a comprehensive reverse communication method that finds a solution of a system of nonlinear equations by a modification of the Powell hybrid method. You must provide the Jacobian.
Syntax
C# |
---|
public static void c05rd( ref int irevcm, int n, double[] x, double[] fvec, double[,] fjac, double xtol, int mode, double[] diag, double factor, double[] r, double[] qtf, C05..::..c05rdCommunications communications, out int ifail ) |
Visual Basic |
---|
Public Shared Sub c05rd ( _ ByRef irevcm As Integer, _ n As Integer, _ x As Double(), _ fvec As Double(), _ fjac As Double(,), _ xtol As Double, _ mode As Integer, _ diag As Double(), _ factor As Double, _ r As Double(), _ qtf As Double(), _ communications As C05..::..c05rdCommunications, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void c05rd( int% irevcm, int n, array<double>^ x, array<double>^ fvec, array<double,2>^ fjac, double xtol, int mode, array<double>^ diag, double factor, array<double>^ r, array<double>^ qtf, C05..::..c05rdCommunications^ communications, [OutAttribute] int% ifail ) |
F# |
---|
static member c05rd : irevcm : int byref * n : int * x : float[] * fvec : float[] * fjac : float[,] * xtol : float * mode : int * diag : float[] * factor : float * r : float[] * qtf : float[] * communications : C05..::..c05rdCommunications * ifail : int byref -> unit |
Parameters
- irevcm
- Type: System..::..Int32%On initial entry: must have the value .On intermediate exit: specifies what action you must take before re-entering c05rd with irevcm unchanged. The value of irevcm should be interpreted as follows:On final exit: , and the algorithm has terminated.Constraint: , , or .
- n
- Type: System..::..Int32On entry: , the number of equations.Constraint: .
- x
- Type: array<System..::..Double>[]()[][]An array of size [n]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.
- fvec
- Type: array<System..::..Double>[]()[][]An array of size [n]On initial entry: need not be set.On intermediate re-entry: if , fvec must not be changed.On final exit: the function values at the final point, x.
- fjac
- Type: array<System..::..Double,2>[,](,)[,][,]On initial entry: need not be set.On intermediate re-entry: if , fjac must not be changed.If , must contain the value of at the point , for and .On final exit: the orthogonal matrix produced by the factorization of the final approximate Jacobian.
- xtol
- Type: System..::..DoubleOn initial entry: the accuracy in x to which the solution is required.Suggested value: , where is the machine precision returned by x02aj.Constraint: .
- mode
- Type: System..::..Int32On initial entry: indicates whether or not you have provided scaling factors in diag.If the scaling must have been supplied in diag.Otherwise, if , the variables will be scaled internally.Constraint: or .
- diag
- Type: array<System..::..Double>[]()[][]An array of size [n]On initial entry: if , diag must contain multiplicative scale factors for the variables.If , diag need not be set.Constraint: if , , for .On intermediate exit: diag must not be changed.On final exit: the scale factors actually used (computed internally if ).
- factor
- Type: System..::..DoubleOn initial entry: a quantity to be used in determining the initial step bound. In most cases, factor should lie between and . (The step bound is if this is nonzero; otherwise the bound is factor.)Suggested value: .Constraint: .
- r
- Type: array<System..::..Double>[]()[][]An array of size []On initial entry: need not be set.On intermediate exit: must not be changed.On final exit: the upper triangular matrix produced by the factorization of the final approximate Jacobian, stored row-wise.
- qtf
- Type: array<System..::..Double>[]()[][]An array of size [n]On initial entry: need not be set.On intermediate exit: must not be changed.On final exit: the vector .
- communications
- Type: NagLibrary..::..C05..::..c05rdCommunicationsAn Object of type C05.c05rdCommunications.
- ifail
- Type: System..::..Int32%On initial entry: ifail must be set to , . If you are unfamiliar with this parameter you should refer to Library Overview 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 method the values of the output parameters 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 method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
The system of equations is defined as:
c05rd is based on the MINPACK routine HYBRJ (see Moré et al. (1980)). It chooses the correction at each step as a convex combination of the Newton and scaled gradient directions. The Jacobian is updated by the rank-1 method of Broyden. For more details see Powell (1970).
References
Moré J J, Garbow B S and Hillstrom K E (1980) User guide for MINPACK-1 Technical Report ANL-80-74 Argonne National Laboratory
Powell M J D (1970) A hybrid method for nonlinear algebraic equations Numerical Methods for Nonlinear Algebraic Equations (ed P Rabinowitz) Gordon and Breach
Error Indicators and Warnings
Errors or warnings detected by the method:
-
On entry, .
Constraint: , , or .
-
No further improvement in the solution is possible. xtol is too small: .
-
The iteration is not making good progress, as measured by the improvement from the last Jacobian evaluations. This failure exit may indicate that the system does not have a zero, or that the solution is very close to the origin (see [Accuracy]). Otherwise, rerunning c05rd from a different starting point may avoid the region of difficulty.
-
The iteration is not making good progress, as measured by the improvement from the last iterations. This failure exit may indicate that the system does not have a zero, or that the solution is very close to the origin (see [Accuracy]). Otherwise, rerunning c05rd from a different starting point may avoid the region of difficulty.
-
On entry, .
Constraint: .
-
On entry, .
Constraint: .
-
On entry, .
Constraint: or .
-
On entry, .
Constraint: .
-
On entry, and diag contained a non-positive element.
Accuracy
If is the true solution and denotes the diagonal matrix whose entries are defined by the array diag, then c05rd tries to ensure that
If this condition is satisfied with , then the larger components of have significant decimal digits. There is a danger that the smaller components of may have large relative errors, but the fast rate of convergence of c05rd usually obviates this possibility.
If xtol is less than machine precision and the above test is satisfied with the machine precision in place of xtol, then the method exits with .
Note: this convergence test is based purely on relative error, and may not indicate convergence if the solution is very close to the origin.
The convergence test assumes that the functions and the Jacobian are coded consistently and that the functions are reasonably well behaved. If these conditions are not satisfied, then c05rd may incorrectly indicate convergence. The coding of the Jacobian can be checked using c05zd. If the Jacobian is coded correctly, then the validity of the answer can be checked by rerunning c05rd with a lower value for xtol.
Parallelism and Performance
None.
Further Comments
The time required by c05rd to solve a given problem depends on , the behaviour of the functions, the accuracy requested and the starting point. The number of arithmetic operations executed by c05rd is approximately to process each evaluation of the functions and approximately to process each evaluation of the Jacobian. The timing of c05rd is strongly influenced by the time spent evaluating the functions.
Ideally the problem should be scaled so that, at the solution, the function values are of comparable magnitude.
Example
This example determines the values which satisfy the tridiagonal equations: