jax.numpy.polyint

Contents

jax.numpy.polyint#

jax.numpy.polyint(p, m=1, k=None)[source]#

Returns the coefficients of the integration of specified order of a polynomial.

JAX implementation of numpy.polyint().

Parameters:
  • p (Array) – An array of polynomial coefficients.

  • m (int) – Order of integration. Default is 1. It must be specified statically.

  • k (int | None) – Scalar or array of m integration constant (s).

Returns:

An array of coefficients of integrated polynomial.

Return type:

Array

See also

Examples

The first order integration of the polynomial \(12 x^2 + 12 x + 6\) is \(4 x^3 + 6 x^2 + 6 x\).

>>> p = jnp.array([12, 12, 6])
>>> jnp.polyint(p)
Array([4., 6., 6., 0.], dtype=float32)

Since the constant k is not provided, the result included 0 at the end. If the constant k is provided:

>>> jnp.polyint(p, k=4)
Array([4., 6., 6., 4.], dtype=float32)

and the second order integration is \(x^4 + 2 x^3 + 3 x\):

>>> jnp.polyint(p, m=2)
Array([1., 2., 3., 0., 0.], dtype=float32)

When m>=2, the constants k should be provided as an array having m elements. The second order integration of the polynomial \(12 x^2 + 12 x + 6\) with the constants k=[4, 5] is \(x^4 + 2 x^3 + 3 x^2 + 4 x + 5\):

>>> jnp.polyint(p, m=2, k=jnp.array([4, 5]))
Array([1., 2., 3., 4., 5.], dtype=float32)