D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02QZF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D02QZF interpolates components of the solution of a non-stiff system of first-order differential equations from information provided by the integrator routines D02QFF or D02QGF.

## 2  Specification

 SUBROUTINE D02QZF ( NEQF, TWANT, NWANT, YWANT, YPWANT, RWORK, LRWORK, IWORK, LIWORK, IFAIL)
 INTEGER NEQF, NWANT, LRWORK, IWORK(LIWORK), LIWORK, IFAIL REAL (KIND=nag_wp) TWANT, YWANT(NWANT), YPWANT(NWANT), RWORK(LRWORK)

## 3  Description

D02QZF evaluates the first NWANT components of the solution of a non-stiff system of first-order ordinary differential equations at any point using the method of Watts and Shampine (1986) and information generated by D02QFF or D02QGF. D02QZF should not normally be used to extrapolate outside the current range of the values produced by the integration routine.

## 4  References

Watts H A and Shampine L F (1986) Smoother interpolants for Adams codes SIAM J. Sci. Statist. Comput. 7 334–345

## 5  Parameters

1:     NEQF – INTEGERInput
On entry: the number of first-order ordinary differential equations being solved by the integration routine. It must contain the same value as the parameter NEQF in a prior call to the setup routine D02QWF.
2:     TWANT – REAL (KIND=nag_wp)Input
On entry: the point at which components of the solution and derivative are to be evaluated. TWANT should not normally be an extrapolation point, that is TWANT should satisfy
• $\mathit{told}\le {\mathbf{TWANT}}\le \mathrm{T}$,
or if integration is proceeding in the negative direction
• $\mathit{told}\ge {\mathbf{TWANT}}\ge \mathrm{T}$,
where $\mathit{told}$ is the previous integration point and is, to within rounding, TCURRHLAST (see D02QXF). Extrapolation is permitted but not recommended and ${\mathbf{IFAIL}}={\mathbf{2}}$ is returned whenever extrapolation is attempted.
3:     NWANT – INTEGERInput
On entry: the number of components of the solution and derivative whose values at TWANT are required. The first NWANT components are evaluated.
Constraint: $1\le {\mathbf{NWANT}}\le {\mathbf{NEQF}}$.
4:     YWANT(NWANT) – REAL (KIND=nag_wp) arrayOutput
On exit: the calculated value of the $\mathit{i}$th component of the solution at TWANT, for $\mathit{i}=1,2,\dots ,{\mathbf{NWANT}}$.
5:     YPWANT(NWANT) – REAL (KIND=nag_wp) arrayOutput
On exit: the calculated value of the $\mathit{i}$th component of the derivative at TWANT, for $\mathit{i}=1,2,\dots ,{\mathbf{NWANT}}$.
6:     RWORK(LRWORK) – REAL (KIND=nag_wp) arrayCommunication Array
On entry: this must be the same parameter RWORK as supplied to D02QWF and to D02QFF or D02QGF. It is used to pass information from these routines to D02QZF. Therefore its contents must not be changed before a call to D02QZF.
7:     LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which D02QZF is called.
This must be the same parameter LRWORK as supplied to D02QWF.
8:     IWORK(LIWORK) – INTEGER arrayCommunication Array
On entry: this must be the same parameter IWORK as supplied to D02QWF and to D02QFF or D02QGF. It is used to pass information from these routines to D02QZF. Therefore its contents must not be changed before a call to D02QZF.
9:     LIWORK – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which D02QZF is called.
This must be the same parameter LIWORK as supplied to D02QWF.
10:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{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$
An integration routine (D02QFF or D02QGF) has not been called, no integration steps have been taken since the last call to D02QWF with ${\mathbf{STATEF}}=\text{'S'}$, one or more of the parameters LRWORK, LIWORK and NEQF does not match the same parameter supplied to D02QWF, or NWANT does not satisfy $1\le {\mathbf{NWANT}}\le {\mathbf{NEQF}}$.
${\mathbf{IFAIL}}=2$
D02QZF has been called for extrapolation. The values of the solution and its derivative at TWANT have been calculated and placed in YWANT and YPWANT before returning with this warning (see Section 7).
These error exits may be caused by overwriting elements of RWORK and IWORK.

## 7  Accuracy

The error in interpolation is of a similar order to the error arising from the integration. The same order of accuracy can be expected when extrapolating using D02QZF. However, the actual error in extrapolation will, in general, be much larger than for interpolation.

When interpolation for only a few components is required then it is more efficient to order the components of interest so that they are numbered first.

## 9  Example

This example solves the equation
 $y′′=-y, y0=0, y′0=1$
reposed as
 $y1′=y2 y2′=-y1$
over the range $\left[0,\pi /2\right]$ with initial conditions ${y}_{1}=0$ and ${y}_{2}=1$ using vector error control (${\mathbf{VECTOL}}=\mathrm{.TRUE.}$) and D02QFF in one-step mode (${\mathbf{ONESTP}}=\mathrm{.TRUE.}$). D02QZF is used to provide solution values at intervals of $\pi /16$.

### 9.1  Program Text

Program Text (d02qzfe.f90)

### 9.2  Program Data

Program Data (d02qzfe.d)

### 9.3  Program Results

Program Results (d02qzfe.r)