scijit.integrate.romb¶
- scijit.integrate.romb(y, dx=1.0, axis=-1, show=False)¶
Romberg integration of equally-spaced samples.
Repeated Richardson extrapolation of the trapezoid rule. Very accurate on smooth data, but the sample count is constrained.
Takes NO callback of either style: it integrates samples.
- Parameters:
- yarray_like
Samples on an equally-spaced grid. The length along
axismust be one plus a non-negative power of two, otherwiseValueError.- dxfloat, optional
Sample spacing, a scalar. Default 1.0.
- axisint, optional
Axis to integrate along. Default -1, the last axis.
- showbool or sequence, optional
Print the Richardson extrapolation table. Default False. A sequence supplies
(precision, width), defaulting to 5 and 8. Only a single data set is printed; anyof rank 2 or more prints a notice instead. Inside@njitit must be a compile-time constant, since it selects whether the table is built at all.
- Returns:
- totalfloat or ndarray
The integral, the top-right corner of the Romberg table. A scalar for a 1-D
y, otherwise an array ofy’s rank less one.
- Raises:
- IndexError
axisoutsidey’s rank.- ValueError
The number of samples along
axisis not one plus a non-negative power of two.
See also
scipy.integrate.rombThe scipy routine this mirrors.
Notes
scipy.integrate.rombdocumentsshowas a bool but reads(precision, width)from a sequence when one is passed; a sequence is accepted here as well.Pure
@njit, no state, so prange-safe. Printing the table takes the GIL for the duration, so it serializes aprangeloop.Examples
>>> import numpy as np >>> from numba import njit >>> import scijit.integrate as si >>> x = np.linspace(0.0, np.pi, 65) >>> @njit ... def run(x): ... return si.romb(np.sin(x), x[1] - x[0]) >>> run(x) 1.9999999999999996