jax.numpy.polydiv(u, v, *, trim_leading_zeros=False)[source]#

Returns the quotient and remainder of polynomial division.

LAX-backend implementation of numpy.polydiv().

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.


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.

The input arrays are the coefficients (including any coefficients equal to zero) of the “numerator” (dividend) and “denominator” (divisor) polynomials, respectively.

  • u (array_like or poly1d) – Dividend polynomial’s coefficients.

  • v (array_like or poly1d) – Divisor polynomial’s coefficients.

  • trim_leading_zeros (bool) –

Return type

Tuple[Array, Array]


  • q (ndarray) – Coefficients, including those equal to zero, of the quotient.

  • r (ndarray) – Coefficients, including those equal to zero, of the remainder.