{"record":{"id":"02f473a0de7fe9f5","repo":"jax-ml/jax","slug":"riemann-zeta-function-not-implemented-pass-q-n","errorCode":null,"errorMessage":"Riemann zeta function not implemented; pass q != None to compute the Hurwitz Zeta function.","messagePattern":"Riemann zeta function not implemented; pass q != None to compute the Hurwitz Zeta function\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/special.py","lineNumber":1288,"sourceCode":"def zeta(x: ArrayLike, q: ArrayLike | None = None) -> Array:\n  r\"\"\"The Hurwitz zeta function.\n\n  JAX implementation of :func:`scipy.special.zeta`. JAX does not implement\n  the Riemann zeta function (i.e. ``q = None``).\n\n  .. math::\n\n     \\zeta(x, q) = \\sum_{n=0}^\\infty \\frac{1}{(n + q)^x}\n\n  Args:\n    x: arraylike, real-valued\n    q: arraylike, real-valued\n\n  Returns:\n    array of zeta function values\n  \"\"\"\n  if q is None:\n    raise NotImplementedError(\n      \"Riemann zeta function not implemented; pass q != None to compute the Hurwitz Zeta function.\")\n  x, q = promote_args_inexact(\"zeta\", x, q)\n  return lax.zeta(x, q)\n\n\n# There is no general closed-form derivative for the zeta function, so we compute\n# derivatives via a series expansion\ndef _zeta_series_expansion(x: ArrayLike, q: ArrayLike | None = None) -> Array:\n  if q is None:\n    raise NotImplementedError(\n      \"Riemann zeta function not implemented; pass q != None to compute the Hurwitz Zeta function.\")\n  # Reference: Johansson, Fredrik.\n  # \"Rigorous high-precision computation of the Hurwitz zeta function and its derivatives.\"\n  # Numerical Algorithms 69.2 (2015): 253-270.\n  # https://arxiv.org/abs/1309.2877 - formula (5)\n  # here we keep the same notation as in reference\n  s, a = promote_args_inexact(\"zeta\", x, q)\n  dtype = lax.dtype(a).type","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/special.py#L1270-L1306","documentation":"jax.scipy.special.zeta only implements the Hurwitz zeta function zeta(x, q), not the Riemann zeta function. Passing q=None (the default in SciPy's signature) raises NotImplementedError telling you to supply q. Note that the Riemann zeta is the special case q=1, but only a limited number of algorithms handle it, so JAX defers it.","triggerScenarios":"Calling jax.scipy.special.zeta(x) or zeta(x, None) — mirroring mpmath.zeta or scipy.special.zeta(x, 1) usage where q was omitted.","commonSituations":"Porting mpmath code that calls zeta(x) for the Riemann zeta; assuming SciPy's two-argument zeta can be called with just x; analytical number theory computations in JAX pipelines.","solutions":["Pass q=1 explicitly: zeta(x, 1) gives the Riemann zeta via the Hurwitz form","Use jax.scipy.special.zeta(x, q) with the intended Hurwitz shift q","If you need the full Riemann zeta (e.g., analytic continuation for x<1), compute it outside JAX with mpmath"],"exampleFix":"// before\njax.scipy.special.zeta(2.0)  # q=None -> raises\n// after\njax.scipy.special.zeta(2.0, 1.0)  # Riemann zeta as Hurwitz with q=1","handlingStrategy":"validation","validationCode":"q = 1.0 if q is None else q  # Riemann zeta as Hurwitz q=1\nzeta(x, q)","typeGuard":null,"tryCatchPattern":"try:\n    z = jax.scipy.special.zeta(x)\nexcept NotImplementedError:\n    z = jax.scipy.special.zeta(x, 1.0)","preventionTips":["Always pass q explicitly; use q=1 for the Riemann zeta","Note Hurwitz zeta with q=1 requires x>1 for the series — validate domain too"],"tags":["jax","scipy-special","zeta","not-implemented"],"backgroundTag":"unsupported-api-signature","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}