# NAG Library Routine Document

## 1Purpose

e02rbf evaluates a rational function at a user-supplied point, given the numerator and denominator coefficients.

## 2Specification

Fortran Interface
 Subroutine e02rbf ( a, ia, b, ib, x, ans,
 Integer, Intent (In) :: ia, ib Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: a(ia), b(ib), x Real (Kind=nag_wp), Intent (Out) :: ans
#include nagmk26.h
 void e02rbf_ (const double a[], const Integer *ia, const double b[], const Integer *ib, const double *x, double *ans, Integer *ifail)

## 3Description

Given a real value $x$ and the coefficients ${a}_{j}$, for $\mathit{j}=0,1,\dots ,l$ and ${b}_{k}$, for $\mathit{k}=0,1,\dots ,m$, e02rbf evaluates the rational function
 $∑j=0lajxj ∑k=0mbkxk .$
using nested multiplication (see Conte and de Boor (1965)).
A particular use of e02rbf is to compute values of the Padé approximants determined by e02raf.
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

## 5Arguments

1:     $\mathbf{a}\left({\mathbf{ia}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: ${\mathbf{a}}\left(\mathit{j}+1\right)$, for $\mathit{j}=1,2,\dots ,l+1$, must contain the value of the coefficient ${a}_{\mathit{j}}$ in the numerator of the rational function.
2:     $\mathbf{ia}$ – IntegerInput
On entry: the value of $l+1$, where $l$ is the degree of the numerator.
Constraint: ${\mathbf{ia}}\ge 1$.
3:     $\mathbf{b}\left({\mathbf{ib}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: ${\mathbf{b}}\left(\mathit{k}+1\right)$, for $\mathit{k}=1,2,\dots ,m+1$, must contain the value of the coefficient ${b}_{k}$ in the denominator of the rational function.
Constraint: if ${\mathbf{ib}}=1$, ${\mathbf{b}}\left(1\right)\ne 0.0$.
4:     $\mathbf{ib}$ – IntegerInput
On entry: the value of $m+1$, where $m$ is the degree of the denominator.
Constraint: ${\mathbf{ib}}\ge 1$.
5:     $\mathbf{x}$ – Real (Kind=nag_wp)Input
On entry: the point $x$ at which the rational function is to be evaluated.
6:     $\mathbf{ans}$ – Real (Kind=nag_wp)Output
On exit: the result of evaluating the rational function at the given point $x$.
7:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
The rational function is being evaluated at or near a pole.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{ia}}<1$, or ${\mathbf{ib}}<1$, or ${\mathbf{b}}\left(1\right)=0.0$ when ${\mathbf{ib}}=1$ (so the denominator is identically zero).
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

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.

## 8Parallelism and Performance

e02rbf is not threaded in any implementation.

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

## 10Example

This example first calls e02raf to calculate the $4/4$ Padé approximant to ${e}^{x}$, and then uses e02rbf to evaluate the approximant at $x=0.1,0.2,\dots ,1.0$.

### 10.1Program Text

Program Text (e02rbfe.f90)

None.

### 10.3Program Results

Program Results (e02rbfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017