# NAG Library Routine Document

## 1Purpose

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

## 2Specification

Fortran Interface
 Subroutine d02xjf ( xsol, sol, m, ysav, neq, x, nqu, hu, h,
 Integer, Intent (In) :: m, ldysav, sdysav, neq, nqu Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: xsol, ysav(ldysav,sdysav), x, hu, h Real (Kind=nag_wp), Intent (Out) :: sol(m)
#include nagmk26.h
 void d02xjf_ (const double *xsol, double sol[], const Integer *m, const double ysav[], const Integer *ldysav, const Integer *sdysav, const Integer *neq, const double *x, const Integer *nqu, const double *hu, const double *h, Integer *ifail)

## 3Description

d02xjf evaluates the first $m$ components of the solution of a system of ordinary differential equations at any point using natural polynomial interpolation based on information generated by the integrator. This information must be passed unchanged to d02xjf. d02xjf should not normally be used to extrapolate outside the range of values obtained from the above routines.

None.

## 5Arguments

1:     $\mathbf{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:     $\mathbf{sol}\left({\mathbf{m}}\right)$ – 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:     $\mathbf{m}$ – IntegerInput
On entry: $m$, 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:     $\mathbf{ysav}\left({\mathbf{ldysav}},{\mathbf{sdysav}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the values provided in the argument ysav on return from the integrator.
5:     $\mathbf{ldysav}$ – IntegerInput
On entry: the value used for the argument ldysav when calling the integrator.
Constraint: ${\mathbf{ldysav}}\ge 1$.
6:     $\mathbf{sdysav}$ – IntegerInput
On entry: the value used for the argument sdysav when calling the integrator.
Constraint: ${\mathbf{sdysav}}\ge {\mathbf{nqu}}+1$.
7:     $\mathbf{neq}$ – IntegerInput
On entry: the value used for the argument neq when calling the integrator.
Constraint: $1\le {\mathbf{neq}}\le {\mathbf{ldysav}}$.
8:     $\mathbf{x}$ – Real (Kind=nag_wp)Input
On entry: the latest value at which the solution has been computed, as provided in the argument tcur on return from the optional output d02nyf.
9:     $\mathbf{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 argument nqu on return from the optional output d02nyf.
Constraint: ${\mathbf{nqu}}\ge 1$.
10:   $\mathbf{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 argument hu on return from the optional output d02nyf.
11:   $\mathbf{h}$ – Real (Kind=nag_wp)Input
On entry: the next step size to be attempted in the integration, as provided in the argument h on return from the optional output d02nyf.
12:   $\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).
If d02xjf 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}}$.

## 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$
 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$.
${\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 d02xjf.
${\mathbf{ifail}}=3$
d02xjf has been called for extrapolation. Before returning with this error exit, the value of the solution at xsol is calculated and placed in sol.
${\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.

## 7Accuracy

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

## 8Parallelism and Performance

d02xjf is not threaded in any implementation.

d02xjf is that employed for prediction purposes internally by the integrator. It is supplied for purposes of consistency only. You are recommended to employ the ${C}^{1}$ interpolant provided by d02xkf wherever possible.