NAG Library Routine Document
E01RAF produces, from a set of function values and corresponding abscissae, the coefficients of an interpolating rational function expressed in continued fraction form.
||N, M, IW(N), IFAIL
||X(N), F(N), A(N), U(N)
E01RAF produces the parameters of a rational function
which assumes prescribed values
at prescribed values
of the independent variable
. More specifically, E01RAF determines the parameters
, in the continued fraction
. The value of
is determined by the routine; normally
. The values of
form a reordered subset of the values of
and their ordering is designed to ensure that a representation of the form (1)
is determined whenever one exists.
The subsequent evaluation of (1)
for given values of
can be carried out using E01RBF
The computational method employed in E01RAF is the modification of the Thacher–Tukey algorithm described in Graves–Morris and Hopkins (1981)
Graves–Morris P R and Hopkins T R (1981) Reliable rational interpolation Numer. Math. 36 111–128
- 1: N – INTEGERInput
On entry: , the number of data points.
- 2: X(N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to the value of the th data abscissa, , for .
the must be distinct.
- 3: F(N) – REAL (KIND=nag_wp) arrayInput
On entry: must be set to the value of the data ordinate, , corresponding to , for .
- 4: M – INTEGEROutput
On exit: , the number of terms in the continued fraction representation of .
- 5: A(N) – REAL (KIND=nag_wp) arrayOutput
contains the value of the parameter
. The remaining elements of A
, if any, are set to zero.
- 6: U(N) – REAL (KIND=nag_wp) arrayOutput
contains the value of the parameter
are a permuted subset of the elements of X
. The remaining
locations contain a permutation of the remaining
, which can be ignored.
- 7: IW(N) – INTEGER arrayWorkspace
- 8: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction 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, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
At least one pair of the values are equal (or so nearly so that a subsequent division will inevitably cause overflow).
A continued fraction of the required form does not exist.
Usually, it is not the accuracy of the coefficients produced by this routine which is of prime interest, but rather the accuracy of the value of
that is produced by the associated routine E01RBF
when subsequently it evaluates the continued fraction (1)
for a given value of
. This final accuracy will depend mainly on the nature of the interpolation being performed. If interpolation of a ‘well-behaved smooth’ function is attempted (and provided the data adequately represents the function), high accuracy will normally ensue, but, if the function is not so ‘smooth’ or extrapolation is being attempted, high accuracy is much less likely. Indeed, in extreme cases, results can be highly inaccurate.
There is no built-in test of accuracy but several courses are open to you to prevent the production or the acceptance of inaccurate results.
- If the origin of a variable is well outside the range of its data values, the origin should be shifted to correct this; and, if the new data values are still excessively large or small, scaling to make the largest value of the order of unity is recommended. Thus, normalization to the range to is ideal. This applies particularly to the independent variable; for the dependent variable, the removal of leading figures which are common to all the data values will usually suffice.
- To check the effect of rounding errors engendered in the routines themselves, E01RAF should be re-entered with interchanged with and with , . This will produce a completely different vector and a reordered vector , but any change in the value of subsequently produced by E01RBF will be due solely to rounding error.
- Even if the data consist of calculated values of a formal mathematical function, it is only in exceptional circumstances that bounds for the interpolation error (the difference between the true value of the function underlying the data and the value which would be produced by the two routines if exact arithmetic were used) can be derived that are sufficiently precise to be of practical use. Consequently, you are recommended to rely on comparison checks: if extra data points are available, the calculation may be repeated with one or more data pairs added or exchanged, or alternatively, one of the original data pairs may be omitted. If the algorithms are being used for extrapolation, the calculations should be performed repeatedly with the nearest points until, hopefully, successive values of for the given agree to the required accuracy.
The time taken by E01RAF is approximately proportional to .
The continued fraction (1)
when expanded produces a rational function in
, the degree of whose numerator is either equal to or exceeds by unity that of the denominator. Only if this rather special form of interpolatory rational function is needed explicitly, would this routine be used without subsequent entry (or entries) to E01RBF
This example reads in the abscissae and ordinates of data points and prints the parameters and of a rational function which interpolates them.
9.1 Program Text
Program Text (e01rafe.f90)
9.2 Program Data
Program Data (e01rafe.d)
9.3 Program Results
Program Results (e01rafe.r)