# naginterfaces.library.ode.ivp_​rkm_​val_​simple¶

naginterfaces.library.ode.ivp_rkm_val_simple(x, xend, y, tol, hmax, m, val, fcn, data=None)[source]

ivp_rkm_val_simple integrates a system of first-order ordinary differential equations over an interval with suitable initial conditions, using a Runge–Kutta–Merson method, until a specified component attains a given value.

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

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/d02/d02bgf.html

Parameters
xfloat

Must be set to the initial value of the independent variable .

xendfloat

The final value of the independent variable .

If on entry integration will proceed in the negative direction.

yfloat, array-like, shape

The initial values of the solution .

tolfloat

Must be set to a positive tolerance for controlling the error in the integration and in the determination of the position where .

ivp_rkm_val_simple has been designed so that, for most problems, a reduction in leads to an approximately proportional reduction in the error in the solution obtained in the integration.

The relation between changes in and the error in the determination of the position where is less clear, but for small enough the error should be approximately proportional to .

However, the actual relation between and the accuracy cannot be guaranteed.

You are strongly recommended to call ivp_rkm_val_simple with more than one value for and to compare the results obtained to estimate their accuracy.

In the absence of any prior knowledge you might compare results obtained by calling ivp_rkm_val_simple with and if correct decimal digits in the solution are required.

hmaxfloat

Controls how the sign of is checked.

is checked at every internal integration step.

The computed solution is checked for a change in sign of at steps of not greater than . This facility should be used if there is any chance of ‘missing’ the change in sign by checking too infrequently. For example, if two changes of sign of are expected within a distance , say, of each other then a suitable value for might be . If only one change of sign in is expected on the range to then is most appropriate.

mint

The index of the component of the solution whose value is to be checked.

valfloat

The value of in the equation to be solved for .

fcncallable f = fcn(x, y, data=None)

must evaluate the functions (i.e., the derivatives ) for given values of its arguments .

Parameters
xfloat

, the value of the argument.

yfloat, ndarray, shape

, for , the value of the argument.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
ffloat, array-like, shape

The value of , for .

dataarbitrary, optional

User-communication data for callback functions.

Returns
xfloat

The point where the component attains the value unless an error has occurred, when it contains the value of at the error. In particular, if anywhere on the range to , it will contain on exit.

yfloat, ndarray, shape

The computed values of the solution at a point near the solution , unless an error has occurred when they contain the computed values at the final value of .

tolfloat

Normally unchanged. However if the range from to the position where (or to the final value of if an error occurs) is so short that a small change in is unlikely to make any change in the computed solution then, on return, has its sign changed. To check results returned with , ivp_rkm_val_simple should be called again with a positive value of whose magnitude is considerably smaller than that of the previous call.

Raises
NagValueError
(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

The value of , , is too small for the function to make any further progress across the integration range. Current value of .

(errno )

The value of , , is too small for the function to take an initial step.

(errno )

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.

(errno )

A serious error occurred in a call to the internal integrator.

(errno )

Unexpected internal error in call to interpolation routine.

The interpolation routine returned error flag .

Warns
NagAlgorithmicWarning
(errno )

No change in sign of the function was detected in the integration range.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

ivp_rkm_val_simple advances the solution of a system of ordinary differential equations

from towards using a Merson form of the Runge–Kutta method. The system is defined by , which evaluates in terms of and (see Parameters), and the values of must be given at .

As the integration proceeds, a check is made on the specified component of the solution to determine an interval where it attains a given value . The position where this value is attained is then determined accurately by interpolation on the solution and its derivative. It is assumed that the solution of can be determined by searching for a change in sign in the function .

The accuracy of the integration and, indirectly, of the determination of the position where is controlled by the argument .

For a description of Runge–Kutta methods and their practical implementation see Hall and Watt (1976).

References

Hall, G and Watt, J M (ed.), 1976, Modern Numerical Methods for Ordinary Differential Equations, Clarendon Press, Oxford