D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD02XKF

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

D02XKF interpolates components of the solution of a system of first-order ordinary differential equations from information provided by the integrators in sub-chapter D02M–N. It provides ${C}^{1}$ interpolation suitable for general use.

## 2  Specification

 SUBROUTINE D02XKF ( XSOL, SOL, M, YSAV, LDYSAV, SDYSAV, ACOR, NEQ, X, NQU, HU, H, IFAIL)
 INTEGER M, LDYSAV, SDYSAV, NEQ, NQU, IFAIL REAL (KIND=nag_wp) XSOL, SOL(M), YSAV(LDYSAV,SDYSAV), ACOR(NEQ), X, HU, H

## 3  Description

D02XKF evaluates the first $m$ components of the solution of a system of ordinary differential equations at any point using ${C}^{1}$ polynomial interpolation based on information generated by the integrator. This information must be passed unchanged to D02XKF. D02XKF should not normally be used to extrapolate outside the range of values obtained from the above routines.
It may be used with the D02N routines only when the BDF integration method is being employed (setup routine D02NVF), provided the Petzold error test was not selected.

None.

## 5  Parameters

1:     XSOL – REAL (KIND=nag_wp)Input
On entry: the point at which the first $m$ components of the solution are to be evaluated. XSOL should not be an extrapolation point, that is XSOL should satisfy $\left({\mathbf{XSOL}}-{\mathbf{X}}\right)×{\mathbf{HU}}\le 0.0$. Extrapolation is permitted but not recommended.
2:     SOL(M) – REAL (KIND=nag_wp) arrayOutput
On exit: the calculated value of the $\mathit{i}$th component of the solution at XSOL, for $\mathit{i}=1,2,\dots ,m$.
3:     M – INTEGERInput
On entry: the number of components of the solution whose values at XSOL are required. The first $m$ components are evaluated.
Constraint: $1\le {\mathbf{M}}\le {\mathbf{NEQ}}$.
4:     YSAV(LDYSAV,SDYSAV) – REAL (KIND=nag_wp) arrayInput
On entry: the values provided in the parameter YSAV on return from the integrator.
5:     LDYSAV – INTEGERInput
On entry: the value used for the parameter LDYSAV when calling the integrator.
Constraint: ${\mathbf{LDYSAV}}\ge 1$.
6:     SDYSAV – INTEGERInput
On entry: the value used for the parameter SDYSAV when calling the integrator.
Constraint: ${\mathbf{SDYSAV}}\ge {\mathbf{NQU}}+1$.
7:     ACOR(NEQ) – REAL (KIND=nag_wp) arrayInput
On entry: the value returned in position $\left({\mathbf{LDYSAV}}+50+\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$, of the parameter RWORK returned by the integrator. If one of the forward communication D02N routines is being employed and D02XKF is to be used in MONITR, then ${\mathbf{ACOR}}\left(\mathit{i}\right)$ must contain the value given in position $\left(\mathit{i},2\right)$ of the MONITR parameter ACOR, for $\mathit{i}=1,2,\dots ,{\mathbf{NEQ}}$ (e.g., see D02NBF).
8:     NEQ – INTEGERInput
On entry: the value used for the parameter NEQ when calling the integrator.
Constraint: $1\le {\mathbf{NEQ}}\le {\mathbf{LDYSAV}}$.
9:     X – REAL (KIND=nag_wp)Input
On entry: the latest value at which the solution has been computed, as provided in the parameter TCUR on return from the optional output D02NYF.
10:   NQU – INTEGERInput
On entry: the order of the method used up to the latest value at which the solution has been computed, as provided in the parameter NQU on return from the optional output D02NYF.
Constraint: ${\mathbf{NQU}}\ge 1$.
11:   HU – REAL (KIND=nag_wp)Input
On entry: the last successful step used, that is the step used in the integration to get to X, as provided in the parameter HU on return from the optional output D02NYF.
12:   H – REAL (KIND=nag_wp)Input
On entry: the next step size to be attempted in the integration, as provided in the parameter H on return from the optional output D02NYF.
13:   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 D02XKF is to be used for extrapolation, IFAIL must be set to $1$ before entry. It is then essential to test the value of IFAIL on exit for ${\mathbf{IFAIL}}={\mathbf{1}}$ or ${\mathbf{2}}$.

## 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$
 On entry, ${\mathbf{M}}<1$, or ${\mathbf{NEQ}}<1$, or ${\mathbf{LDYSAV}}<1$, or ${\mathbf{NEQ}}>{\mathbf{LDYSAV}}$, or ${\mathbf{M}}>{\mathbf{NEQ}}$, or ${\mathbf{NQU}}<1$, or ${\mathbf{SDYSAV}}<{\mathbf{NQU}}+1$, or the BDF integrator was not previously used, or the Petzold error test, if applicable, was used.
${\mathbf{IFAIL}}=2$
On entry, ${\mathbf{HU}}=0.0$ or ${\mathbf{H}}=0.0$. This error can only occur if H and HU have been changed by you or possibly if the integrator has failed before calling D02XKF.
${\mathbf{IFAIL}}=3$
D02XKF has been called for extrapolation. Before returning with this error exit, the value of the solution at XSOL is calculated and placed in SOL.

## 7  Accuracy

The solution values returned will be of a similar accuracy to those computed by the integrator.

D02XKF provides a ${C}^{1}$ interpolant and as such is ideal for most applications, for example for tabulation and root-finding. In general D02XKF should be preferred to D02XJF for interpolation as the latter provides only a ${C}^{0}$ interpolant. D02XJF is the natural interpolant employed by the BDF method and it is supplied only to permit you to reproduce the internal values used by the integrator.