# NAG Library Routine Document

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine d02qzf ( neqf,
 Integer, Intent (In) :: neqf, nwant, lrwork, iwork(liwork), liwork Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: twant, rwork(lrwork) Real (Kind=nag_wp), Intent (Out) :: ywant(nwant), ypwant(nwant)
#include nagmk26.h
 void d02qzf_ (const Integer *neqf, const double *twant, const Integer *nwant, double ywant[], double ypwant[], const double rwork[], const Integer *lrwork, const Integer iwork[], const Integer *liwork, Integer *ifail)

## 3Description

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.

## 4References

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

## 5Arguments

1:     $\mathbf{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 argument neqf in a prior call to the setup routine d02qwf.
2:     $\mathbf{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:     $\mathbf{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:     $\mathbf{ywant}\left({\mathbf{nwant}}\right)$ – 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:     $\mathbf{ypwant}\left({\mathbf{nwant}}\right)$ – 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:     $\mathbf{rwork}\left({\mathbf{lrwork}}\right)$ – Real (Kind=nag_wp) arrayCommunication Array
On entry: this must be the same argument 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:     $\mathbf{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 argument lrwork as supplied to d02qwf.
8:     $\mathbf{iwork}\left({\mathbf{liwork}}\right)$ – Integer arrayCommunication Array
On entry: this must be the same argument 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:     $\mathbf{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 argument liwork as supplied to d02qwf.
10:   $\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$
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 arguments lrwork, liwork and neqf does not match the same argument 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).
${\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.
These error exits may be caused by overwriting elements of rwork and iwork.

## 7Accuracy

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.

## 8Parallelism and Performance

d02qzf is not thread safe and should not be called from a multithreaded user program. Please see Section 3.12.1 in How to Use the NAG Library and its Documentation for more information on thread safety.
d02qzf is not threaded in any implementation.

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.

## 10Example

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$.

### 10.1Program Text

Program Text (d02qzfe.f90)

### 10.2Program Data

Program Data (d02qzfe.d)

### 10.3Program Results

Program Results (d02qzfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017