The function may be called by the names: d02psc or nag_ode_ivp_rkts_interp.
d02psc and its associated functions (d02pfc,d02pqc,d02prc,d02ptcandd02puc) solve the initial value problem for a first-order system of ordinary differential equations. The functions, based on Runge–Kutta methods and derived from RKSUITE (see Brankin et al. (1991)), integrate
where is the vector of solution components and is the independent variable.
d02pfc computes the solution at the end of an integration step. Using the information computed on that step d02psc computes the solution by interpolation at any point on that step. It cannot be used if was specified in the call to setup function d02pqc.
Brankin R W, Gladwell I and Shampine L F (1991) RKSUITE: A suite of Runge–Kutta codes for the initial value problems for ODEs SoftReport 91-S1 Southern Methodist University
1: – IntegerInput
On entry: , the number of ordinary differential equations in the system to be solved by the integration function.
2: – doubleInput
On entry: , the value of the independent variable where a solution is desired.
3: – Nag_SolDerivInput
On entry: determines whether the solution and/or its first derivative are to be computed
compute approximate solution.
compute approximate first derivative.
compute approximate solution and first derivative.
, or .
4: – IntegerInput
On entry: the number of components of the solution to be computed. The first nwant components are evaluated.
5: – doubleOutput
On exit: an approximation to the first nwant components of the solution at twant if or . Otherwise ywant is not defined.
6: – doubleOutput
On exit: an approximation to the first nwant components of the first derivative at twant if or . Otherwise ypwant is not defined.
7: – function, supplied by the userExternal Function
f must evaluate the functions (that is the first derivatives ) for given values of the arguments . It must be the same procedure as supplied to d02pfc.
f (double t,Integer n,const double y,double yp,Nag_Comm *comm)
1: – doubleInput
On entry: , the current value of the independent variable.
2: – IntegerInput
On entry: , the number of ordinary differential equations in the system to be solved.
3: – const doubleInput
On entry: the current values of the dependent variables,
, for .
4: – doubleOutput
On exit: the values of
, for .
5: – Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to f.
user – double *
iuser – Integer *
p – Pointer
The type Pointer will be void *. Before calling d02psc you may allocate memory and initialize these pointers with various quantities for use by f when called from d02psc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
Note:f should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by d02psc. If your code inadvertently does return any NaNs or infinities, d02psc is likely to produce unexpected results.
8: – doubleCommunication Array
On entry: this array stores information that can be utilized on subsequent calls to d02psc.
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
11: – IntegerCommunication Array
12: – doubleCommunication Array
On entry: these must be the same arrays supplied in a previous call d02pfc. They must remain unchanged between calls.
On exit: information about the integration for use on subsequent calls to d02pfc, d02psc or other associated functions.
13: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
Constraint: for , .
On entry, and . Constraint: .
On entry, , and .
Constraint: for , .
On entry, , but the value passed to the setup function was .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
You cannot call this function before you have called the step integrator.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
On entry, a previous call to the setup function has not been made or the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere. You cannot continue integrating the problem.
You cannot call this function after the integrator has returned an error.
You cannot call this function when you have specified, in the setup function, that the range integrator will be used.
in setup, but interpolation is not available for this method. Either use in setup or use reset function to force the integrator to step to particular points.
The computed values will be of a similar accuracy to that computed by d02pfc.
8Parallelism and Performance
d02psc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
This example solves the equation
over the range with initial conditions and . Relative error control is used with threshold values of for each solution component. d02pfc is used to integrate the problem one step at a time and d02psc is used to compute the first component of the solution and its derivative at intervals of length across the range whenever these points lie in one of those integration steps. A low order Runge–Kutta method () is also used with tolerances and in turn so that solutions may be compared.