D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02LZF

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

D02LZF interpolates components of the solution of a non-stiff system of second-order differential equations from information provided by the integrator D02LAF, when the low-order method has been used.

## 2  Specification

 SUBROUTINE D02LZF ( NEQ, T, Y, YP, NWANT, TWANT, YWANT, YPWANT, RWORK, LRWORK, IFAIL)
 INTEGER NEQ, NWANT, LRWORK, IFAIL REAL (KIND=nag_wp) T, Y(NEQ), YP(NEQ), TWANT, YWANT(NWANT), YPWANT(NWANT), RWORK(LRWORK)

## 3  Description

D02LZF evaluates the first ${\mathbf{NWANT}}$ ($\text{}\le {\mathbf{NEQ}}$) components of the solution of a non-stiff system of second-order ordinary differential equations at any point using a special Runge–Kutta–Nystrom formula (see Dormand and Prince (1986)) and information generated by D02LAF when the low-order method has been used. This information must be presented unchanged to D02LZF. D02LZF should not normally be used to extrapolate outside the range of the values from D02LAF.

## 4  References

Dormand J R and Prince P J (1986) Runge–Kutta–Nystrom triples Mathematical Report TP-CS-86-05 Teesside Polytechnic

## 5  Parameters

1:     NEQ – INTEGERInput
On entry: the number of second-order ordinary differential equations being solved by D02LAF. It must contain the same value as the parameter NEQ in a prior call to D02LAF.
2:     T – REAL (KIND=nag_wp)Input
On entry: $t$, the current value at which the solution and its derivative have been computed (as returned in parameter T on output from D02LAF).
3:     Y(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: the $\mathit{i}$th component of the solution at $t$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$, as returned from D02LAF.
4:     YP(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: the $\mathit{i}$th component of the derivative at $t$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$, as returned from D02LAF.
5:     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{NEQ}}$.
6:     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
 $told≤TWANT≤T,$
or if integration is proceeding in the negative direction
 $told≥TWANT≥T,$
where told is the previous integration point which is held in an element of the array RWORK and is, to within rounding, ${\mathbf{T}}-{\mathbf{HUSED}}$. (HUSED is given by D02LYF.) Extrapolation is permitted but not recommended, and ${\mathbf{IFAIL}}={\mathbf{2}}$ is returned whenever extrapolation is attempted.
7:     YWANT(NWANT) – REAL (KIND=nag_wp) arrayOutput
On exit: the calculated value of the $\mathit{i}$th component of the solution at $t={\mathbf{TWANT}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NWANT}}$.
8:     YPWANT(NWANT) – REAL (KIND=nag_wp) arrayOutput
On exit: the calculated value of the $\mathit{i}$th component of the derivative at $t={\mathbf{TWANT}}$, for $\mathit{i}=1,2,\dots ,{\mathbf{NWANT}}$.
9:     RWORK(LRWORK) – REAL (KIND=nag_wp) arrayCommunication Array
On entry: this must be the same parameter RWORK as supplied to D02LAF. It is used to pass information from D02LAF to D02LZF and therefore the contents of this array must not be changed before calling D02LZF.
10:   LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which D02LZF is called.
This must be the same parameter LRWORK as supplied to the setup routine D02LXF.
11:   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).
If D02LZF is to be used for extrapolation at TWANT, IFAIL should be set to $1$ before entry. It is then essential to test the value of IFAIL on exit.

## 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$
Illegal input detected, i.e., one of the following conditions:
 – D02LAF has not been called; – one or both of the parameters NEQ and LRWORK does not match the corresponding parameter supplied to the setup routine D02LXF; – no integration steps have been taken since the last call to D02LXF with ${\mathbf{START}}=\mathrm{.TRUE.}$; – ${\mathbf{NWANT}}<1$ or ${\mathbf{NWANT}}>{\mathbf{NEQ}}$.
This error exit can be caused if elements of RWORK have been overwritten.
${\mathbf{IFAIL}}=2$
D02LZF 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 error number (see Section 7).
${\mathbf{IFAIL}}=3$
D02LAF last used the high order method to integrate the system of differential equations. Interpolation is not permitted with this method.

## 7  Accuracy

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