## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

e02raf calculates the coefficients in a Padé approximant to a function from its user-supplied Maclaurin expansion.

## 2Specification

Fortran Interface
 Subroutine e02raf ( ia, ib, c, ic, a, b, w, jw,
 Integer, Intent (In) :: ia, ib, ic, jw Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: c(ic) Real (Kind=nag_wp), Intent (Out) :: a(ia), b(ib), w(jw)
#include <nag.h>
 void e02raf_ (const Integer *ia, const Integer *ib, const double c[], const Integer *ic, double a[], double b[], double w[], const Integer *jw, Integer *ifail)
The routine may be called by the names e02raf or nagf_fit_pade_app.

## 3Description

Given a power series
 $c0+c1x+c2x2+⋯+cl+mxl+m+⋯$
e02raf uses the coefficients ${c}_{i}$, for $\mathit{i}=0,1,\dots ,l+m$, to form the $\left[l/m\right]$ Padé approximant of the form
 $a0+a1x+a2x2+⋯+alxl b0+b1x+b2x2+⋯+bmxm$
with ${b}_{0}$ defined to be unity. The two sets of coefficients ${a}_{j}$, for $\mathit{j}=0,1,\dots ,l$, and ${b}_{k}$, for $\mathit{k}=0,1,\dots ,m$, in the numerator and denominator are calculated by direct solution of the Padé equations (see Graves–Morris (1979)); these values are returned through the argument list unless the approximant is degenerate.
Padé approximation is a useful technique when values of a function are to be obtained from its Maclaurin expansion but convergence of the series is unacceptably slow or even nonexistent. It is based on the hypothesis of the existence of a sequence of convergent rational approximations, as described in Baker and Graves–Morris (1981) and Graves–Morris (1979).
Unless there are reasons to the contrary (as discussed in Chapter 4, Section 2, Chapters 5 and 6 of Baker and Graves–Morris (1981)), one normally uses the diagonal sequence of Padé approximants, namely
 ${[m/m],m=0,1,2,…}.$
Subsequent evaluation of the approximant at a given value of $x$ may be carried out using e02rbf.
Baker G A Jr and Graves–Morris P R (1981) Padé approximants, Part 1: Basic theory encyclopaedia of Mathematics and its Applications Addison–Wesley
Graves–Morris P R (1979) The numerical calculation of Padé approximants Padé Approximation and its Applications. Lecture Notes in Mathematics (ed L Wuytack) 765 231–245 Adison–Wesley

## 5Arguments

1: $\mathbf{ia}$Integer Input
2: $\mathbf{ib}$Integer Input
On entry: ia must specify $l+1$ and ib must specify $m+1$, where $l$ and $m$ are the degrees of the numerator and denominator of the approximant, respectively.
Constraint: ${\mathbf{ia}}\ge 1$ and ${\mathbf{ib}}\ge 1$.
3: $\mathbf{c}\left({\mathbf{ic}}\right)$Real (Kind=nag_wp) array Input
On entry: ${\mathbf{c}}\left(\mathit{i}\right)$ must specify, for $\mathit{i}=1,2,\dots ,l+m+1$, the coefficient of ${x}^{\mathit{i}-1}$ in the given power series.
4: $\mathbf{ic}$Integer Input
On entry: the dimension of the array c as declared in the (sub)program from which e02raf is called.
Constraint: ${\mathbf{ic}}\ge {\mathbf{ia}}+{\mathbf{ib}}-1$.
5: $\mathbf{a}\left({\mathbf{ia}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{a}}\left(\mathit{j}+1\right)$, for $\mathit{j}=1,2,\dots ,l+1$, contains the coefficient ${a}_{\mathit{j}}$ in the numerator of the approximant.
6: $\mathbf{b}\left({\mathbf{ib}}\right)$Real (Kind=nag_wp) array Output
On exit: ${\mathbf{b}}\left(\mathit{k}+1\right)$, for $\mathit{k}=1,2,\dots ,m+1$, contains the coefficient ${b}_{\mathit{k}}$ in the denominator of the approximant.
7: $\mathbf{w}\left({\mathbf{jw}}\right)$Real (Kind=nag_wp) array Workspace
8: $\mathbf{jw}$Integer Input
On entry: the dimension of the array w as declared in the (sub)program from which e02raf is called.
Constraint: ${\mathbf{jw}}\ge {\mathbf{ib}}×\left(2×{\mathbf{ib}}+3\right)$.
9: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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$
On entry, ${\mathbf{ia}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ia}}\ge 1$.
On entry, ${\mathbf{ib}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ib}}\ge 1$.
On entry, ${\mathbf{ic}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ia}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ib}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ic}}\ge {\mathbf{ia}}+{\mathbf{ib}}-1$.
On entry, ${\mathbf{jw}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ib}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{jw}}\ge {\mathbf{ib}}×\left(2×{\mathbf{ib}}+3\right)$.
${\mathbf{ifail}}=2$
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

The solution should be the best possible to the extent to which the solution is determined by the input coefficients. It is recommended that you determine the locations of the zeros of the numerator and denominator polynomials, both to examine compatibility with the analytic structure of the given function and to detect defects. (Defects are nearby pole-zero pairs; defects close to $x=0.0$ characterise ill-conditioning in the construction of the approximant.) Defects occur in regions where the approximation is necessarily inaccurate. The example program calls c02abf to determine the above zeros.
It is easy to test the stability of the computed numerator and denominator coefficients by making small perturbations of the original Maclaurin series coefficients (e.g., ${c}_{l}$ or ${c}_{l+m}$). These questions of intrinsic error of the approximants and computational error in their calculation are discussed in Chapter 2 of Baker and Graves–Morris (1981).

## 8Parallelism and Performance

e02raf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
e02raf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The time taken is approximately proportional to ${m}^{3}$.

## 10Example

This example calculates the $\left[4/4\right]$ Padé approximant of ${e}^{x}$ (whose power-series coefficients are first stored in the array c). The poles and zeros are then calculated to check the character of the $\left[4/4\right]$ Padé approximant.

### 10.1Program Text

Program Text (e02rafe.f90)

None.

### 10.3Program Results

Program Results (e02rafe.r)