d02 Chapter Contents
d02 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_ode_ivp_adams_interp (d02qzc)

## 1  Purpose

nag_ode_ivp_adams_interp (d02qzc) interpolates components of the solution of a non-stiff system of first order ordinary differential equations from information provided by nag_ode_ivp_adams_roots (d02qfc). Normally this function will be used in conjunction with the integration function, nag_ode_ivp_adams_roots (d02qfc), operating in one-step mode.

## 2  Specification

 #include #include
 void nag_ode_ivp_adams_interp (Integer neqf, double twant, Integer nwant, double ywant[], double ypwant[], Nag_ODE_Adams *opt, NagError *fail)

## 3  Description

nag_ode_ivp_adams_interp (d02qzc) 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 nag_ode_ivp_adams_roots (d02qfc). nag_ode_ivp_adams_interp (d02qzc) should not normally be used to extrapolate outside the current range of the values produced by the integration function.

## 4  References

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

## 5  Arguments

1:     neqfIntegerInput
On entry: the number of differential equations.
Constraint: ${\mathbf{neqf}}\ge 1$.
2:     twantdoubleInput
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
$\mathbf{opt}\mathbf{\to }\mathbf{tcurr}-\mathbf{opt}\mathbf{\to }\mathbf{hlast}\le {\mathbf{twant}}\le \mathbf{opt}\mathbf{\to }\mathbf{tcurr}$.
or if integration is proceeding in the negative direction
$\mathbf{opt}\mathbf{\to }\mathbf{tcurr}-\mathbf{opt}\mathbf{\to }\mathbf{hlast}\ge {\mathbf{twant}}\ge \mathbf{opt}\mathbf{\to }\mathbf{tcurr}$.
Extrapolation is permitted but not recommended and a fail value of NW_EXTRAPOLATION is returned whenever extrapolation is attempted.
3:     nwantIntegerInput
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:     ywant[nwant]doubleOutput
On exit: ${\mathbf{ywant}}\left[\mathit{i}-1\right]$ contains the calculated value of the $\mathit{i}$th component of the solution at twant, for $\mathit{i}=1,2,\dots ,{\mathbf{nwant}}$.
5:     ypwant[nwant]doubleOutput
On exit: ${\mathbf{ypwant}}\left[\mathit{i}-1\right]$ contains the calculated value of the $\mathit{i}$th component of the derivative at twant, for $\mathit{i}=1,2,\dots ,{\mathbf{nwant}}$.
On entry: the structure of type Nag_ODE_Adams as output from the integration function nag_ode_ivp_adams_roots (d02qfc). The structure must be passed unchanged. (See Section 8 for comments about deallocation of memory from opt.)
7:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_INT_ARG_LT
On entry, ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nwant}}\ge 1$.
NE_NEQF
The value of neqf supplied is not the same as that given to the setup function nag_ode_ivp_adams_setup (d02qwc). ${\mathbf{neqf}}=〈\mathit{\text{value}}〉$ but the value given to nag_ode_ivp_adams_setup (d02qwc) was $〈\mathit{\text{value}}〉$.
NE_NO_INTEGRATE
The integrator function nag_ode_ivp_adams_roots (d02qfc) has not been called.
NE_NO_STEPS
No successful integration steps were taken in the call(s) to the integration function nag_ode_ivp_adams_roots (d02qfc).
NE_NWANT_GT
nwant is greater than the value of neqf given to the setup function nag_ode_ivp_adams_setup (d02qwc). ${\mathbf{nwant}}=〈\mathit{\text{value}}〉$, ${\mathbf{neqf}}=〈\mathit{\text{value}}〉$.
NW_EXTRAPOLATION
Extrapolation requested, ${\mathbf{twant}}=〈\mathit{\text{value}}〉$.

## 7  Accuracy

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 nag_ode_ivp_adams_interp (d02qzc). However, the actual error in extrapolation will, in general, be much larger than for interpolation.

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.
The structure opt will contain pointers which have been allocated memory during a call to nag_ode_ivp_adams_setup (d02qwc). This allocated memory is used by nag_ode_ivp_adams_roots (d02qfc) and nag_ode_ivp_adams_interp (d02qzc). When all calls to these functions have been completed the function nag_ode_ivp_adams_free (d02qyc) may be called to free the allocated memory from the structure.

## 9  Example

This example solves the equation
 $y ′′ = -y , y 0 = 0 , y ′ 0 = 1$
reposed as
 $y 1 ′ = y 2 y 2 ′ = - y 1$
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{Nag_TRUE}$) and nag_ode_ivp_adams_roots (d02qfc) in one-step mode (${\mathbf{one_step}}=\mathrm{Nag_TRUE}$). nag_ode_ivp_adams_interp (d02qzc) is used to provide solution values at intervals of $\pi /16$.

### 9.1  Program Text

Program Text (d02qzce.c)

None.

### 9.3  Program Results

Program Results (d02qzce.r)