MCPcopy Create free account
hub / github.com/numpy/numpy / polyint

Function polyint

numpy/lib/polynomial.py:269–366  ·  view source on GitHub ↗

Return an antiderivative (indefinite integral) of a polynomial. .. note:: This forms part of the old polynomial API. Since version 1.4, the new polynomial API defined in `numpy.polynomial` is preferred. A summary of the differences can be found in the :doc:`tran

(p, m=1, k=None)

Source from the content-addressed store, hash-verified

267
268@array_function_dispatch(_polyint_dispatcher)
269def polyint(p, m=1, k=None):
270 """
271 Return an antiderivative (indefinite integral) of a polynomial.
272
273 .. note::
274 This forms part of the old polynomial API. Since version 1.4, the
275 new polynomial API defined in `numpy.polynomial` is preferred.
276 A summary of the differences can be found in the
277 :doc:`transition guide </reference/routines.polynomials>`.
278
279 The returned order `m` antiderivative `P` of polynomial `p` satisfies
280 :math:`\\frac{d^m}{dx^m}P(x) = p(x)` and is defined up to `m - 1`
281 integration constants `k`. The constants determine the low-order
282 polynomial part
283
284 .. math:: \\frac{k_{m-1}}{0!} x^0 + \\ldots + \\frac{k_0}{(m-1)!}x^{m-1}
285
286 of `P` so that :math:`P^{(j)}(0) = k_{m-j-1}`.
287
288 Parameters
289 ----------
290 p : array_like or poly1d
291 Polynomial to integrate.
292 A sequence is interpreted as polynomial coefficients, see `poly1d`.
293 m : int, optional
294 Order of the antiderivative. (Default: 1)
295 k : list of `m` scalars or scalar, optional
296 Integration constants. They are given in the order of integration:
297 those corresponding to highest-order terms come first.
298
299 If ``None`` (default), all constants are assumed to be zero.
300 If `m = 1`, a single scalar can be given instead of a list.
301
302 See Also
303 --------
304 polyder : derivative of a polynomial
305 poly1d.integ : equivalent method
306
307 Examples
308 --------
309 The defining property of the antiderivative:
310
311 >>> p = np.poly1d([1,1,1])
312 >>> P = np.polyint(p)
313 >>> P
314 poly1d([ 0.33333333, 0.5 , 1. , 0. ]) # may vary
315 >>> np.polyder(P) == p
316 True
317
318 The integration constants default to zero, but can be specified:
319
320 >>> P = np.polyint(p, 3)
321 >>> P(0)
322 0.0
323 >>> np.polyder(P)(0)
324 0.0
325 >>> np.polyder(P, 2)(0)
326 0.0

Callers 1

integMethod · 0.70

Calls 3

atleast_1dFunction · 0.90
poly1dClass · 0.85
__truediv__Method · 0.45

Tested by

no test coverage detected