zeta#
- scipy.special.zeta(x, q=None, out=None)[source]#
Riemann or Hurwitz zeta function.
- Parameters:
- xarray_like of float or complex.
Input data
- qarray_like of float, optional
Input data, must be real. Defaults to Riemann zeta. When q is
None
, complex inputs x are supported. If q is notNone
, then currently only real inputs x withx >= 1
are supported, even whenq = 1.0
(corresponding to the Riemann zeta function).- outndarray, optional
Output array for the computed values.
- Returns:
- outarray_like
Values of zeta(x).
See also
Notes
The two-argument version is the Hurwitz zeta function
\[\zeta(x, q) = \sum_{k=0}^{\infty} \frac{1}{(k + q)^x};\]see [dlmf] for details. The Riemann zeta function corresponds to the case when
q = 1
.For complex inputs with
q = None
, points withabs(z.imag) > 1e9
and0 <= abs(z.real) < 2.5
are currently not supported due to slow convergence causing excessive runtime.zeta
has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1
and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
✅
✅
Dask
✅
n/a
See Support for the array API standard for more information.
References
[dlmf]NIST, Digital Library of Mathematical Functions, https://dlmf.nist.gov/25.11#i
Examples
>>> import numpy as np >>> from scipy.special import zeta, polygamma, factorial
Some specific values:
>>> zeta(2), np.pi**2/6 (1.6449340668482266, 1.6449340668482264)
>>> zeta(4), np.pi**4/90 (1.0823232337111381, 1.082323233711138)
First nontrivial zero:
>>> zeta(0.5 + 14.134725141734695j) 0 + 0j
Relation to the
polygamma
function:>>> m = 3 >>> x = 1.25 >>> polygamma(m, x) array(2.782144009188397) >>> (-1)**(m+1) * factorial(m) * zeta(m+1, x) 2.7821440091883969