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

# NAG Toolbox: nag_pde_1d_parab_fd_interp (d03pz)

## Purpose

nag_pde_1d_parab_fd_interp (d03pz) interpolates in the spatial coordinate the solution and derivative of a system of partial differential equations (PDEs). The solution must first be computed using one of the finite difference schemes nag_pde_1d_parab_fd (d03pc), nag_pde_1d_parab_dae_fd (d03ph) or nag_pde_1d_parab_remesh_fd (d03pp), or one of the Keller box schemes nag_pde_1d_parab_keller (d03pe), nag_pde_1d_parab_dae_keller (d03pk) or nag_pde_1d_parab_remesh_keller (d03pr).

## Syntax

[up, ifail] = d03pz(m, u, x, xp, itype, 'npde', npde, 'npts', npts, 'intpts', intpts)
[up, ifail] = nag_pde_1d_parab_fd_interp(m, u, x, xp, itype, 'npde', npde, 'npts', npts, 'intpts', intpts)

## Description

nag_pde_1d_parab_fd_interp (d03pz) is an interpolation function for evaluating the solution of a system of partial differential equations (PDEs), at a set of user-specified points. The solution of the system of equations (possibly with coupled ordinary differential equations) must be computed using a finite difference scheme or a Keller box scheme on a set of mesh points. nag_pde_1d_parab_fd_interp (d03pz) can then be employed to compute the solution at a set of points anywhere in the range of the mesh. It can also evaluate the first spatial derivative of the solution. It uses linear interpolation for approximating the solution.

None.

## Parameters

Note: the parameters x, m, u, npts and npde must be supplied unchanged from the PDE function.

### Compulsory Input Parameters

1:     m – int64int32nag_int scalar
The coordinate system used. If the call to nag_pde_1d_parab_fd_interp (d03pz) follows one of the finite difference functions then m must be the same parameter m as used in that call. For the Keller box scheme only Cartesian coordinate systems are valid and so m must be set to zero. No check will be made by nag_pde_1d_parab_fd_interp (d03pz) in this case.
m = 0${\mathbf{m}}=0$
Indicates Cartesian coordinates.
m = 1${\mathbf{m}}=1$
Indicates cylindrical polar coordinates.
m = 2${\mathbf{m}}=2$
Indicates spherical polar coordinates.
Constraints:
• 0m2$0\le {\mathbf{m}}\le 2$ following a finite difference function;
• m = 0${\mathbf{m}}=0$ following a Keller box scheme function.
2:     u(npde,npts) – double array
npde, the first dimension of the array, must satisfy the constraint npde1${\mathbf{npde}}\ge 1$.
The PDE part of the original solution returned in the parameter u by the PDE function.
Constraint: npde1${\mathbf{npde}}\ge 1$.
3:     x(npts) – double array
npts, the dimension of the array, must satisfy the constraint npts3${\mathbf{npts}}\ge 3$.
x(i)${\mathbf{x}}\left(\mathit{i}\right)$, for i = 1,2,,npts$\mathit{i}=1,2,\dots ,{\mathbf{npts}}$, must contain the mesh points as used by the PDE function.
4:     xp(intpts) – double array
intpts, the dimension of the array, must satisfy the constraint intpts1${\mathbf{intpts}}\ge 1$.
xp(i)${\mathbf{xp}}\left(\mathit{i}\right)$, for i = 1,2,,intpts$\mathit{i}=1,2,\dots ,{\mathbf{intpts}}$, must contain the spatial interpolation points.
Constraint: x(1)xp(1) < xp(2) < < xp(intpts)x(npts)${\mathbf{x}}\left(1\right)\le {\mathbf{xp}}\left(1\right)<{\mathbf{xp}}\left(2\right)<\cdots <{\mathbf{xp}}\left({\mathbf{intpts}}\right)\le {\mathbf{x}}\left({\mathbf{npts}}\right)$.
5:     itype – int64int32nag_int scalar
Specifies the interpolation to be performed.
itype = 1${\mathbf{itype}}=1$
The solutions at the interpolation points are computed.
itype = 2${\mathbf{itype}}=2$
Both the solutions and their first derivatives at the interpolation points are computed.
Constraint: itype = 1${\mathbf{itype}}=1$ or 2$2$.

### Optional Input Parameters

1:     npde – int64int32nag_int scalar
Default: The first dimension of the array u.
The number of PDEs.
Constraint: npde1${\mathbf{npde}}\ge 1$.
2:     npts – int64int32nag_int scalar
Default: The dimension of the array x and the second dimension of the array u. (An error is raised if these dimensions are not equal.)
The number of mesh points.
Constraint: npts3${\mathbf{npts}}\ge 3$.
3:     intpts – int64int32nag_int scalar
Default: The dimension of the array xp.
The number of interpolation points.
Constraint: intpts1${\mathbf{intpts}}\ge 1$.

None.

### Output Parameters

1:     up(npde,intpts,itype) – double array
If itype = 1${\mathbf{itype}}=1$, up(i,j,1)${\mathbf{up}}\left(\mathit{i},\mathit{j},1\right)$, contains the value of the solution Ui(xj,tout)${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{\mathrm{out}}\right)$, at the interpolation points xj = xp(j)${x}_{\mathit{j}}={\mathbf{xp}}\left(\mathit{j}\right)$, for j = 1,2,,intpts$\mathit{j}=1,2,\dots ,{\mathbf{intpts}}$ and i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
If itype = 2${\mathbf{itype}}=2$, up(i,j,1)${\mathbf{up}}\left(\mathit{i},\mathit{j},1\right)$ contains Ui(xj,tout)${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{\mathrm{out}}\right)$ and up(i,j,2)${\mathbf{up}}\left(\mathit{i},\mathit{j},2\right)$ contains (Ui)/(x) $\frac{\partial {U}_{\mathit{i}}}{\partial x}$ at these points.
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$
 On entry, itype ≠ 1${\mathbf{itype}}\ne 1$ or 2$2$, or intpts < 1${\mathbf{intpts}}<1$, or npde < 1${\mathbf{npde}}<1$, or npts < 3${\mathbf{npts}}<3$, or m ≠ 0${\mathbf{m}}\ne 0$, 1$1$ or 2$2$, or the mesh points x(i)${\mathbf{x}}\left(\mathit{i}\right)$, for i = 1,2, … ,npts$\mathit{i}=1,2,\dots ,{\mathbf{npts}}$, are not in strictly increasing order.
ifail = 2${\mathbf{ifail}}=2$
On entry, the interpolation points xp(i)${\mathbf{xp}}\left(\mathit{i}\right)$, for i = 1,2,,intpts$\mathit{i}=1,2,\dots ,{\mathbf{intpts}}$, are not in strictly increasing order.
ifail = 3${\mathbf{ifail}}=3$
You are attempting extrapolation, that is, one of the interpolation points xp(i)${\mathbf{xp}}\left(i\right)$, for some i$i$, lies outside the interval [x(1),x(npts)${\mathbf{x}}\left(1\right),{\mathbf{x}}\left({\mathbf{npts}}\right)$]. Extrapolation is not permitted.

## Accuracy

See the PDE function documents.

None.

## Example

```function nag_pde_1d_parab_fd_interp_example
m = int64(1);
u = [0, 0.1760021889329504, 0.3341579089708593, 0.4937980719530722, ...
0.6511403366936832, 0.8044807535486175, 0.9525489765885864, ...
1.09423368983943, 1.228514538086573, 1.35444287807973, ...
1.471137345520289, 1.577784110954285, 1.673622501349812, ...
1.757611424145824, 1.825804783497759, 1.867752956803207, ...
1.878359678117952, 1.868385424753035, 1.854505240663775, ...
1.84852820454846;
0.9997119383379945, 0.9996043818707437, 0.9995887346960896, ...
0.9995733176158295, 0.9995516033644839, 0.9995217547212679, ...
0.9994816709262737, 0.999428326601514, 0.9993571885011239, ...
0.9992612549235844, 0.9991292197833584, 0.9989381167530054, ...
0.9984790503092739, 0.9936254861425254, 0.9449226608879052, ...
0.7493216873033168, 0.4582225956678795, 0.2084439018937778, ...
0.05247378844653194, 0];
x = [0;
0.08257934547233232;
0.1645945902807339;
0.2454854871407991;
0.3246994692046835;
0.4016954246529694;
0.4759473930370735;
0.5469481581224268;
0.6142127126896678;
0.6772815716257411;
0.7357239106731316;
0.7891405093963936;
0.8371664782625285;
0.879473751206489;
0.9157733266550574;
0.9458172417006346;
0.9694002659393304;
0.9863613034027223;
0.9965844930066698;
1];
xp = [0;
0.4;
0.6;
0.8;
0.9;
1];
itype = int64(1);
[up, ifail] = nag_pde_1d_parab_fd_interp(m, u, x, xp, itype)
```
```

up =

0    0.8008    1.1988    1.5990    1.7958    1.8485
0.9997    0.9995    0.9994    0.9988    0.9663   -0.0000

ifail =

0

```
```function d03pz_example
m = int64(1);
u = [0, 0.1760021889329504, 0.3341579089708593, 0.4937980719530722, ...
0.6511403366936832, 0.8044807535486175, 0.9525489765885864, ...
1.09423368983943, 1.228514538086573, 1.35444287807973, ...
1.471137345520289, 1.577784110954285, 1.673622501349812, ...
1.757611424145824, 1.825804783497759, 1.867752956803207, ...
1.878359678117952, 1.868385424753035, 1.854505240663775, ...
1.84852820454846;
0.9997119383379945, 0.9996043818707437, 0.9995887346960896, ...
0.9995733176158295, 0.9995516033644839, 0.9995217547212679, ...
0.9994816709262737, 0.999428326601514, 0.9993571885011239, ...
0.9992612549235844, 0.9991292197833584, 0.9989381167530054, ...
0.9984790503092739, 0.9936254861425254, 0.9449226608879052, ...
0.7493216873033168, 0.4582225956678795, 0.2084439018937778, ...
0.05247378844653194, 0];
x = [0;
0.08257934547233232;
0.1645945902807339;
0.2454854871407991;
0.3246994692046835;
0.4016954246529694;
0.4759473930370735;
0.5469481581224268;
0.6142127126896678;
0.6772815716257411;
0.7357239106731316;
0.7891405093963936;
0.8371664782625285;
0.879473751206489;
0.9157733266550574;
0.9458172417006346;
0.9694002659393304;
0.9863613034027223;
0.9965844930066698;
1];
xp = [0;
0.4;
0.6;
0.8;
0.9;
1];
itype = int64(1);
[up, ifail] = d03pz(m, u, x, xp, itype)
```
```

up =

0    0.8008    1.1988    1.5990    1.7958    1.8485
0.9997    0.9995    0.9994    0.9988    0.9663   -0.0000

ifail =

0

```