naginterfaces.library.numdiff.rcomm¶
- naginterfaces.library.numdiff.rcomm(xval, fval)[source]¶
rcomm
calculates a set of derivatives (up to order ) of a function at a point with respect to a single variable. A corresponding set of error estimates is also returned. Derivatives are calculated using an extension of the Neville algorithm. This function differs fromfwd()
, in that the abscissae and corresponding function values must be calculated before this function is called. The abscissae may be generated usingsample()
.For full information please refer to the NAG Library document for d04ba
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/d04/d04baf.html
- Parameters
- Returns
- derfloat, ndarray, shape
The derivative estimates.
- erestfloat, ndarray, shape
The error estimates for the derivatives.
- Raises
- NagValueError
- (errno )
The derived is below tolerance.
Derived is required. Derived .
- (errno )
On entry, the values of are not correctly spaced.
Derived .
- Notes
rcomm
provides a set of approximations:to the derivatives:
of a real valued function at a real abscissa , together with a set of error estimates:
which hopefully satisfy:
The results and are based on function values:
The abscissae and the corresponding function values should be passed into
rcomm
as the vectors and respectively. The step size is derived from the abscissae in . See Further Comments for a discussion of how the derived value of may affect the results ofrcomm
. The order in which the abscissae and function values are stored in and is irrelevant, provided that the function value at any given index corresponds to the value of the abscissa at the same index. Abscissae may be automatically generated usingsample()
if desired. For each derivativercomm
employs an extension of the Neville Algorithm (see Lyness and Moler (1969)) to obtain a selection of approximations.For example, for odd derivatives, this function calculates a set of numbers:
each of which is an approximation to . A specific approximation is of polynomial degree and is based on polynomial interpolation using function values , for . In the absence of round-off error, the better approximations would be associated with the larger values of and of . However, round-off error in function values has an increasingly contaminating effect for successively larger values of . This function proceeds to make a judicious choice between all the approximations in the following way.
For a specified value of , let:
where and , for , and let be such that , for .
This function returns:
and
where is a safety factor which has been assigned the values:
,
,
,
on the basis of performance statistics.
The even order derivatives are calculated in a precisely analogous manner.
- References
Lyness, J N and Moler, C B, 1969, Generalised Romberg methods for integrals of derivatives, Numer. Math. (14), 1–14