This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / interpolate / _fitpack2 / UnivariateSpline / antiderivative

function

scipy.interpolate._fitpack2:UnivariateSpline.antiderivative

source: build-install/usr/lib/python3.14/site-packages/scipy/interpolate/_fitpack2.py:949

Signature

def antiderivative(self, n = 1)

Summary

Construct a new spline representing the antiderivative of this spline.

Parameters

n : int, optional

Order of antiderivative to evaluate. Default: 1

Returns

spline : UnivariateSpline

Spline of order k2=k+n representing the antiderivative of this spline.

Notes

Examples

import numpy as np
from scipy.interpolate import UnivariateSpline
x = np.linspace(0, np.pi/2, 70)
y = 1 / np.sqrt(1 - 0.8*np.sin(x)**2)
spl = UnivariateSpline(x, y, s=0)
✓
The derivative is the inverse operation of the antiderivative, although some floating point error accumulates:
spl(1.7), spl.antiderivative().derivative()(1.7)
✗
(array(2.15654), array(2.15654))
Antiderivative can be used to evaluate definite integrals:
ispl = spl.antiderivative()
✓
ispl(np.pi/2) - ispl(0)
✗
np.float64(2.2572053588768486)
This is indeed an approximation to the complete elliptic integral :math:`K(m) = \int_0^{\pi/2} [1 - m\sin^2 x]^{-1/2} dx`:
from scipy.special import ellipk
✓
ellipk(0.8)
✗
np.float64(2.257205326820854)

See also

derivative
splantider

Aliases

  • scipy.interpolate.UnivariateSpline.antiderivative