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_coll (d03pd)

## Purpose

nag_pde_1d_parab_coll (d03pd) integrates a system of linear or nonlinear parabolic partial differential equations (PDEs) in one space variable. The spatial discretization is performed using a Chebyshev C0${C}^{0}$ collocation method, and the method of lines is employed to reduce the PDEs to a system of ordinary differential equations (ODEs). The resulting system is solved using a backward differentiation formula method.

## Syntax

[ts, u, x, rsave, isave, ind, user, cwsav, lwsav, iwsav, rwsav, ifail] = d03pd(m, ts, tout, pdedef, bndary, u, xbkpts, npoly, uinit, acc, rsave, isave, itask, itrace, ind, cwsav, lwsav, iwsav, rwsav, 'npde', npde, 'nbkpts', nbkpts, 'npts', npts, 'user', user)
[ts, u, x, rsave, isave, ind, user, cwsav, lwsav, iwsav, rwsav, ifail] = nag_pde_1d_parab_coll(m, ts, tout, pdedef, bndary, u, xbkpts, npoly, uinit, acc, rsave, isave, itask, itrace, ind, cwsav, lwsav, iwsav, rwsav, 'npde', npde, 'nbkpts', nbkpts, 'npts', npts, 'user', user)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 22: lrsave, lisave have been removed from the interface
.

## Description

nag_pde_1d_parab_coll (d03pd) integrates the system of parabolic equations:
 npde ∑ Pi,j( ∂ Uj)/( ∂ t) + Qi = x − m( ∂ )/( ∂ x)(xmRi),  i = 1,2, … ,npde,  a ≤ x ≤ b,t ≥ t0, j = 1
$∑j=1npdePi,j ∂Uj ∂t +Qi=x-m ∂∂x (xmRi), i=1,2,…,npde, a≤x≤b,t≥t0,$
(1)
where Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ depend on x$x$, t$t$, U$U$, Ux${U}_{x}$ and the vector U$U$ is the set of solution values
 U (x,t) = [ U1 (x,t) , … , Unpde (x,t) ]T , $U (x,t) = [ U 1 (x,t) ,…, U npde (x,t) ] T ,$ (2)
and the vector Ux${U}_{x}$ is its partial derivative with respect to x$x$. Note that Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ must not depend on (U)/(t) $\frac{\partial U}{\partial t}$.
The integration in time is from t0${t}_{0}$ to tout${t}_{\mathrm{out}}$, over the space interval axb$a\le x\le b$, where a = x1$a={x}_{1}$ and b = $b={x}_{{\mathbf{nbkpts}}}$ are the leftmost and rightmost of a user-defined set of break points x1,x2,,${x}_{1},{x}_{2},\dots ,{x}_{{\mathbf{nbkpts}}}$. The coordinate system in space is defined by the value of m$m$; m = 0$m=0$ for Cartesian coordinates, m = 1$m=1$ for cylindrical polar coordinates and m = 2$m=2$ for spherical polar coordinates.
The system is defined by the functions Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ which must be specified in pdedef.
The initial values of the functions U(x,t)$U\left(x,t\right)$ must be given at t = t0$t={t}_{0}$, and must be specified in uinit.
The functions Ri${R}_{i}$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$, which may be thought of as fluxes, are also used in the definition of the boundary conditions for each equation. The boundary conditions must have the form
 βi(x,t)Ri(x,t,U,Ux) = γi(x,t,U,Ux),  i = 1,2, … ,npde, $βi(x,t)Ri(x,t,U,Ux)=γi(x,t,U,Ux), i=1,2,…,npde,$ (3)
where x = a$x=a$ or x = b$x=b$.
The boundary conditions must be specified in bndary. Thus, the problem is subject to the following restrictions:
 (i) t0 < tout${t}_{0}<{t}_{\mathrm{out}}$, so that integration is in the forward direction; (ii) Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and the flux Ri${R}_{i}$ must not depend on any time derivatives; (iii) the evaluation of the functions Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ is done at both the break points and internally selected points for each element in turn, that is Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ are evaluated twice at each break point. Any discontinuities in these functions must therefore be at one or more of the break points x1,x2, … ,${x}_{1},{x}_{2},\dots ,{x}_{{\mathbf{nbkpts}}}$; (iv) at least one of the functions Pi,j${P}_{i,j}$ must be nonzero so that there is a time derivative present in the problem; (v) if m > 0$m>0$ and x1 = 0.0${x}_{1}=0.0$, which is the left boundary point, then it must be ensured that the PDE solution is bounded at this point. This can be done by either specifying the solution at x = 0.0$x=0.0$ or by specifying a zero flux there, that is βi = 1.0${\beta }_{i}=1.0$ and γi = 0.0${\gamma }_{i}=0.0$. See also Section [Further Comments].
The parabolic equations are approximated by a system of ODEs in time for the values of Ui${U}_{i}$ at the mesh points. This ODE system is obtained by approximating the PDE solution between each pair of break points by a Chebyshev polynomial of degree npoly. The interval between each pair of break points is treated by nag_pde_1d_parab_coll (d03pd) as an element, and on this element, a polynomial and its space and time derivatives are made to satisfy the system of PDEs at npoly1${\mathbf{npoly}}-1$ spatial points, which are chosen internally by the code and the break points. In the case of just one element, the break points are the boundaries. The user-defined break points and the internally selected points together define the mesh. The smallest value that npoly can take is one, in which case, the solution is approximated by piecewise linear polynomials between consecutive break points and the method is similar to an ordinary finite element method.
In total there are (nbkpts1) × npoly + 1$\left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1$ mesh points in the spatial direction, and npde × ((nbkpts1) × npoly + 1)${\mathbf{npde}}×\left(\left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1\right)$ ODEs in the time direction; one ODE at each break point for each PDE component and (npoly1${\mathbf{npoly}}-1$) ODEs for each PDE component between each pair of break points. The system is then integrated forwards in time using a backward differentiation formula method.

## References

Berzins M (1990) Developments in the NAG Library software for parabolic equations Scientific Software Systems (eds J C Mason and M G Cox) 59–72 Chapman and Hall
Berzins M and Dew P M (1991) Algorithm 690: Chebyshev polynomial software for elliptic-parabolic systems of PDEs ACM Trans. Math. Software 17 178–206
Zaturska N B, Drazin P G and Banks W H H (1988) On the flow of a viscous fluid driven along a channel by a suction at porous walls Fluid Dynamics Research 4

## Parameters

### Compulsory Input Parameters

1:     m – int64int32nag_int scalar
The coordinate system used:
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.
Constraint: m = 0${\mathbf{m}}=0$, 1$1$ or 2$2$.
2:     ts – double scalar
The initial value of the independent variable t$t$.
Constraint: ${\mathbf{ts}}<{\mathbf{tout}}$.
3:     tout – double scalar
The final value of t$t$ to which the integration is to be carried out.
4:     pdedef – function handle or string containing name of m-file
pdedef must compute the values of the functions Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ which define the system of PDEs. The functions may depend on x$x$, t$t$, U$U$ and Ux${U}_{x}$ and must be evaluated at a set of points.
[p, q, r, ires, user] = pdedef(npde, t, x, nptl, u, ux, ires, user)

Input Parameters

1:     npde – int64int32nag_int scalar
The number of PDEs in the system.
2:     t – double scalar
The current value of the independent variable t$t$.
3:     x(nptl) – double array
Contains a set of mesh points at which Pi,j${P}_{i,j}$, Qi${Q}_{i}$ and Ri${R}_{i}$ are to be evaluated. x(1)${\mathbf{x}}\left(1\right)$ and x(nptl)${\mathbf{x}}\left({\mathbf{nptl}}\right)$ contain successive user-supplied break points and the elements of the array will satisfy x(1) < x(2) < < x(nptl)${\mathbf{x}}\left(1\right)<{\mathbf{x}}\left(2\right)<\cdots <{\mathbf{x}}\left({\mathbf{nptl}}\right)$.
4:     nptl – int64int32nag_int scalar
The number of points at which evaluations are required (the value of npoly + 1${\mathbf{npoly}}+1$).
5:     u(npde,nptl) – double array
u(i,j)${\mathbf{u}}\left(\mathit{i},\mathit{j}\right)$ contains the value of the component Ui(x,t)${U}_{\mathit{i}}\left(x,t\right)$ where x = x(j)$x={\mathbf{x}}\left(\mathit{j}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,nptl$\mathit{j}=1,2,\dots ,{\mathbf{nptl}}$.
6:     ux(npde,nptl) – double array
ux(i,j)${\mathbf{ux}}\left(\mathit{i},\mathit{j}\right)$ contains the value of the component (Ui(x,t))/(x) $\frac{\partial {U}_{\mathit{i}}\left(x,t\right)}{\partial x}$ where x = x(j)$x={\mathbf{x}}\left(\mathit{j}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,nptl$\mathit{j}=1,2,\dots ,{\mathbf{nptl}}$.
7:     ires – int64int32nag_int scalar
Set to 1​ or ​1$-1\text{​ or ​}1$.
8:     user – Any MATLAB object
pdedef is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     p(npde,npde,nptl) – double array
p(i,j,k)${\mathbf{p}}\left(\mathit{i},\mathit{j},\mathit{k}\right)$ must be set to the value of Pi,j(x,t,U,Ux)${P}_{\mathit{i},\mathit{j}}\left(x,t,U,{U}_{x}\right)$ where x = x(k)$x={\mathbf{x}}\left(\mathit{k}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$, j = 1,2,,npde$\mathit{j}=1,2,\dots ,{\mathbf{npde}}$ and k = 1,2,,nptl$\mathit{k}=1,2,\dots ,{\mathbf{nptl}}$.
2:     q(npde,nptl) – double array
q(i,j)${\mathbf{q}}\left(\mathit{i},\mathit{j}\right)$ must be set to the value of Qi(x,t,U,Ux)${Q}_{\mathit{i}}\left(x,t,U,{U}_{x}\right)$ where x = x(j)$x={\mathbf{x}}\left(\mathit{j}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,nptl$\mathit{j}=1,2,\dots ,{\mathbf{nptl}}$.
3:     r(npde,nptl) – double array
r(i,j)${\mathbf{r}}\left(\mathit{i},\mathit{j}\right)$ must be set to the value of Ri(x,t,U,Ux)${R}_{\mathit{i}}\left(x,t,U,{U}_{x}\right)$ where x = x(j)$x={\mathbf{x}}\left(\mathit{j}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,nptl$\mathit{j}=1,2,\dots ,{\mathbf{nptl}}$.
4:     ires – int64int32nag_int scalar
Should usually remain unchanged. However, you may set ires to force the integration function to take certain actions as described below:
ires = 2${\mathbf{ires}}=2$
Indicates to the integrator that control should be passed back immediately to the calling (sub)routine with the error indicator set to ${\mathbf{ifail}}={\mathbf{6}}$.
ires = 3${\mathbf{ires}}=3$
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set ires = 3${\mathbf{ires}}=3$ when a physically meaningless input or output value has been generated. If you consecutively set ires = 3${\mathbf{ires}}=3$, then nag_pde_1d_parab_coll (d03pd) returns to the calling function with the error indicator set to ${\mathbf{ifail}}={\mathbf{4}}$.
5:     user – Any MATLAB object
5:     bndary – function handle or string containing name of m-file
bndary must compute the functions βi${\beta }_{i}$ and γi${\gamma }_{i}$ which define the boundary conditions as in equation (3).
[beta, gamma, ires, user] = bndary(npde, t, u, ux, ibnd, ires, user)

Input Parameters

1:     npde – int64int32nag_int scalar
The number of PDEs in the system.
2:     t – double scalar
The current value of the independent variable t$t$.
3:     u(npde) – double array
u(i)${\mathbf{u}}\left(\mathit{i}\right)$ contains the value of the component Ui(x,t)${U}_{\mathit{i}}\left(x,t\right)$ at the boundary specified by ibnd, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
4:     ux(npde) – double array
ux(i)${\mathbf{ux}}\left(\mathit{i}\right)$ contains the value of the component (Ui(x,t))/(x) $\frac{\partial {U}_{\mathit{i}}\left(x,t\right)}{\partial x}$ at the boundary specified by ibnd, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
5:     ibnd – int64int32nag_int scalar
Specifies which boundary conditions are to be evaluated.
ibnd = 0${\mathbf{ibnd}}=0$
bndary must set up the coefficients of the left-hand boundary, x = a$x=a$.
ibnd0${\mathbf{ibnd}}\ne 0$
bndary must set up the coefficients of the right-hand boundary, x = b$x=b$.
6:     ires – int64int32nag_int scalar
Set to 1​ or ​1$-1\text{​ or ​}1$.
7:     user – Any MATLAB object
bndary is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     beta(npde) – double array
beta(i)${\mathbf{beta}}\left(\mathit{i}\right)$ must be set to the value of βi(x,t)${\beta }_{\mathit{i}}\left(x,t\right)$ at the boundary specified by ibnd, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
2:     gamma(npde) – double array
gamma(i)${\mathbf{gamma}}\left(\mathit{i}\right)$ must be set to the value of γi(x,t,U,Ux)${\gamma }_{\mathit{i}}\left(x,t,U,{U}_{x}\right)$ at the boundary specified by ibnd, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$.
3:     ires – int64int32nag_int scalar
Should usually remain unchanged. However, you may set ires to force the integration function to take certain actions as described below:
ires = 2${\mathbf{ires}}=2$
Indicates to the integrator that control should be passed back immediately to the calling (sub)routine with the error indicator set to ${\mathbf{ifail}}={\mathbf{6}}$.
ires = 3${\mathbf{ires}}=3$
Indicates to the integrator that the current time step should be abandoned and a smaller time step used instead. You may wish to set ires = 3${\mathbf{ires}}=3$ when a physically meaningless input or output value has been generated. If you consecutively set ires = 3${\mathbf{ires}}=3$, then nag_pde_1d_parab_coll (d03pd) returns to the calling function with the error indicator set to ${\mathbf{ifail}}={\mathbf{4}}$.
4:     user – Any MATLAB object
6:     u(npde,npts) – double array
npde, the first dimension of the array, must satisfy the constraint npde1${\mathbf{npde}}\ge 1$.
If ind = 1${\mathbf{ind}}=1$ the value of u must be unchanged from the previous call.
7:     xbkpts(nbkpts) – double array
nbkpts, the dimension of the array, must satisfy the constraint nbkpts2${\mathbf{nbkpts}}\ge 2$.
The values of the break points in the space direction. xbkpts(1)${\mathbf{xbkpts}}\left(1\right)$ must specify the left-hand boundary, a$a$, and ${\mathbf{xbkpts}}\left({\mathbf{nbkpts}}\right)$ must specify the right-hand boundary, b$b$.
Constraint: xbkpts(1) < xbkpts(2) < < ${\mathbf{xbkpts}}\left(1\right)<{\mathbf{xbkpts}}\left(2\right)<\cdots <{\mathbf{xbkpts}}\left({\mathbf{nbkpts}}\right)$.
8:     npoly – int64int32nag_int scalar
The degree of the Chebyshev polynomial to be used in approximating the PDE solution between each pair of break points.
Constraint: 1npoly49$1\le {\mathbf{npoly}}\le 49$.
9:     uinit – function handle or string containing name of m-file
uinit must compute the initial values of the PDE components Ui(xj,t0)${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{0}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,npts$\mathit{j}=1,2,\dots ,{\mathbf{npts}}$.
[u, user] = uinit(npde, npts, x, user)

Input Parameters

1:     npde – int64int32nag_int scalar
The number of PDEs in the system.
2:     npts – int64int32nag_int scalar
The number of mesh points in the interval [a,b]$\left[a,b\right]$.
3:     x(npts) – double array
x(j)${\mathbf{x}}\left(\mathit{j}\right)$, contains the values of the j$\mathit{j}$th mesh point, for j = 1,2,,npts$\mathit{j}=1,2,\dots ,{\mathbf{npts}}$.
4:     user – Any MATLAB object
uinit is called from nag_pde_1d_parab_coll (d03pd) with the object supplied to nag_pde_1d_parab_coll (d03pd).

Output Parameters

1:     u(npde,npts) – double array
u(i,j)${\mathbf{u}}\left(\mathit{i},\mathit{j}\right)$ must be set to the initial value Ui(xj,t0)${U}_{\mathit{i}}\left({x}_{\mathit{j}},{t}_{0}\right)$, for i = 1,2,,npde$\mathit{i}=1,2,\dots ,{\mathbf{npde}}$ and j = 1,2,,npts$\mathit{j}=1,2,\dots ,{\mathbf{npts}}$.
2:     user – Any MATLAB object
10:   acc – double scalar
A positive quantity for controlling the local error estimate in the time integration. If E(i,j)$E\left(i,j\right)$ is the estimated error for Ui${U}_{i}$ at the j$j$th mesh point, the error test is:
 |E(i,j)| = acc × (1.0 + |u(i,j)|). $|E(i,j)|=acc×(1.0+|uij|).$
Constraint: acc > 0.0${\mathbf{acc}}>0.0$.
11:   rsave(lrsave) – double array
lrsave, the dimension of the array, must satisfy the constraint lrsave11 × npde × npts + 50 + nwkres + lenode$\mathit{lrsave}\ge 11×{\mathbf{npde}}×{\mathbf{npts}}+50+\mathit{nwkres}+\mathit{lenode}$.
If ind = 0${\mathbf{ind}}=0$, rsave need not be set on entry.
If ind = 1${\mathbf{ind}}=1$, rsave must be unchanged from the previous call to the function because it contains required information about the iteration.
12:   isave(lisave) – int64int32nag_int array
lisave, the dimension of the array, must satisfy the constraint lisavenpde × npts + 24$\mathit{lisave}\ge {\mathbf{npde}}×{\mathbf{npts}}+24$.
If ind = 0${\mathbf{ind}}=0$, isave need not be set on entry.
If ind = 1${\mathbf{ind}}=1$, isave must be unchanged from the previous call to the function because it contains required information about the iteration. In particular:
isave(1)${\mathbf{isave}}\left(1\right)$
Contains the number of steps taken in time.
isave(2)${\mathbf{isave}}\left(2\right)$
Contains the number of residual evaluations of the resulting ODE system used. One such evaluation involves computing the PDE functions at all the mesh points, as well as one evaluation of the functions in the boundary conditions.
isave(3)${\mathbf{isave}}\left(3\right)$
Contains the number of Jacobian evaluations performed by the time integrator.
isave(4)${\mathbf{isave}}\left(4\right)$
Contains the order of the last backward differentiation formula method used.
isave(5)${\mathbf{isave}}\left(5\right)$
Contains the number of Newton iterations performed by the time integrator. Each iteration involves an ODE residual evaluation followed by a back-substitution using the LU$LU$ decomposition of the Jacobian matrix.
Specifies the task to be performed by the ODE integrator.
itask = 1${\mathbf{itask}}=1$
Normal computation of output values u at t = tout$t={\mathbf{tout}}$.
itask = 2${\mathbf{itask}}=2$
One step and return.
itask = 3${\mathbf{itask}}=3$
Stop at first internal integration point at or beyond t = tout$t={\mathbf{tout}}$.
Constraint: itask = 1${\mathbf{itask}}=1$, 2$2$ or 3$3$.
14:   itrace – int64int32nag_int scalar
The level of trace information required from nag_pde_1d_parab_coll (d03pd) and the underlying ODE solver. itrace may take the value 1$-1$, 0$0$, 1$1$, 2$2$ or 3$3$.
itrace = 1${\mathbf{itrace}}=-1$
No output is generated.
itrace = 0${\mathbf{itrace}}=0$
Only warning messages from the PDE solver are printed on the current error message unit (see nag_file_set_unit_error (x04aa)).
itrace > 0${\mathbf{itrace}}>0$
Output from the underlying ODE solver is printed on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)). This output contains details of Jacobian entries, the nonlinear iteration and the time integration during the computation of the ODE system.
If itrace < 1${\mathbf{itrace}}<-1$, then 1$-1$ is assumed and similarly if itrace > 3${\mathbf{itrace}}>3$, then 3$3$ is assumed.
The advisory messages are given in greater detail as itrace increases. You are advised to set itrace = 0${\mathbf{itrace}}=0$, unless you are experienced with sub-chapter D02M–N.
15:   ind – int64int32nag_int scalar
Indicates whether this is a continuation call or a new integration.
ind = 0${\mathbf{ind}}=0$
Starts or restarts the integration in time.
ind = 1${\mathbf{ind}}=1$
Continues the integration after an earlier exit from the function. In this case, only the parameters tout and ifail should be reset between calls to nag_pde_1d_parab_coll (d03pd).
Constraint: ind = 0${\mathbf{ind}}=0$ or 1$1$.
16:   cwsav(10$10$) – cell array of strings
17:   lwsav(100$100$) – logical array
18:   iwsav(505$505$) – int64int32nag_int array
19:   rwsav(1100$1100$) – double array

### Optional Input Parameters

1:     npde – int64int32nag_int scalar
Default: The first dimension of the array u.
The number of PDEs in the system to be solved.
Constraint: npde1${\mathbf{npde}}\ge 1$.
2:     nbkpts – int64int32nag_int scalar
Default: The dimension of the array xbkpts.
The number of break points in the interval [a,b]$\left[a,b\right]$.
Constraint: nbkpts2${\mathbf{nbkpts}}\ge 2$.
3:     npts – int64int32nag_int scalar
Default: The second dimension of the array u.
The number of mesh points in the interval [a,b]$\left[a,b\right]$.
Constraint: npts = (nbkpts1) × npoly + 1${\mathbf{npts}}=\left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1$.
4:     user – Any MATLAB object
user is not used by nag_pde_1d_parab_coll (d03pd), but is passed to pdedef, bndary and uinit. Note that for large objects it may be more efficient to use a global variable which is accessible from the m-files than to use user.

### Input Parameters Omitted from the MATLAB Interface

lrsave lisave iuser ruser

### Output Parameters

1:     ts – double scalar
The value of t$t$ corresponding to the solution values in u. Normally ${\mathbf{ts}}={\mathbf{tout}}$.
2:     u(npde,npts) – double array
u(i,j)${\mathbf{u}}\left(i,j\right)$ will contain the computed solution at t = ts$t={\mathbf{ts}}$.
3:     x(npts) – double array
The mesh points chosen by nag_pde_1d_parab_coll (d03pd) in the spatial direction. The values of x will satisfy x(1) < x(2) < < x(npts)${\mathbf{x}}\left(1\right)<{\mathbf{x}}\left(2\right)<\cdots <{\mathbf{x}}\left({\mathbf{npts}}\right)$.
4:     rsave(lrsave) – double array
If ind = 1${\mathbf{ind}}=1$, rsave must be unchanged from the previous call to the function because it contains required information about the iteration.
5:     isave(lisave) – int64int32nag_int array
If ind = 1${\mathbf{ind}}=1$, isave must be unchanged from the previous call to the function because it contains required information about the iteration. In particular:
isave(1)${\mathbf{isave}}\left(1\right)$
Contains the number of steps taken in time.
isave(2)${\mathbf{isave}}\left(2\right)$
Contains the number of residual evaluations of the resulting ODE system used. One such evaluation involves computing the PDE functions at all the mesh points, as well as one evaluation of the functions in the boundary conditions.
isave(3)${\mathbf{isave}}\left(3\right)$
Contains the number of Jacobian evaluations performed by the time integrator.
isave(4)${\mathbf{isave}}\left(4\right)$
Contains the order of the last backward differentiation formula method used.
isave(5)${\mathbf{isave}}\left(5\right)$
Contains the number of Newton iterations performed by the time integrator. Each iteration involves an ODE residual evaluation followed by a back-substitution using the LU$LU$ decomposition of the Jacobian matrix.
6:     ind – int64int32nag_int scalar
ind = 1${\mathbf{ind}}=1$.
7:     user – Any MATLAB object
8:     cwsav(10$10$) – cell array of strings
9:     lwsav(100$100$) – logical array
10:   iwsav(505$505$) – int64int32nag_int array
11:   rwsav(1100$1100$) – double array
12:   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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, ${\mathbf{tout}}\le {\mathbf{ts}}$, or ${\mathbf{tout}}-{\mathbf{ts}}$ is too small, or itask ≠ 1${\mathbf{itask}}\ne 1$, 2$2$ or 3$3$, or m ≠ 0${\mathbf{m}}\ne 0$, 1$1$ or 2$2$, or m > 0${\mathbf{m}}>0$ and xbkpts(1) < 0.0${\mathbf{xbkpts}}\left(1\right)<0.0$, or npde < 1${\mathbf{npde}}<1$, or nbkpts < 2${\mathbf{nbkpts}}<2$, or npoly < 1${\mathbf{npoly}}<1$ or npoly > 49${\mathbf{npoly}}>49$, or npts ≠ (nbkpts − 1) × npoly + 1${\mathbf{npts}}\ne \left({\mathbf{nbkpts}}-1\right)×{\mathbf{npoly}}+1$, or acc ≤ 0.0${\mathbf{acc}}\le 0.0$, or ind ≠ 0${\mathbf{ind}}\ne 0$ or 1$1$, or break points xbkpts(i)${\mathbf{xbkpts}}\left(i\right)$ are not ordered, or lrsave is too small, or lisave is too small.
W ifail = 2${\mathbf{ifail}}=2$
The underlying ODE solver cannot make any further progress across the integration range from the current point t = ts$t={\mathbf{ts}}$ with the supplied value of acc. The components of u contain the computed values at the current point t = ts$t={\mathbf{ts}}$.
W ifail = 3${\mathbf{ifail}}=3$
In the underlying ODE solver, there were repeated errors or corrector convergence test failures on an attempted step, before completing the requested task. The problem may have a singularity or acc is too small for the integration to continue. Integration was successful as far as t = ts$t={\mathbf{ts}}$.
ifail = 4${\mathbf{ifail}}=4$
In setting up the ODE system, the internal initialization function was unable to initialize the derivative of the ODE system. This could be due to the fact that ires was repeatedly set to 3$3$ in at least pdedef or bndary, when the residual in the underlying ODE solver was being evaluated.
ifail = 5${\mathbf{ifail}}=5$
In solving the ODE system, a singular Jacobian has been encountered. You should check your problem formulation.
W ifail = 6${\mathbf{ifail}}=6$
When evaluating the residual in solving the ODE system, ires was set to 2$2$ in at least pdedef or bndary. Integration was successful as far as t = ts$t={\mathbf{ts}}$.
ifail = 7${\mathbf{ifail}}=7$
The value of acc is so small that the function is unable to start the integration in time.
ifail = 8${\mathbf{ifail}}=8$
In one of pdedef or bndary, ires was set to an invalid value.
ifail = 9${\mathbf{ifail}}=9$ (nag_ode_ivp_stiff_imp_revcom (d02nn))
A serious error has occurred in an internal call to the specified function. Check the problem specification and all parameters and array dimensions. Setting itrace = 1${\mathbf{itrace}}=1$ may provide more information. If the problem persists, contact NAG.
W ifail = 10${\mathbf{ifail}}=10$
The required task has been completed, but it is estimated that a small change in acc is unlikely to produce any change in the computed solution. (Only applies when you are not operating in one step mode, that is when itask2${\mathbf{itask}}\ne 2$.)
ifail = 11${\mathbf{ifail}}=11$
An error occurred during Jacobian formulation of the ODE system (a more detailed error description may be directed to the current error message unit).
ifail = 12${\mathbf{ifail}}=12$
Not applicable.
ifail = 13${\mathbf{ifail}}=13$
Not applicable.
ifail = 14${\mathbf{ifail}}=14$
The flux function Ri${R}_{i}$ was detected as depending on time derivatives, which is not permissible.

## Accuracy

nag_pde_1d_parab_coll (d03pd) controls the accuracy of the integration in the time direction but not the accuracy of the approximation in space. The spatial accuracy depends on the degree of the polynomial approximation npoly, and on both the number of break points and on their distribution in space. In the time integration only the local error over a single step is controlled and so the accuracy over a number of steps cannot be guaranteed. You should therefore test the effect of varying the accuracy parameter, acc.

nag_pde_1d_parab_coll (d03pd) is designed to solve parabolic systems (possibly including elliptic equations) with second-order derivatives in space. The parameter specification allows you to include equations with only first-order derivatives in the space direction but there is no guarantee that the method of integration will be satisfactory for such systems. The position and nature of the boundary conditions in particular are critical in defining a stable problem.
The time taken depends on the complexity of the parabolic system and on the accuracy requested.

## Example

The problem consists of a fourth-order PDE which can be written as a pair of second-order elliptic-parabolic PDEs for U1(x,t)${U}_{1}\left(x,t\right)$ and U2(x,t)${U}_{2}\left(x,t\right)$,
 0 = (∂2U1)/( ∂ x2) − U2 $0= ∂2U1 ∂x2 -U2$ (4)
 ( ∂ U2)/( ∂ t) = (∂2U2)/( ∂ x2) + U2( ∂ U1)/( ∂ x) − U1( ∂ U2)/( ∂ x) $∂U2 ∂t = ∂2U2 ∂x2 +U2 ∂U1 ∂x -U1 ∂U2 ∂x$ (5)
where 1x1$-1\le x\le 1$ and t0$t\ge 0$. The boundary conditions are given by
 ( ∂ U1)/( ∂ x) = 0  and  U1 = 1  at ​x = − 1,   and ( ∂ U1)/( ∂ x) = 0  and  U1 = − 1  at ​x = 1.
$∂U1 ∂x =0 and U1=1 at ​x=-1, and ∂U1 ∂x =0 and U1=-1 at ​x=1.$
The initial conditions at t = 0$t=0$ are given by
 U1 = − sin(πx)/2  and  U2 = (π2)/4sin(πx)/2. $U1=-sin⁡πx2 and U2=π24sin⁡πx2.$
The absence of boundary conditions for U2(x,t)${U}_{2}\left(x,t\right)$ does not pose any difficulties provided that the derivative flux boundary conditions are assigned to the first PDE (4) which has the correct flux, (U1)/(x) $\frac{\partial {U}_{1}}{\partial x}$. The conditions on U1(x,t)${U}_{1}\left(x,t\right)$ at the boundaries are assigned to the second PDE by setting β2 = 0.0${\beta }_{2}=0.0$ in equation (3) and placing the Dirichlet boundary conditions on U1(x,t)${U}_{1}\left(x,t\right)$ in the function γ2${\gamma }_{2}$.
```function nag_pde_1d_parab_coll_example

% Solution of an elliptic-parabolic pair of PDEs
% (derived from a fourth-order PDE).

% Set values for problem parameters.
npde = 2;

% Number of points on interpolated mesh, number of break points.
intpts = 6;
nbkpts = 10;

% Order of Chebyshev polynomial.
npoly = 3;

itype = 1;

nel = nbkpts - 1;
npts = nel*npoly + 1;
mu = npde*(npoly + 1) - 1;
neqn = npde*npts;
lisave = neqn + 24;
npl1 = npoly + 1;
nwkres = 3*npl1*npl1 + npl1*(npde*npde + 6*npde+nbkpts+1) + 13*npde + 5;
lenode = (3*mu + 1)*neqn;
lrsave = 11*neqn + 50 + nwkres + lenode;

% Define some arrays.
rsave = zeros(lrsave, 1);
u = zeros(npde, npts);
uinterp = zeros(npde, intpts, itype);
x = zeros(npts, 1);
xbkpts = zeros(nbkpts, 1);

isave = zeros(lisave, 1, 'int64');
cwsav = {''; ''; ''; ''; ''; ''; ''; ''; ''; ''};
lwsav = false(100, 1);
iwsav = zeros(505, 1, 'int64');
rwsav = zeros(1100, 1);

% Set up the points on the interpolation grid.
xinterp = [-1.0 -0.6 -0.2 0.2 0.6 1.0];

acc = 1.0e-4;

itrace = 0;
m = 0; % Use cartesian coordinates.

% We run through the calculation twice; once to output the interpolated
% results, and once to store the results for plotting.
niter = [5, 20];

% Prepare to store plotting results.
tsav = zeros(niter(2), 1);
usav = zeros(2, niter(2), npts);
isav = 0;

fprintf(' nag_pde_1d_parab_coll example program results\n');
for icalc = 1:2

% Set the break points.
if icalc == 1
hx = 2.0/(nbkpts-1.0);
xbkpts(1) = -1.0;
xbkpts(nbkpts) = 1.0;
for i = 2:nbkpts-1
xbkpts(i) = xbkpts(i-1) + hx;
end
else
for i = 1:nbkpts
xbkpts(i) = -1.0 + (i - 1.0)*2.0/(nbkpts - 1.0);
end
end

% Set initial conditions.
ts = 0.0;
tout = 0.1e-4;
alpha = -log(tout)/(niter(2)-1.0);

% Start the integration in time.
ind = 0;

% Loop over endpoints for the integration.  We've set itask = 1, which
% gives normal computation of output values at t = tout.
for iter = 1:niter(icalc)

%Set the endpoint.
if icalc == 1
tout = 10.0*tout;
else
tout = exp(alpha*(iter - niter(icalc)));
end

% Calling this routine here, we always have ind set to 0, which
% (re)starts the integration in time - otherwise, the output x
% array is set to zero.
[ts, u, x, rsave, isave, indOut, user, cwsav, lwsav, iwsav, ...
rwsav, ifail] = nag_pde_1d_parab_coll(int64(m), ts, tout, @pdedef, ...
@bndary, u, xbkpts, int64(npoly), @uinit, ...
acc, rsave, isave, int64(itask), int64(itrace), int64(ind), ...
cwsav, lwsav, iwsav, rwsav);
if ifail ~= 0
% Parameters out of range, or convergence problems.
% Print message and exit.
fprintf('Warning: nag_pde_1d_parab_coll returned with ifail = %1d \n\n',ifail);
return;
end

if icalc == 1
% Output interpolation points first time through.
if iter == 1
fprintf([' polynomial degree = %4d', ...
'    no. of elements = %4d\n'], npoly, nel);
fprintf([' accuracy requirement = %10.3e', ...
'    number of points = %5d\n\n'], acc, npts);
fprintf(' t / x       ');
for i = 1:intpts
fprintf('%8.4f', xinterp(i));
end
fprintf('\n\n');
end

% Call nag_pde_1d_parab_coll_interp to do interpolation of results
% onto coarser grid.
[uinterp, rsave, ifail] = nag_pde_1d_parab_coll_interp(u, ...
xbkpts, int64(npoly), xinterp, int64(itype), rsave);
if ifail ~= 0
% Parameters out of range, or convergence problems.
% Print message and exit.
fprintf(['Warning: nag_pde_1d_parab_coll_interp returned with ifail = ', ...
'%1d \n\n'], ifail);
return;
end

% Output interpolated results for this time step.
fprintf('%7.4f  u(1)', ts);
for i = 1:intpts
fprintf('%8.4f', uinterp(1,i,1));
end
fprintf('\n');
fprintf('         u(2)');
for i = 1:intpts
fprintf('%8.4f', uinterp(2,i,1));
end
fprintf('\n\n');
else
% Save this timestep, and this set of results.
isav = isav+1;
tsav(isav) = ts;
for ipt = 1:npts
for isol = 1:2
usav(isol,isav,ipt) = u(isol,ipt);
end
end
end
end

if icalc == 1
% Output some statistics.
fprintf([' Number of integration steps in time = %6d\n', ...
' Number of function evaluations = %6d\n', ...
' Number of Jacobian evaluations = %6d\n', ...
' Number of iterations = %6d\n'], isave(1), isave(2), ...
isave(3), isave(5));
else
% Plot results.
fig1 = figure('Number', 'off');
plot_results(x, tsav, squeeze(usav(1,:,:)), 'U1');
fig2 = figure('Number', 'off');
plot_results(x, tsav, squeeze(usav(2,:,:)), 'U2');
end
end

function [p, q, r, ires, user] = pdedef(npde, t, x, nptl, u, ux, ires, user)
p = zeros(npde, npde, nptl);
q = zeros(npde, nptl);
r = zeros(npde, nptl);

for i = 1:double(nptl)
q(1,i) = u(2,i);
q(2,i) = u(1,i)*ux(2,i) - ux(1,i)*u(2,i);
r(1,i) = ux(1,i);
r(2,i) = ux(2,i);
p(1,1,i) = 0;
p(1,2,i) = 0;
p(2,1,i) = 0;
p(2,2,i) = 1;
end;

function [beta, gamma, ires, user] = bndary(npde, t, u, ux, ibnd, ires, user)
beta = zeros(npde, 1);
gamma = zeros(npde, 1);

if (ibnd == 0)
beta(1) = 1;
gamma(1) = 0;
beta(2) = 0;
gamma(2) = u(1) - 1;
else
beta(1) = 1;
gamma(1) = 0;
beta(2) = 0;
gamma(2) = u(1) + 1;
end

function [u, user] = uinit(npde, npts, x, user)
u = zeros(npde, npts);

piby2 = pi/2;
for i = 1:double(npts)
u(1,i) = -sin(piby2*x(i));
u(2,i) = -piby2*piby2*u(1,i);
end

function plot_results(x, t, u, ident)
% Formatting for title and axis labels.
titleFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 14};
labFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 13};
set(gca, 'FontSize', 13); % for legend, axis tick labels, etc.

% Plot array as a mesh.
mesh(x, t, u);
set(gca, 'YScale', 'log');
set(gca, 'YTick', [0.00001 0.0001 0.001 0.01 0.1 1]);
set(gca, 'YMinorGrid', 'off');
set(gca, 'YMinorTick', 'off');

% Label the axes, and set the title.
xlabel('x', labFmt{:});
ylabel('t', labFmt{:});
zlabel([ident,'(x,t)'], labFmt{:});
title({['Solution ',ident,' of elliptic-parabolic pair'], ...
'using Chebyshev Collocation and BDF'}, titleFmt{:});

% Set the axes limits tight to the x and y range.
axis([x(1) x(end) t(1) t(end)]);

% Set the view to something nice (determined empirically).
view(-165, 44);
```
```
nag_pde_1d_parab_coll example program results
polynomial degree =    3    no. of elements =    9
accuracy requirement =  1.000e-04    number of points =    28

t / x        -1.0000 -0.6000 -0.2000  0.2000  0.6000  1.0000

0.0001  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
u(2) -2.4850 -1.9957 -0.7623  0.7623  1.9957  2.4850

0.0010  u(1)  1.0000  0.8086  0.3088 -0.3088 -0.8086 -1.0000
u(2) -2.5548 -1.9918 -0.7608  0.7608  1.9918  2.5548

0.0100  u(1)  1.0000  0.8055  0.3070 -0.3070 -0.8055 -1.0000
u(2) -2.6867 -1.9527 -0.7457  0.7457  1.9527  2.6867

0.1000  u(1)  1.0000  0.7955  0.2988 -0.2988 -0.7955 -1.0000
u(2) -2.8966 -1.8365 -0.6393  0.6393  1.8365  2.8966

1.0000  u(1)  1.0000  0.7939  0.2972 -0.2972 -0.7939 -1.0000
u(2) -2.9233 -1.8247 -0.6120  0.6120  1.8247  2.9233

Number of integration steps in time =     41
Number of function evaluations =    275
Number of Jacobian evaluations =     11
Number of iterations =     97

```
```function d03pd_example

% Solution of an elliptic-parabolic pair of PDEs
% (derived from a fourth-order PDE).

% Set values for problem parameters.
npde = 2;

% Number of points on interpolated mesh, number of break points.
intpts = 6;
nbkpts = 10;

% Order of Chebyshev polynomial.
npoly = 3;

itype = 1;

nel = nbkpts - 1;
npts = nel*npoly + 1;
mu = npde*(npoly + 1) - 1;
neqn = npde*npts;
lisave = neqn + 24;
npl1 = npoly + 1;
nwkres = 3*npl1*npl1 + npl1*(npde*npde + 6*npde+nbkpts+1) + 13*npde + 5;
lenode = (3*mu + 1)*neqn;
lrsave = 11*neqn + 50 + nwkres + lenode;

% Define some arrays.
rsave = zeros(lrsave, 1);
u = zeros(npde, npts);
uinterp = zeros(npde, intpts, itype);
x = zeros(npts, 1);
xbkpts = zeros(nbkpts, 1);

isave = zeros(lisave, 1, 'int64');
cwsav = {''; ''; ''; ''; ''; ''; ''; ''; ''; ''};
lwsav = false(100, 1);
iwsav = zeros(505, 1, 'int64');
rwsav = zeros(1100, 1);

% Set up the points on the interpolation grid.
xinterp = [-1.0 -0.6 -0.2 0.2 0.6 1.0];

acc = 1.0e-4;

itrace = 0;
m = 0; % Use cartesian coordinates.

% We run through the calculation twice; once to output the interpolated
% results, and once to store the results for plotting.
niter = [5, 20];

% Prepare to store plotting results.
tsav = zeros(niter(2), 1);
usav = zeros(2, niter(2), npts);
isav = 0;

fprintf(' d03pd example program results\n');
for icalc = 1:2

% Set the break points.
if icalc == 1
hx = 2.0/(nbkpts-1.0);
xbkpts(1) = -1.0;
xbkpts(nbkpts) = 1.0;
for i = 2:nbkpts-1
xbkpts(i) = xbkpts(i-1) + hx;
end
else
for i = 1:nbkpts
xbkpts(i) = -1.0 + (i - 1.0)*2.0/(nbkpts - 1.0);
end
end

% Set initial conditions.
ts = 0.0;
tout = 0.1e-4;
alpha = -log(tout)/(niter(2)-1.0);

% Start the integration in time.
ind = 0;

% Loop over endpoints for the integration.  We've set itask = 1, which
% gives normal computation of output values at t = tout.
for iter = 1:niter(icalc)

%Set the endpoint.
if icalc == 1
tout = 10.0*tout;
else
tout = exp(alpha*(iter - niter(icalc)));
end

% Calling this routine here, we always have ind set to 0, which
% (re)starts the integration in time - otherwise, the output x
% array is set to zero.
[ts, u, x, rsave, isave, indOut, user, cwsav, lwsav, iwsav, ...
rwsav, ifail] = d03pd(int64(m), ts, tout, @pdedef, ...
@bndary, u, xbkpts, int64(npoly), @uinit, ...
acc, rsave, isave, int64(itask), int64(itrace), int64(ind), ...
cwsav, lwsav, iwsav, rwsav);
if ifail ~= 0
% Parameters out of range, or convergence problems.
% Print message and exit.
fprintf('Warning: d03pd returned with ifail = %1d \n\n',ifail);
return;
end

if icalc == 1
% Output interpolation points first time through.
if iter == 1
fprintf([' polynomial degree = %4d', ...
'    no. of elements = %4d\n'], npoly, nel);
fprintf([' accuracy requirement = %10.3e', ...
'    number of points = %5d\n\n'], acc, npts);
fprintf(' t / x       ');
for i = 1:intpts
fprintf('%8.4f', xinterp(i));
end
fprintf('\n\n');
end

% Call d03py to do interpolation of results onto coarser grid.
[uinterp, rsave, ifail] = d03py(u, xbkpts, int64(npoly), ...
xinterp, int64(itype), rsave);
if ifail ~= 0
% Parameters out of range, or convergence problems.
% Print message and exit.
fprintf(['Warning: d03py returned with ifail = ', ...
'%1d \n\n'], ifail);
return;
end

% Output interpolated results for this time step.
fprintf('%7.4f  u(1)', ts);
for i = 1:intpts
fprintf('%8.4f', uinterp(1,i,1));
end
fprintf('\n');
fprintf('         u(2)');
for i = 1:intpts
fprintf('%8.4f', uinterp(2,i,1));
end
fprintf('\n\n');
else
% Save this timestep, and this set of results.
isav = isav+1;
tsav(isav) = ts;
for ipt = 1:npts
for isol = 1:2
usav(isol,isav,ipt) = u(isol,ipt);
end
end
end
end

if icalc == 1
% Output some statistics.
fprintf([' Number of integration steps in time = %6d\n', ...
' Number of function evaluations = %6d\n', ...
' Number of Jacobian evaluations = %6d\n', ...
' Number of iterations = %6d\n'], isave(1), isave(2), ...
isave(3), isave(5));
else
% Plot results.
fig1 = figure('Number', 'off');
plot_results(x, tsav, squeeze(usav(1,:,:)), 'U1');
fig2 = figure('Number', 'off');
plot_results(x, tsav, squeeze(usav(2,:,:)), 'U2');
end
end

function [p, q, r, ires, user] = pdedef(npde, t, x, nptl, u, ux, ires, user)
p = zeros(npde, npde, nptl);
q = zeros(npde, nptl);
r = zeros(npde, nptl);

for i = 1:double(nptl)
q(1,i) = u(2,i);
q(2,i) = u(1,i)*ux(2,i) - ux(1,i)*u(2,i);
r(1,i) = ux(1,i);
r(2,i) = ux(2,i);
p(1,1,i) = 0;
p(1,2,i) = 0;
p(2,1,i) = 0;
p(2,2,i) = 1;
end;

function [beta, gamma, ires, user] = bndary(npde, t, u, ux, ibnd, ires, user)
beta = zeros(npde, 1);
gamma = zeros(npde, 1);

if (ibnd == 0)
beta(1) = 1;
gamma(1) = 0;
beta(2) = 0;
gamma(2) = u(1) - 1;
else
beta(1) = 1;
gamma(1) = 0;
beta(2) = 0;
gamma(2) = u(1) + 1;
end

function [u, user] = uinit(npde, npts, x, user)
u = zeros(npde, npts);

piby2 = pi/2;
for i = 1:double(npts)
u(1,i) = -sin(piby2*x(i));
u(2,i) = -piby2*piby2*u(1,i);
end

function plot_results(x, t, u, ident)
% Formatting for title and axis labels.
titleFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 14};
labFmt = {'FontName', 'Helvetica', 'FontWeight', 'Bold', 'FontSize', 13};
set(gca, 'FontSize', 13); % for legend, axis tick labels, etc.

% Plot array as a mesh.
mesh(x, t, u);
set(gca, 'YScale', 'log');
set(gca, 'YTick', [0.00001 0.0001 0.001 0.01 0.1 1]);
set(gca, 'YMinorGrid', 'off');
set(gca, 'YMinorTick', 'off');

% Label the axes, and set the title.
xlabel('x', labFmt{:});
ylabel('t', labFmt{:});
zlabel([ident,'(x,t)'], labFmt{:});
title({['Solution ',ident,' of elliptic-parabolic pair'], ...
'using Chebyshev Collocation and BDF'}, titleFmt{:});

% Set the axes limits tight to the x and y range.
axis([x(1) x(end) t(1) t(end)]);

% Set the view to something nice (determined empirically).
view(-165, 44);
```
```
d03pd example program results
polynomial degree =    3    no. of elements =    9
accuracy requirement =  1.000e-04    number of points =    28

t / x        -1.0000 -0.6000 -0.2000  0.2000  0.6000  1.0000

0.0001  u(1)  1.0000  0.8090  0.3090 -0.3090 -0.8090 -1.0000
u(2) -2.4850 -1.9957 -0.7623  0.7623  1.9957  2.4850

0.0010  u(1)  1.0000  0.8086  0.3088 -0.3088 -0.8086 -1.0000
u(2) -2.5548 -1.9918 -0.7608  0.7608  1.9918  2.5548

0.0100  u(1)  1.0000  0.8055  0.3070 -0.3070 -0.8055 -1.0000
u(2) -2.6867 -1.9527 -0.7457  0.7457  1.9527  2.6867

0.1000  u(1)  1.0000  0.7955  0.2988 -0.2988 -0.7955 -1.0000
u(2) -2.8966 -1.8365 -0.6393  0.6393  1.8365  2.8966

1.0000  u(1)  1.0000  0.7939  0.2972 -0.2972 -0.7939 -1.0000
u(2) -2.9233 -1.8247 -0.6120  0.6120  1.8247  2.9233

Number of integration steps in time =     41
Number of function evaluations =    275
Number of Jacobian evaluations =     11
Number of iterations =     97

```