# naginterfaces.library.ode.ivp_​rkts_​range¶

naginterfaces.library.ode.ivp_rkts_range(f, twant, ygot, ymax, comm, data=None)[source]

ivp_rkts_range solves an initial value problem for a first-order system of ordinary differential equations using Runge–Kutta methods.

For full information please refer to the NAG Library document for d02pe

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/d02/d02pef.html

Parameters
fcallable yp = f(t, y, data=None)

must evaluate the functions (that is the first derivatives ) for given values of the arguments , .

Parameters
tfloat

, the current value of the independent variable.

yfloat, ndarray, shape

The current values of the dependent variables, , for .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ypfloat, array-like, shape

The values of , for .

twantfloat

, the next value of the independent variable where a solution is desired.

ygotfloat, array-like, shape

On the first call to ivp_rkts_range, need not be set. On all subsequent calls must remain unchanged.

ymaxfloat, array-like, shape

On the first call to ivp_rkts_range, need not be set. On all subsequent calls must remain unchanged.

commdict, communication object, modified in place

Communication structure.

This argument must have been initialized by a prior call to ivp_rkts_setup().

dataarbitrary, optional

User-communication data for callback functions.

Returns
tgotfloat

, the value of the independent variable at which a solution has been computed. On successful exit with no exception or warning is raised, will equal . On exit with > 1, a solution has still been computed at the value of but in general will not equal .

ygotfloat, ndarray, shape

An approximation to the true solution at the value of . At each step of the integration to , the local error has been controlled as specified in ivp_rkts_setup(). The local error has still been controlled even when , that is after a return with > 1.

ypgotfloat, ndarray, shape

An approximation to the first derivative of the true solution at .

ymaxfloat, ndarray, shape

contains the largest value of computed at any step in the integration so far.

Raises
NagValueError
(errno )

On entry, a previous call to the setup function has not been made or the communication arrays have become corrupted.

(errno )

On entry, , but the value passed to the setup function was .

(errno )

On entry, the communication arrays have become corrupted, or a catastrophic error has already been detected elsewhere. You cannot continue integrating the problem.

(errno )

is too close to the last value of ( on setup).

When using the method of order at setup, these must differ by at least . Their absolute difference is .

(errno )

lies beyond (setup) in the direction of integration.

and .

(errno )

lies beyond (setup) in the direction of integration, but is very close to .

You may have intended .

.

(errno )

does not lie in the direction of integration. .

(errno )

To start a new problem, you will need to call the setup function.

(errno )

You cannot call this function after it has returned an error.

You must call the setup function to start another problem.

(errno )

You cannot call this function when you have specified, in the setup function, that the step integrator will be used.

Warns
NagAlgorithmicWarning
(errno )

This function is being used inefficiently because the step size has been reduced drastically many times to obtain answers at many points. Using the order and pair method at setup is more appropriate here. You can continue integrating this problem.

(errno )

Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. However, you can continue integrating the problem.

(errno )

Approximately function evaluations have been used to compute the solution since the integration started or since this message was last printed. Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.

(errno )

Your problem has been diagnosed as stiff. If the situation persists, it will cost roughly times as much to reach (setup) as it has cost to reach the current time. You should probably call functions intended for stiff problems. However, you can continue integrating the problem.

(errno )

In order to satisfy your error requirements the solver has to use a step size of at the current time, . This step size is too small for the machine precision, and is smaller than .

(errno )

The global error assessment algorithm failed at start of integration.

The integration is being terminated.

(errno )

The global error assessment may not be reliable for times beyond .

The integration is being terminated.

Notes

ivp_rkts_range and its associated functions (ivp_rkts_setup(), ivp_rkts_diag() and ivp_rkts_errass()) solve an 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.

ivp_rkts_range is designed for the usual task, namely to compute an approximate solution at a sequence of points. You must first call ivp_rkts_setup() to specify the problem and how it is to be solved. Thereafter you call ivp_rkts_range repeatedly with successive values of , the points at which you require the solution, in the range from to (as specified in ivp_rkts_setup()). In this manner ivp_rkts_range returns the point at which it has computed a solution (usually ), the solution there () and its derivative (). If ivp_rkts_range encounters some difficulty in taking a step toward , then it returns the point of difficulty () and the solution and derivative computed there ( and , respectively).

In the call to ivp_rkts_setup() you can specify either the first step size for ivp_rkts_range to attempt or that it computes automatically an appropriate value. Thereafter ivp_rkts_range estimates an appropriate step size for its next step. This value and other details of the integration can be obtained after any call to ivp_rkts_range by a call to ivp_rkts_diag(). The local error is controlled at every step as specified in ivp_rkts_setup(). If you wish to assess the true error, you must set to a positive value in the call to ivp_rkts_setup(). This assessment can be obtained after any call to ivp_rkts_range by a call to ivp_rkts_errass().

For more complicated tasks, you are referred to functions ivp_rkts_onestep(), ivp_rkts_interp() and ivp_rkts_reset_tend(), all of which are used by ivp_rkts_range.

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