NAG Library Function Document

nag_ode_ivp_adams_interp (d02qzc)


    1  Purpose
    7  Accuracy


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.


#include <nag.h>
#include <nagd02.h>
void  nag_ode_ivp_adams_interp (Integer neqf, double twant, Integer nwant, double ywant[], double ypwant[], Nag_ODE_Adams *opt, NagError *fail)


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.


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


1:     neqf IntegerInput
On entry: the number of differential equations.
Constraint: neqf1 .
2:     twant doubleInput
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
opttcurr - opthlast twant opttcurr.
or if integration is proceeding in the negative direction
opttcurr - opthlast twant opttcurr.
Extrapolation is permitted but not recommended and a fail value of NW_EXTRAPOLATION is returned whenever extrapolation is attempted.
3:     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 nwant neqf .
4:     ywant[nwant] doubleOutput
On exit: ywant[i-1]  contains the calculated value of the i th component of the solution at twant, for i=1,2,,nwant.
5:     ypwant[nwant] doubleOutput
On exit: ypwant[i-1]  contains the calculated value of the i th component of the derivative at twant, for i=1,2,,nwant.
6:     opt Nag_ODE_Adams *Input
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 9 for comments about deallocation of memory from opt.)
7:     fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

Error Indicators and Warnings

On entry, nwant=value.
Constraint: nwant1.
The value of neqf supplied is not the same as that given to the setup function nag_ode_ivp_adams_setup (d02qwc). neqf=value  but the value given to nag_ode_ivp_adams_setup (d02qwc) was value.
The integrator function nag_ode_ivp_adams_roots (d02qfc) has not been called.
No successful integration steps were taken in the call(s) to the integration function nag_ode_ivp_adams_roots (d02qfc).
nwant is greater than the value of neqf given to the setup function nag_ode_ivp_adams_setup (d02qwc). nwant=value , neqf=value .
Extrapolation requested, twant=value .


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.

Parallelism and Performance

nag_ode_ivp_adams_interp (d02qzc) is not threaded in any implementation.

Further Comments

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.


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 0,π/2  with initial conditions y 1 = 0  and y 2 = 1  using vector error control ( vectol=Nag_TRUE ) and nag_ode_ivp_adams_roots (d02qfc) in one-step mode ( one_step=Nag_TRUE ). nag_ode_ivp_adams_interp (d02qzc) is used to provide solution values at intervals of π/16 .

Program Text

Program Text (d02qzce.c)

Program Data


Program Results

Program Results (d02qzce.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017