Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_interp_1d_ratnl_eval (e01rb)

## Purpose

nag_interp_1d_ratnl_eval (e01rb) evaluates continued fractions of the form produced by nag_interp_1d_ratnl (e01ra).

## Syntax

[f, ifail] = e01rb(a, u, x, 'm', m)
[f, ifail] = nag_interp_1d_ratnl_eval(a, u, x, 'm', m)

## Description

nag_interp_1d_ratnl_eval (e01rb) evaluates the continued fraction
 $Rx=a1+Rmx$
where
 $Rix=am-i+ 2x-um-i+ 1 1+Ri- 1x , for ​ i=m,m- 1,…,2.$
and
 $R1x=0$
for a prescribed value of $x$. nag_interp_1d_ratnl_eval (e01rb) is intended to be used to evaluate the continued fraction representation (of an interpolatory rational function) produced by nag_interp_1d_ratnl (e01ra).

## References

Graves–Morris P R and Hopkins T R (1981) Reliable rational interpolation Numer. Math. 36 111–128

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{a}\left({\mathbf{m}}\right)$ – double array
${\mathbf{a}}\left(\mathit{j}\right)$ must be set to the value of the parameter ${a}_{\mathit{j}}$ in the continued fraction, for $\mathit{j}=1,2,\dots ,m$.
2:     $\mathrm{u}\left({\mathbf{m}}\right)$ – double array
${\mathbf{u}}\left(\mathit{j}\right)$ must be set to the value of the parameter ${u}_{\mathit{j}}$ in the continued fraction, for $\mathit{j}=1,2,\dots ,m-1$. (The element ${\mathbf{u}}\left(m\right)$ is not used).
3:     $\mathrm{x}$ – double scalar
The value of $x$ at which the continued fraction is to be evaluated.

### Optional Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Default: the dimension of the arrays a, u. (An error is raised if these dimensions are not equal.)
$m$, the number of terms in the continued fraction.
Constraint: ${\mathbf{m}}\ge 1$.

### Output Parameters

1:     $\mathrm{f}$ – double scalar
The value of the continued fraction corresponding to the value of $x$.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
The value of x corresponds to a pole of $R\left(x\right)$ or is so close that an overflow is likely to ensue.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

See Accuracy in nag_interp_1d_ratnl (e01ra).

The time taken by nag_interp_1d_ratnl_eval (e01rb) is approximately proportional to $m$.

## Example

This example reads in the arguments ${a}_{j}$ and ${u}_{j}$ of a continued fraction (as determined by the example for nag_interp_1d_ratnl (e01ra)) and evaluates the continued fraction at a point $x$.
```function e01rb_example

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

% Calculate rational approximation coefficients
x = [0:4];
f = [4   2   4   7   10.4];

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

% Evaluate at single point
x = 6;
[f, ifail] = e01rb( ...
a, u, x, 'm', m);

fprintf('x    = %12.4e\n',x);
fprintf('R(x) = %12.4e\n',f);

```
```e01rb example results

x    =   6.0000e+00
R(x) =   1.7714e+01
```