naginterfaces.library.ode.ivp_rk_zero_simple¶
- naginterfaces.library.ode.ivp_rk_zero_simple(x, xend, y, fcn, tol, relabs, output=None, g=None, data=None)[source]¶
ivp_rk_zero_simple
integrates a system of first-order ordinary differential equations over an interval with suitable initial conditions, using a fixed order Runge–Kutta method, until a user-specified function, if supplied, of the solution is zero, and returns the solution at points specified by you, if desired.For full information please refer to the NAG Library document for d02bj
https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/d02/d02bjf.html
- Parameters
- xfloat
The initial value of the independent variable .
- xendfloat
The final value of the independent variable. If , integration will proceed in the negative direction.
- yfloat, array-like, shape
The initial values of the solution at .
- 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 independent variable.
- yfloat, ndarray, shape
, for , the value of the variable.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- ffloat, array-like, shape
The value of , for .
- tolfloat
A positive tolerance for controlling the error in the integration. Hence affects the determination of the position where , if is supplied.
ivp_rk_zero_simple
has been designed so that, for most problems, a reduction in leads to an approximately proportional reduction in the error in the solution.However, the actual relation between and the accuracy achieved cannot be guaranteed.
You are strongly recommended to call
ivp_rk_zero_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 the results obtained by calling
ivp_rk_zero_simple
with and with each of and where correct significant digits are required in the solution, .The accuracy of the value such that is indirectly controlled by varying .
You should experiment to determine this accuracy.
- relabsstr, length 1
The type of error control. At each step in the numerical solution an estimate of the local error, , is made. For the current step to be accepted the following condition must be satisfied:
where and are defined by
‘M’
1.0
‘A’
‘R’
‘D’
where and are small machine-dependent numbers and is an estimate of the local error at , computed internally. If the condition is not satisfied, the step size is reduced and the solution is recomputed on the current step. If you wish to measure the error in the computed solution in terms of the number of correct decimal places, should be set to ‘A’ on entry, whereas if the error requirement is in terms of the number of correct significant digits, should be set to ‘R’. If you prefer a mixed error test, should be set to ‘M’, otherwise if you have no preference, should be set to the default ‘D’. Note that in this case ‘D’ is taken to be ‘R’.
- outputNone or callable xsol = output(xsol, y, data=None), optional
Note: if this argument is None then a NAG-supplied facility will be used.
permits access to intermediate values of the computed solution (for example to print or plot them), at successive user-specified points.
It is initially called by
ivp_rk_zero_simple
with (the initial value of ).You must reset to the next point (between the current and ) where is to be called, and so on at each call to .
If, after a call to , the reset point is beyond ,
ivp_rk_zero_simple
will integrate to with no further calls to ; if a call to is required at the point , must be given precisely the value .- Parameters
- xsolfloat
The output value of the independent variable .
- yfloat, ndarray, shape
The computed solution at the point .
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- xsolfloat
You must set to the next value of at which is to be called.
- gNone or callable retval = g(x, y, data=None), optional
Note: if this argument is None then a NAG-supplied facility will be used.
must evaluate the function for specified values .
It specifies the function for which the first position where is to be found.
- Parameters
- xfloat
, the value of the independent variable.
- yfloat, ndarray, shape
, for , the value of the variable.
- dataarbitrary, optional, modifiable in place
User-communication data for callback functions.
- Returns
- retvalfloat
The value of at the specified point.
- dataarbitrary, optional
User-communication data for callback functions.
- Returns
- xfloat
If is supplied by you, it contains the point where , unless anywhere on the range to , in which case, will contain (and the error indicator = 6 is set); if is not supplied by you it contains . However, if an error has occurred, it contains the value of at which the error occurred.
- yfloat, ndarray, shape
The computed values of the solution at the final point .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: , , or .
- (errno )
With the given value of , no further progress can be made across the integration range from the current point .
The solution is returned at this point, .
- (errno )
With the given value of , no initial progress can be made from the starting point of integration provided.
- (errno )
On the first call to , was returned as , which is inconsistent with — .
- (errno )
On the first call to , remained unchanged.
- (errno )
On a call to , was returned as , which is inconsistent with previous and — .
- (errno )
On a call to , remained unchanged.
- (errno )
No change in sign of the function was detected in the integration range.
- (errno )
Unexpected internal error in call to zero-finding routine.
The zero-finding routine returned error flag .
- (errno )
Unexpected internal error in call to interpolation routine.
The interpolation routine returned error flag .
- (errno )
Unexpected internal error in call to step integrator.
The step integrator returned error flag .
- Notes
No equivalent traditional C interface for this routine exists in the NAG Library.
ivp_rk_zero_simple
advances the solution of a system of ordinary differential equationsfrom to using a fixed order Runge–Kutta method. The system is defined by , which evaluates in terms of and . The initial values of must be given at .
The solution is returned via the supplied by you and at points specified by you, if desired: this solution is obtained by interpolation on solution values produced by the method. As the integration proceeds a check can be made on the user-specified function to determine an interval where it changes sign. The position of this sign change is then determined accurately by interpolation to the solution. It is assumed that is a continuous function of the variables, so that a solution of can be determined by searching for a change in sign in . The accuracy of the integration, the interpolation and, indirectly, of the determination of the position where , is controlled by the arguments and .
- References
Shampine, L F, 1994, Numerical solution of ordinary differential equations, Chapman and Hall