jax.numpy.polymul#

jax.numpy.polymul(a1, a2, *, trim_leading_zeros=False)[source]#

Find the product of two polynomials.

LAX-backend implementation of numpy.polymul().

Setting trim_leading_zeros=True makes the output match that of numpy. But prevents the function from being able to be used in compiled code. Due to differences in accumulation of floating point arithmetic errors, the cutoff for values to be considered zero may lead to inconsistent results between NumPy and JAX, and even between different JAX backends. The result may lead to inconsistent output shapes when trim_leading_zeros=True.

Original docstring below.

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 transition guide.

Finds the polynomial resulting from the multiplication of the two input polynomials. Each input must be either a poly1d object or a 1D sequence of polynomial coefficients, from highest to lowest degree.

Parameters
  • a1 (array_like or poly1d object) – Input polynomials.

  • a2 (array_like or poly1d object) – Input polynomials.

  • trim_leading_zeros (bool) –

Returns

out – The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.

Return type

ndarray or poly1d object