D02PXF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

D02PXF computes the solution of a system of ordinary differential equations using interpolation anywhere on an integration step taken by D02PDF.

2  Specification


3  Description

D02PXF and its associated routines (D02PDF, D02PVF, D02PWF, D02PYF and D02PZF) solve the initial value problem for a first-order system of ordinary differential equations. The routines, based on Runge–Kutta methods and derived from RKSUITE (see Brankin et al. (1991)), integrate
y=ft,y  given  yt0=y0
where y is the vector of n solution components and t is the independent variable.
D02PDF computes the solution at the end of an integration step. Using the information computed on that step D02PXF computes the solution by interpolation at any point on that step. It cannot be used if METHOD=3 was specified in the call to setup routine D02PVF.

4  References

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

5  Parameters

1:     TWANT – REAL (KIND=nag_wp)Input
On entry: t, the value of the independent variable where a solution is desired.
2:     REQEST – CHARACTER(1)Input
On entry: determines whether the solution and/or its first derivative are to be computed.
Compute the approximate solution only.
Compute the approximate first derivative of the solution only.
Compute both the approximate solution and its first derivative.
Constraint: REQEST='S', 'D' or 'B'.
3:     NWANT – INTEGERInput
On entry: the number of components of the solution to be computed. The first NWANT components are evaluated.
Constraint: 1NWANTn, where n is specified by NEQ in the prior call to D02PVF.
4:     YWANT(*) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array YWANT must be at least NWANT if REQEST='S' or 'B', and at least 1 otherwise.
On exit: an approximation to the first NWANT components of the solution at TWANT if REQEST='S' or 'B'. Otherwise YWANT is not defined.
5:     YPWANT(*) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array YPWANT must be at least NWANT if REQEST='D' or 'B', and at least 1 otherwise.
On exit: an approximation to the first NWANT components of the first derivative at TWANT if REQEST='D' or 'B'. Otherwise YPWANT is not defined.
6:     F – SUBROUTINE, supplied by the user.External Procedure
F must evaluate the functions fi (that is the first derivatives yi) for given values of the arguments t,yi. It must be the same procedure as supplied to D02PDF.
The specification of F is:
REAL (KIND=nag_wp)  T, Y(*), YP(*)
In the description of the parameters of D02PXF below, n denotes the value of NEQ in the call of D02PVF.
1:     T – REAL (KIND=nag_wp)Input
On entry: t, the current value of the independent variable.
2:     Y(*) – REAL (KIND=nag_wp) arrayInput
On entry: the current values of the dependent variables, yi, for i=1,2,,n.
3:     YP(*) – REAL (KIND=nag_wp) arrayOutput
On exit: the values of fi, for i=1,2,,n.
F must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which D02PXF is called. Parameters denoted as Input must not be changed by this procedure.
7:     WORK(*) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array WORK must be at least LENWRK (see D02PVF).
On entry: this must be the same array as supplied to D02PDF and must remain unchanged between calls.
On exit: contains information about the integration for use on subsequent calls to D02PDF or other associated routines.
8:     WRKINT(LENINT) – REAL (KIND=nag_wp) arrayInput/Output
On entry: must be the same array as supplied in previous calls, if any, and must remain unchanged between calls to D02PXF.
On exit: the contents are modified.
9:     LENINT – INTEGERInput
On entry: the dimension of the array WRKINT as declared in the (sub)program from which D02PXF is called.
  • LENINT1 if METHOD=1 in the prior call to D02PVF;
  • LENINTn+5×NWANT if METHOD=2 and n is specified by NEQ in the prior call to D02PVF.
10:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ 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 parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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:
On entry, an invalid input value for NWANT or LENINT was detected or an invalid call to D02PXF was made, for example without a previous call to the integration routine D02PDF, or after an error return from D02PDF, or if D02PDF was being used with METHOD=3. You cannot continue integrating the problem.

7  Accuracy

The computed values will be of a similar accuracy to that computed by D02PDF.

8  Further Comments


9  Example

This example solves the equation
y = -y ,   y0=0,   y0=1
reposed as
y1 = y2
y2 = -y1
over the range 0,2π with initial conditions y1=0.0 and y2=1.0. Relative error control is used with threshold values of 1.0E−8 for each solution component. D02PDF is used to integrate the problem one step at a time and D02PXF is used to compute the first component of the solution and its derivative at intervals of length π/8 across the range whenever these points lie in one of those integration steps. A moderate order Runge–Kutta method (METHOD=2) is also used with tolerances TOL=1.0E−3 and TOL=1.0E−4 in turn so that solutions may be compared. The value of π is obtained by using X01AAF.
Note that the length of WORK is large enough for any valid combination of input arguments to D02PVF and the length of WRKINT is large enough for any valid value of the parameter NWANT.

9.1  Program Text

Program Text (d02pxfe.f90)

9.2  Program Data

Program Data (d02pxfe.d)

9.3  Program Results

Program Results (d02pxfe.r)

Produced by GNUPLOT 4.4 patchlevel 0 -1 -0.5 0 0.5 1 0 1 2 3 4 5 6 7 Solution t Example Program Simple Sine Solution, TOL = 0.001 solution derivative

D02PXF (PDF version)
D02 Chapter Contents
D02 Chapter Introduction
NAG Library Manual

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