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

## Purpose

nag_fit_pade_eval (e02rb) evaluates a rational function at a user-supplied point, given the numerator and denominator coefficients.

## Syntax

[ans, ifail] = e02rb(a, b, x, 'ia', ia, 'ib', ib)
[ans, ifail] = nag_fit_pade_eval(a, b, x, 'ia', ia, 'ib', ib)

## Description

Given a real value x$x$ and the coefficients aj${a}_{j}$, for j = 0,1,,l$\mathit{j}=0,1,\dots ,l$ and bk${b}_{k}$, for k = 0,1,,m$\mathit{k}=0,1,\dots ,m$, nag_fit_pade_eval (e02rb) evaluates the rational function
 ( ∑ j = 0lajxj)/( ∑ k = 0mbkxk). $∑j=0lajxj ∑k=0mbkxk .$
using nested multiplication (see Conte and de Boor (1965)).
A particular use of nag_fit_pade_eval (e02rb) is to compute values of the Padé approximants determined by nag_fit_pade_app (e02ra).

## References

Conte S D and de Boor C (1965) Elementary Numerical Analysis McGraw–Hill
Peters G and Wilkinson J H (1971) Practical problems arising in the solution of polynomial equations J. Inst. Maths. Applics. 8 16–35

## Parameters

### Compulsory Input Parameters

1:     a(ia) – double array
ia, the dimension of the array, must satisfy the constraint ia1${\mathbf{ia}}\ge 1$.
a(j + 1)${\mathbf{a}}\left(\mathit{j}+1\right)$, for j = 1,2,,l + 1$\mathit{j}=1,2,\dots ,l+1$, must contain the value of the coefficient aj${a}_{\mathit{j}}$ in the numerator of the rational function.
2:     b(ib) – double array
ib, the dimension of the array, must satisfy the constraint ib1${\mathbf{ib}}\ge 1$.
b(k + 1)${\mathbf{b}}\left(\mathit{k}+1\right)$, for k = 1,2,,m + 1$\mathit{k}=1,2,\dots ,m+1$, must contain the value of the coefficient bk${b}_{k}$ in the denominator of the rational function.
Constraint: if ib = 1${\mathbf{ib}}=1$, b(1)0.0${\mathbf{b}}\left(1\right)\ne 0.0$.
3:     x – double scalar
The point x$x$ at which the rational function is to be evaluated.

### Optional Input Parameters

1:     ia – int64int32nag_int scalar
Default: The dimension of the array a.
The value of l + 1$l+1$, where l$l$ is the degree of the numerator.
Constraint: ia1${\mathbf{ia}}\ge 1$.
2:     ib – int64int32nag_int scalar
Default: The dimension of the array b.
The value of m + 1$m+1$, where m$m$ is the degree of the denominator.
Constraint: ib1${\mathbf{ib}}\ge 1$.

None.

### Output Parameters

1:     ans – double scalar
The result of evaluating the rational function at the given point x$x$.
2:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
The rational function is being evaluated at or near a pole.
ifail = 2${\mathbf{ifail}}=2$
 On entry, ia < 1${\mathbf{ia}}<1$, or ib < 1${\mathbf{ib}}<1$, or b(1) = 0.0${\mathbf{b}}\left(1\right)=0.0$ when ib = 1${\mathbf{ib}}=1$ (so the denominator is identically zero).

## Accuracy

A running error analysis for polynomial evaluation by nested multiplication using the recurrence suggested by Kahan (see Peters and Wilkinson (1971)) is used to detect whether you are attempting to evaluate the approximant at or near a pole.

The time taken is approximately proportional to l + m$l+m$.

## Example

```function nag_fit_pade_eval_example
a = [1;
0.5;
0.1071428571428577;
0.011904761904762;
0.0005952380952381046];
b = [1;
-0.5;
0.1071428571428566;
-0.01190476190476179;
0.0005952380952380861];
x = 0.1;
[ans, ifail] = nag_fit_pade_eval(a, b, x)
```
```

ans =

1.1052

ifail =

0

```
```function e02rb_example
a = [1;
0.5;
0.1071428571428577;
0.011904761904762;
0.0005952380952381046];
b = [1;
-0.5;
0.1071428571428566;
-0.01190476190476179;
0.0005952380952380861];
x = 0.1;
[ans, ifail] = e02rb(a, b, x)
```
```

ans =

1.1052

ifail =

0

```