naginterfaces.library.roots.contfn_cntin_rcomm¶
- naginterfaces.library.roots.contfn_cntin_rcomm(x, fx, tol, ir, comm, ind, scal=1.0536712127723509e-08)[source]¶
contfn_cntin_rcomm
attempts to locate a zero of a continuous function using a continuation method based on a secant iteration. It uses reverse communication for evaluating the function.For full information please refer to the NAG Library document for c05ax
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/c05/c05axf.html
- Parameters
- xfloat
On initial entry: an initial approximation to the zero.
- fxfloat
On initial entry: if , need not be set.
If , must contain for the initial value of .
On intermediate entry: must contain for the current value of .
- tolfloat
On initial entry: a value that controls the accuracy to which the zero is determined. is used in determining the convergence of the secant iteration used at each stage of the continuation process. It is used directly when solving the last problem ( in Notes), and is used for the problem defined by , . Convergence to the accuracy specified by is not guaranteed, and so you are recommended to find the zero using at least two values for to check the accuracy obtained.
- irint
On initial entry: indicates the type of error test required, as follows. Solving the problem defined by , , involves computing a sequence of secant iterates . This sequence will be considered to have converged only if:
for ,
for ,
for ,
for some ; here is either or as discussed above.
Note that there are other subsidiary conditions (not given here) which must also be satisfied before the secant iteration is considered to have converged.
- commdict, communication object, modified in place
Communication structure.
On initial entry: need not be set.
- indint
On initial entry: must be set to or .
need not be set.
must contain .
- scalfloat, optional
On initial entry: a factor for use in determining a significant approximation to the derivative of at , the initial value. A number of difference approximations to are calculated using
where and has the same sign as . A significance (cancellation) check is made on each difference approximation and the approximation is rejected if insignificant.
- Returns
- xfloat
On intermediate exit: the point at which must be evaluated before re-entry to the function.
On final exit: the final approximation to the zero.
- indint
On intermediate exit: contains , or . The calling program must evaluate at , storing the result in , and re-enter
contfn_cntin_rcomm
with all other arguments unchanged.On final exit: contains .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: , or .
- (errno )
On initial entry, .
Constraint: or .
- (errno )
On intermediate entry, .
Constraint: , or .
- (errno )
On entry, .
Constraint: (to machine accuracy).
- (errno )
Significant derivatives of cannot be computed. This can happen when is almost constant and nonzero, for any value of .
- (errno )
Current problem in the continuation sequence cannot be solved. Perhaps the original problem had no solution or the continuation path passes through a set of insoluble problems: consider refining the initial approximation to the zero. Alternatively, is too small, and the accuracy requirement is too stringent, or too large and the initial approximation too poor.
- (errno )
Continuation away from the initial point is not possible. This error exit will usually occur if the problem has not been properly posed or the error requirement is extremely stringent.
- (errno )
Final problem (with ) cannot be solved. It is likely that too much accuracy has been requested, or that the zero is at and .
- Notes
contfn_cntin_rcomm
uses a modified version of an algorithm given in Swift and Lindfield (1978) to compute a zero of a continuous function . The algorithm used is based on a continuation method in which a sequence of problemsare solved, where (the value of is determined as the algorithm proceeds) and where is your initial estimate for the zero of . For each the current problem is solved by a robust secant iteration using the solution from earlier problems to compute an initial estimate.
You must supply an error tolerance . is used directly to control the accuracy of solution of the final problem () in the continuation method, and is used to control the accuracy in the intermediate problems ().
- References
Swift, A and Lindfield, G R, 1978, Comparison of a continuation method for the numerical solution of a single nonlinear equation, Comput. J. (21), 359–362