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