bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / interpolate / _bsplines / BSpline / integrate
function
scipy.interpolate._bsplines:BSpline.integrate
source: build-install/usr/lib/python3.14/site-packages/scipy/interpolate/_bsplines.py:1233
Signature
def integrate(self, a, b, extrapolate = None)Summary
Compute a definite integral of the spline.
Parameters
a: floatLower limit of integration.
b: floatUpper limit of integration.
extrapolate: bool or 'periodic', optionalwhether to extrapolate beyond the base interval,
t[k] .. t[-k-1], or take the spline to be zero outside of the base interval. If 'periodic', periodic extrapolation is used. If None (default), useself.extrapolate.
Returns
I: array_likeDefinite integral of the spline over the interval
[a, b].
Examples
Construct the linear spline ``x if x < 1 else 2 - x`` on the base interval :math:`[0, 2]`, and integrate itfrom scipy.interpolate import BSpline b = BSpline.basis_element([0, 1, 2]) b.integrate(0, 1)✓
array(0.5)If the integration limits are outside of the base interval, the result is controlled by the `extrapolate` parameter
b.integrate(-1, 1)
✗array(0.)
b.integrate(-1, 1, extrapolate=False)
✓array(0.5)
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.grid(True)✓
ax.axvline(0, c='r', lw=5, alpha=0.5) # base interval ax.axvline(2, c='r', lw=5, alpha=0.5)✗
<matplotlib.lines.Line2D object at 0x7f3f43050590>
xx = [-1, 1, 2]
✓ax.plot(xx, b(xx))
✗[<matplotlib.lines.Line2D object at 0x7f3f43050980>]
plt.show()
✓
Aliases
scipy.interpolate.BSpline.integrate