# NAG Library Routine Document

## 1Purpose

d03pyf may be used in conjunction with either d03pdf/d03pda or d03pjf/d03pja. It computes the solution and its first derivative at user-specified points in the spatial coordinate.

## 2Specification

Fortran Interface
 Subroutine d03pyf ( npde, u, npts, xp, up,
 Integer, Intent (In) :: npde, nbkpts, npoly, npts, intpts, itype, lrsave Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: u(npde,npts), xbkpts(nbkpts), xp(intpts) Real (Kind=nag_wp), Intent (Inout) :: rsave(lrsave) Real (Kind=nag_wp), Intent (Out) :: up(npde,intpts,itype)
#include nagmk26.h
 void d03pyf_ (const Integer *npde, const double u[], const Integer *nbkpts, const double xbkpts[], const Integer *npoly, const Integer *npts, const double xp[], const Integer *intpts, const Integer *itype, double up[], double rsave[], const Integer *lrsave, Integer *ifail)

## 3Description

d03pyf is an interpolation routine for evaluating the solution of a system of partial differential equations (PDEs), or the PDE components of a system of PDEs with coupled ordinary differential equations (ODEs), at a set of user-specified points. The solution of a system of equations can be computed using d03pdf/d03pda or d03pjf/d03pja on a set of mesh points; d03pyf can then be employed to compute the solution at a set of points other than those originally used in d03pdf/d03pda or d03pjf/d03pja. It can also evaluate the first derivative of the solution. Polynomial interpolation is used between each of the break-points ${\mathbf{xbkpts}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nbkpts}}$. When the derivative is needed (${\mathbf{itype}}=2$), the array ${\mathbf{xp}}\left({\mathbf{intpts}}\right)$ must not contain any of the break-points, as the method, and consequently the interpolation scheme, assumes that only the solution is continuous at these points.

None.

## 5Arguments

Note: the arguments u, npts, npde, xbkpts, nbkpts, rsave and lrsave must be supplied unchanged from either d03pdf/d03pda or d03pjf/d03pja.
1:     $\mathbf{npde}$ – IntegerInput
On entry: the number of PDEs.
Constraint: ${\mathbf{npde}}\ge 1$.
2:     $\mathbf{u}\left({\mathbf{npde}},{\mathbf{npts}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the PDE part of the original solution returned in the argument u by the routine d03pdf/d03pda or d03pjf/d03pja.
3:     $\mathbf{nbkpts}$ – IntegerInput
On entry: the number of break-points.
Constraint: ${\mathbf{nbkpts}}\ge 2$.
4:     $\mathbf{xbkpts}\left({\mathbf{nbkpts}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: ${\mathbf{xbkpts}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nbkpts}}$, must contain the break-points as used by d03pdf/d03pda or d03pjf/d03pja.
Constraint: ${\mathbf{xbkpts}}\left(1\right)<{\mathbf{xbkpts}}\left(2\right)<\cdots <{\mathbf{xbkpts}}\left({\mathbf{nbkpts}}\right)$.
5:     $\mathbf{npoly}$ – IntegerInput
On entry: the degree of the Chebyshev polynomial used for approximation as used by d03pdf/d03pda or d03pjf/d03pja.
Constraint: $1\le {\mathbf{npoly}}\le 49$.
6:     $\mathbf{npts}$ – IntegerInput
On entry: the number of mesh points as used by d03pdf/d03pda or d03pjf/d03pja.
Constraint: ${\mathbf{npts}}=\left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1$.
7:     $\mathbf{xp}\left({\mathbf{intpts}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: ${\mathbf{xp}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{intpts}}$, must contain the spatial interpolation points.
Constraints:
• ${\mathbf{xbkpts}}\left(1\right)\le {\mathbf{xp}}\left(1\right)<{\mathbf{xp}}\left(2\right)<\cdots <{\mathbf{xp}}\left({\mathbf{intpts}}\right)\le {\mathbf{xbkpts}}\left({\mathbf{nbkpts}}\right)$;
• if ${\mathbf{itype}}=2$, ${\mathbf{xp}}\left(\mathit{i}\right)\ne {\mathbf{xbkpts}}\left(\mathit{j}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{intpts}}$ and $\mathit{j}=2,3,\dots ,{\mathbf{nbkpts}}-1$.
8:     $\mathbf{intpts}$ – IntegerInput
On entry: the number of interpolation points.
Constraint: ${\mathbf{intpts}}\ge 1$.
9:     $\mathbf{itype}$ – IntegerInput
On entry: specifies the interpolation to be performed.
${\mathbf{itype}}=1$
The solution at the interpolation points are computed.
${\mathbf{itype}}=2$
Both the solution and the first derivative at the interpolation points are computed.
Constraint: ${\mathbf{itype}}=1$ or $2$.
10:   $\mathbf{up}\left({\mathbf{npde}},{\mathbf{intpts}},{\mathbf{itype}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: if ${\mathbf{itype}}=1$, ${\mathbf{up}}\left(\mathit{i},\mathit{j},1\right)$, contains the value of the solution ${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{\mathrm{out}}\right)$, at the interpolation points ${x}_{\mathit{j}}={\mathbf{xp}}\left(\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{intpts}}$ and $\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
If ${\mathbf{itype}}=2$, ${\mathbf{up}}\left(\mathit{i},\mathit{j},1\right)$ contains ${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{\mathrm{out}}\right)$ and ${\mathbf{up}}\left(\mathit{i},\mathit{j},2\right)$ contains $\frac{\partial {U}_{\mathit{i}}}{\partial x}$ at these points.
11:   $\mathbf{rsave}\left({\mathbf{lrsave}}\right)$ – Real (Kind=nag_wp) arrayCommunication Array
The array rsave contains information required by d03pyf as returned by d03pdf/d03pda or d03pjf/d03pja. The contents of rsave must not be changed from the call to d03pdf/d03pda or d03pjf/d03pja. Some elements of this array are overwritten on exit.
12:   $\mathbf{lrsave}$ – IntegerInput
On entry: the size of the workspace rsave, as in d03pdf/d03pda or d03pjf/d03pja.
13:   $\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$
 On entry, ${\mathbf{itype}}\ne 1$ or $2$, or ${\mathbf{npoly}}<1$, or ${\mathbf{npde}}<1$, or ${\mathbf{nbkpts}}<2$, or ${\mathbf{intpts}}<1$, or ${\mathbf{npts}}\ne \left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1$, or ${\mathbf{xbkpts}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{nbkpts}}$, are not ordered.
${\mathbf{ifail}}=2$
On entry, the interpolation points ${\mathbf{xp}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{intpts}}$, are not in strictly increasing order, or when ${\mathbf{itype}}=2$, at least one of the interpolation points stored in xp is equal to one of the break-points stored in xbkpts.
${\mathbf{ifail}}=3$
You are attempting extrapolation, that is, one of the interpolation points ${\mathbf{xp}}\left(i\right)$, for some $i$, lies outside the interval [${\mathbf{xbkpts}}\left(1\right),{\mathbf{xbkpts}}\left({\mathbf{nbkpts}}\right)$]. Extrapolation is not permitted.
${\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

See the documents for d03pdf/d03pda or d03pjf/d03pja.

## 8Parallelism and Performance

d03pyf is not threaded in any implementation.