romb#
- scipy.integrate.romb(y, dx=1.0, axis=-1, show=False)[source]#
Romberg integration using samples of a function.
- Parameters:
- yarray_like
A vector of
2**k + 1equally-spaced samples of a function.- dxfloat, optional
The sample spacing. Default is 1.
- axisint, optional
The axis along which to integrate. Default is -1 (last axis).
- showbool, optional
When y is a single 1-D array, then if this argument is True print the table showing Richardson extrapolation from the samples. Default is False.
- Returns:
- rombndarray
The integrated result for axis.
See also
quadadaptive quadrature using QUADPACK
fixed_quadfixed-order Gaussian quadrature
dblquaddouble integrals
tplquadtriple integrals
simpsonintegrators for sampled data
cumulative_trapezoidcumulative integration for sampled data
Notes
Array API Standard Support
rombhas experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
✅
✅
Dask
✅
n/a
See Support for the array API standard for more information.
Examples
>>> from scipy import integrate >>> import numpy as np >>> x = np.arange(10, 14.25, 0.25) >>> y = np.arange(3, 12)
>>> integrate.romb(y) 56.0
>>> y = np.sin(np.power(x, 2.5)) >>> integrate.romb(y) -0.742561336672229
>>> integrate.romb(y, show=True) Richardson Extrapolation Table for Romberg Integration ====================================================== -0.81576 4.63862 6.45674 -1.10581 -3.02062 -3.65245 -2.57379 -3.06311 -3.06595 -3.05664 -1.34093 -0.92997 -0.78776 -0.75160 -0.74256 ====================================================== -0.742561336672229 # may vary
>>> integrate.romb([[1, 2, 3], [4, 5, 6]], show=True) *** Printing table only supported for integrals of a single data set. array([ 4., 10.])