jax.scipy.special.zeta: the custom_jvp rule returns a different primal value than the function (nan vs finite for s < 1)
Description
Description
zeta is a custom_jvp function whose JVP rule is partial(jax.jvp, _zeta_series_expansion), so the
primal output under differentiation comes from the series expansion rather than from zeta itself. For
s < 1 the function returns nan (matching scipy.special.zeta, which is defined for s > 1), but
jax.jvp and jax.value_and_grad return a finite primal (-1.46035 for zeta(0.5, 1.0)). The same
expression thus gives different values depending on whether it is differentiated.
Steps to reproduce
import jax
jax.config.update("jax_enable_x64", True)
from jax.scipy.special import zeta
print(zeta(0.5, 1.0)) # nan
print(jax.jvp(zeta, (0.5, 1.0), (0.0, 1.0))[0]) # -1.4603545088095866
print(jax.value_and_grad(lambda q: zeta(0.5, q))(1.0)[0]) # -1.4603545088095866
Expected
The JVP's primal output equals zeta(s, q) for every input (both nan, or both the same number).
System info (python version, jaxlib version, accelerator, etc.)
Environment
JAX / jaxlib 0.11.2 (the latest release, CPU) and 0.10.1, Python 3.12, Ubuntu 24.04, x86_64
#38651