jax-ml/jax · error · ValueError
Order of integral must be positive (see polyder)
Error message
Order of integral must be positive (see polyder)
What it means
jnp.polyint raises the polynomial degree by m, so a negative integration order is meaningless. It fires when m < 0 after the m argument is concretized.
Solutions
- Use jnp.polyder for negative-order intent (differentiation)
- Take abs(m) or clamp m to >= 0 if the sign is a bug
- Guard with m = max(m, 0) before calling
Example fix
// before jnp.polyint(p, m=-2) // after from jax._src.numpy.polynomial import polyder polyder(p, m=2)
Defensive patterns
Strategy: validation
Validate before calling
m = max(int(m), 0) # or reject negatives explicitly before polyint
Type guard
null
Prevention
- Treat negative m as a call to polyder
- Validate integer order parameters at API boundaries
When it happens
Trigger: Calling jnp.polyint(p, m=-1) (or any negative m). m is converted with operator.index, so floats raise a separate concreteness/type error, but any negative int hits this branch.
Common situations: Sign confusion between integration and differentiation orders; dynamically computed m that can go negative in loops (e.g. repeatedly differentiating/integrating).
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- a_scale and b_scale must both be present or absent.
- args argument to jax.scipy.optimize.minimize must be a…
- Argument ' ' of type is not a valid JAX type.
- Argument ' ' of type ' ' is not a valid JAX type
- array() got multiple values for argument
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/c3423da15fce3315.
Report an issue: GitHub.
Appendix: source
Thrown at jax/_src/numpy/polynomial.py:565
>>> 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
:math:`12 x^2 + 12 x + 6` with the constants ``k=[4, 5]`` is
:math:`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)
"""
m = core.concrete_or_error(operator.index, m, "'m' argument of jnp.polyint")
k = 0 if k is None else k
p, k = ensure_arraylike("polyint", p, k)
p_arr, k_arr = promote_dtypes_inexact(p, k)
del p, k
if m < 0:
raise ValueError("Order of integral must be positive (see polyder)")
k_arr = atleast_1d(k_arr)
if len(k_arr) == 1:
k_arr = full((m,), k_arr[0])
if k_arr.shape != (m,):
raise ValueError("k must be a scalar or a rank-1 array of length 1 or m.")
if m == 0:
return p_arr
else:
grid = (arange(len(p_arr) + m, dtype=p_arr.dtype)[np.newaxis]
- arange(m, dtype=p_arr.dtype)[:, np.newaxis])
coeff = maximum(1, grid).prod(0)[::-1]
return true_divide(concatenate((p_arr, k_arr)), coeff)
@export
@api.jit(static_argnames=('m',))
def polyder(p: ArrayLike, m: int = 1) -> Array:
r"""Returns the coefficients of the derivative of specified order of a polynomial.View on GitHub (pinned to 1e1c6a8fc0)