hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_interp_1d_ratnl (e01ra)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_interp_1d_ratnl (e01ra) produces, from a set of function values and corresponding abscissae, the coefficients of an interpolating rational function expressed in continued fraction form.


[m, a, u, ifail] = e01ra(x, f, 'n', n)
[m, a, u, ifail] = nag_interp_1d_ratnl(x, f, 'n', n)


nag_interp_1d_ratnl (e01ra) produces the parameters of a rational function Rx which assumes prescribed values fi at prescribed values xi of the independent variable x, for i=1,2,,n. More specifically, nag_interp_1d_ratnl (e01ra) determines the parameters aj, for j=1,2,,m and uj, for j=1,2,,m-1, in the continued fraction
Rx=a1+Rmx (1)
Rix=am-i+ 2x-um-i+ 1 1+Ri- 1x ,   for ​ i=m,m- 1,,2,  
such that Rxi=fi, for i=1,2,,n. The value of m in (1) is determined by the function; normally m=n. The values of uj form a reordered subset of the values of xi 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 x can be carried out using nag_interp_1d_ratnl_eval (e01rb).
The computational method employed in nag_interp_1d_ratnl (e01ra) 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


Compulsory Input Parameters

1:     xn – double array
xi must be set to the value of the ith data abscissa, xi, for i=1,2,,n.
Constraint: the xi must be distinct.
2:     fn – double array
fi must be set to the value of the data ordinate, fi, corresponding to xi, for i=1,2,,n.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the arrays x, f. (An error is raised if these dimensions are not equal.)
n, the number of data points.
Constraint: n>0.

Output Parameters

1:     m int64int32nag_int scalar
m, the number of terms in the continued fraction representation of Rx.
2:     an – double array
aj contains the value of the parameter aj in Rx, for j=1,2,,m. The remaining elements of a, if any, are set to zero.
3:     un – double array
uj contains the value of the parameter uj in Rx, for j=1,2,,m-1. The uj are a permuted subset of the elements of x. The remaining n-m+1 locations contain a permutation of the remaining xi, which can be ignored.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry,n0.
At least one pair of the values xi are equal (or so nearly so that a subsequent division will inevitably cause overflow).
A continued fraction of the required form does not exist.
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


Usually, it is not the accuracy of the coefficients produced by this function which is of prime interest, but rather the accuracy of the value of Rx that is produced by the associated function nag_interp_1d_ratnl_eval (e01rb) when subsequently it evaluates the continued fraction (1) for a given value of x. 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.
1. 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 -1.0 to +1.0 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.
2. To check the effect of rounding errors engendered in the functions themselves, nag_interp_1d_ratnl (e01ra) should be re-entered with x1 interchanged with xi and f1 with fi, i1. This will produce a completely different vector a and a reordered vector u, but any change in the value of Rx subsequently produced by nag_interp_1d_ratnl_eval (e01rb) will be due solely to rounding error.
3. 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 functions 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 2,3, nearest points until, hopefully, successive values of Rx for the given x agree to the required accuracy.

Further Comments

The time taken by nag_interp_1d_ratnl (e01ra) is approximately proportional to n2.
The continued fraction (1) when expanded produces a rational function in x, 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 function be used without subsequent entry (or entries) to nag_interp_1d_ratnl_eval (e01rb).


This example reads in the abscissae and ordinates of 5 data points and prints the arguments aj and uj of a rational function which interpolates them.
function e01ra_example

fprintf('e01ra example results\n\n');

x = [0:4];
f = [4   2   4   7   10.4];

[m, a, u, ifail] = e01ra( ...
                          x, f);

disp('Reorder subset, u:');
disp('Thiele coefficients, a:');

e01ra example results

Reorder subset, u:
     0     3     1

Thiele coefficients, a:
    4.0000    1.0000    0.7500   -1.0000

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015