Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_ode_ivp_stiff_nat_interp (d02xj)

## Purpose

nag_ode_ivp_stiff_nat_interp (d02xj) 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.

## Syntax

[sol, ifail] = d02xj(xsol, m, ysav, neq, x, nqu, hu, h, 'sdysav', sdysav)
[sol, ifail] = nag_ode_ivp_stiff_nat_interp(xsol, m, ysav, neq, x, nqu, hu, h, 'sdysav', sdysav)

## Description

nag_ode_ivp_stiff_nat_interp (d02xj) evaluates the first m$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 nag_ode_ivp_stiff_nat_interp (d02xj). nag_ode_ivp_stiff_nat_interp (d02xj) should not normally be used to extrapolate outside the range of values obtained from the above functions.

None.

## Parameters

### Compulsory Input Parameters

1:     xsol – double scalar
The point at which the first m$m$ components of the solution are to be evaluated. xsol should not be an extrapolation point, that is xsol should satisfy (xsolx) × hu0.0$\left({\mathbf{xsol}}-{\mathbf{x}}\right)×{\mathbf{hu}}\le 0.0$. Extrapolation is permitted but not recommended.
2:     m – int64int32nag_int scalar
m$m$, the number of components of the solution whose values at xsol are required. The first m components are evaluated.
Constraint: 1mneq$1\le {\mathbf{m}}\le {\mathbf{neq}}$.
3:     ysav(ldysav,sdysav) – double array
ldysav, the first dimension of the array, must satisfy the constraint ldysav1$\mathit{ldysav}\ge 1$.
The values provided in the parameter ysav on return from the integrator.
4:     neq – int64int32nag_int scalar
The value used for the parameter neq when calling the integrator.
Constraint: 1neqldysav$1\le {\mathbf{neq}}\le \mathit{ldysav}$.
5:     x – double scalar
The latest value at which the solution has been computed, as provided in the parameter tcur on return from the optional output nag_ode_ivp_stiff_integ_diag (d02ny).
6:     nqu – int64int32nag_int scalar
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 nag_ode_ivp_stiff_integ_diag (d02ny).
Constraint: nqu1${\mathbf{nqu}}\ge 1$.
7:     hu – double scalar
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 nag_ode_ivp_stiff_integ_diag (d02ny).
8:     h – double scalar
The next step size to be attempted in the integration, as provided in the parameter h on return from the optional output nag_ode_ivp_stiff_integ_diag (d02ny).

### Optional Input Parameters

1:     sdysav – int64int32nag_int scalar
Default: The second dimension of the array ysav.
The value used for the parameter sdysav when calling the integrator.
Constraint: sdysavnqu + 1${\mathbf{sdysav}}\ge {\mathbf{nqu}}+1$.

ldysav

### Output Parameters

1:     sol(m) – double array
The calculated value of the i$\mathit{i}$th component of the solution at xsol, for i = 1,2,,m$\mathit{i}=1,2,\dots ,m$.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).
If nag_ode_ivp_stiff_nat_interp (d02xj) is to be used for extrapolation, ifail must be set to 1$1$ before entry. It is then essential to test the value of ifail on exit for ${\mathbf{ifail}}={\mathbf{1}}$ or 2${\mathbf{2}}$.

## Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, m < 1${\mathbf{m}}<1$, or neq < 1${\mathbf{neq}}<1$, or ldysav < 1$\mathit{ldysav}<1$, or neq > ldysav${\mathbf{neq}}>\mathit{ldysav}$, or m > neq${\mathbf{m}}>{\mathbf{neq}}$, or nqu < 1${\mathbf{nqu}}<1$, or sdysav < nqu + 1${\mathbf{sdysav}}<{\mathbf{nqu}}+1$.
ifail = 2${\mathbf{ifail}}=2$
On entry, hu = 0.0${\mathbf{hu}}=0.0$ or h = 0.0${\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 nag_ode_ivp_stiff_nat_interp (d02xj).
W ifail = 3${\mathbf{ifail}}=3$
nag_ode_ivp_stiff_nat_interp (d02xj) has been called for extrapolation. Before returning with this error exit, the value of the solution at xsol is calculated and placed in sol.

## Accuracy

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

nag_ode_ivp_stiff_nat_interp (d02xj) is that employed for prediction purposes internally by the integrator. It is supplied for purposes of consistency only. You are recommended to employ the C1${C}^{1}$ interpolant provided by nag_ode_ivp_stiff_c1_interp (d02xk) wherever possible.

## Example

```function nag_ode_ivp_stiff_nat_interp_example
xsol = 0.02;
m = int64(3);
ysave = [0.9992010426063869, -9.014310377562871e-06, 6.812799519478248e-10, ...
4.431544977419294e-13, 0, 3.646603065905307e-06;
3.637754720562377e-05, -1.43245286845343e-09, -1.690946415679345e-09, ...
4.645881910091972e-09, -5.351301001679175e-39, -5.764408311856045e-06;
0.0007625798464070455, 9.015742830431324e-06, 1.009666463731707e-09, ...
-4.64632506458996e-09, -0.2374434471130371, 2.117805245939617e-06];
neq = int64(3);
x = 0.02004966865187021;
nqu = int64(1);
hu = 0.0002271142424177253;
h = 0.0002271142424177253;
[sol, ifail] = nag_ode_ivp_stiff_nat_interp(xsol, m, ysave, neq, x, nqu, hu, h)
```
```

sol =

0.9992
0.0000
0.0008

ifail =

0

```
```function d02xj_example
xsol = 0.02;
m = int64(3);
ysave = [0.9992010426063869, -9.014310377562871e-06, 6.812799519478248e-10, ...
4.431544977419294e-13, 0, 3.646603065905307e-06;
3.637754720562377e-05, -1.43245286845343e-09, -1.690946415679345e-09, ...
4.645881910091972e-09, -5.351301001679175e-39, -5.764408311856045e-06;
0.0007625798464070455, 9.015742830431324e-06, 1.009666463731707e-09, ...
-4.64632506458996e-09, -0.2374434471130371, 2.117805245939617e-06];
neq = int64(3);
x = 0.02004966865187021;
nqu = int64(1);
hu = 0.0002271142424177253;
h = 0.0002271142424177253;
[sol, ifail] = d02xj(xsol, m, ysave, neq, x, nqu, hu, h)
```
```

sol =

0.9992
0.0000
0.0008

ifail =

0

```