NAG Library Routine Document

e02rbf (pade_eval)


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


Fortran Interface
Subroutine e02rbf ( a, ia, b, ib, x, ans, ifail)
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
C Header Interface
#include <nagmk26.h>
void  e02rbf_ (const double a[], const Integer *ia, const double b[], const Integer *ib, const double *x, double *ans, Integer *ifail)


Given a real value x and the coefficients aj, for j=0,1,,l and bk, for k=0,1,,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


1:     aia – Real (Kind=nag_wp) arrayInput
On entry: aj+1, for j=1,2,,l+1, must contain the value of the coefficient aj in the numerator of the rational function.
2:     ia – IntegerInput
On entry: the value of l+1, where l is the degree of the numerator.
Constraint: ia1.
3:     bib – Real (Kind=nag_wp) arrayInput
On entry: bk+1, for k=1,2,,m+1, must contain the value of the coefficient bk in the denominator of the rational function.
Constraint: if ib=1, b10.0.
4:     ib – IntegerInput
On entry: the value of m+1, where m is the degree of the denominator.
Constraint: ib1.
5:     x – Real (Kind=nag_wp)Input
On entry: the point x at which the rational function is to be evaluated.
6:     ans – Real (Kind=nag_wp)Output
On exit: the result of evaluating the rational function at the given point x.
7:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 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 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 -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

Error Indicators and Warnings

If on entry 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:
Evaluation at or near a pole.
On entry, ia=value.
Constraint: ia1.
On entry, ib=value.
Constraint: ib1.
The first ib entries in b are zero: ib=value.
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
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.
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.


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.

Parallelism and Performance

e02rbf is not threaded in any implementation.

Further Comments

The time taken is approximately proportional to l+m.


This example first calls e02raf to calculate the 4/4 Padé approximant to ex, and then uses e02rbf to evaluate the approximant at x=0.1,0.2,,1.0.

Program Text

Program Text (e02rbfe.f90)

Program Data


Program Results

Program Results (e02rbfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 2 4 6 8 10 12 14 16 18 20 22 0 0.5 1 1.5 2 2.5 3 1e−14 1e−12 1e−10 1e−08 1e−06 0.0001 0.01 y(x) Error x Example Program The [4|4] Pade Approximant of exp(x) gnuplot_plot_1 Pade gnuplot_plot_2 exp(x) gnuplot_plot_3 Error