Skip to content
fn

zeta

→Tensor
zeta(input: TensorOrScalar, other: TensorOrScalar)

Hurwitz zeta function ζ(x,q)\zeta(x, q).

Computes the Hurwitz zeta function, a two-argument generalisation of the Riemann zeta that arises in moment-generating functions of discrete distributions, in expansions of polygamma functions, and as a regulariser in analytic number theory.

Parameters

inputTensor | Scalar
Exponent; must satisfy ℜ(x)>1\Re(x) > 1 for the series to converge. Any real dtype.
otherTensor | Scalar
Shift parameter; broadcast-compatible with input. The non-positive integers are poles. Either operand may be a Python number, which follows the other's device and dtype; not both.

Returns

Tensor

ζ(x,q)\zeta(x, q) element-wise, broadcast to the common shape of input and other.

Notes

Series definition:

ζ(x,q)=∑k=0∞1(k+q)x.\zeta(x, q) = \sum_{k=0}^\infty \frac{1}{(k + q)^x}.

The implementation accumulates an explicit prefix of 12 terms and closes the tail with the Euler–Maclaurin correction

∑k=N∞(k+q)−x≈a1−xx−1+a−x2+∑jB2j(2j)!∏i=02j−2(x+i) a−x−2j+1,\sum_{k=N}^\infty (k + q)^{-x} \approx \frac{a^{1-x}}{x - 1} + \frac{a^{-x}}{2} + \sum_j \frac{B_{2j}}{(2j)!} \prod_{i=0}^{2j-2}(x + i)\, a^{-x-2j+1},

where a=q+Na = q + N and the B2jB_{2j} are Bernoulli numbers; that is accurate to float64 rounding for x>1x > 1 and q>0q > 0. A negative non-integer other is real only for an integer input and is reduced to positive arguments; otherwise it is NaN. The non-positive integers other are poles (+inf), input = 1 is +inf and input < 1 is NaN. The Riemann zeta is the special case ζ(x)=ζ(x,1)\zeta(x) = \zeta(x, 1).

Examples

>>> import lucid
>>> from lucid.special import zeta
>>> x = lucid.tensor([2.0, 3.0])
>>> q = lucid.tensor([1.0, 1.0])
>>> zeta(x, q)
tensor([1.645, 1.202])
>>> zeta(x, 1.0)
tensor([1.645, 1.202])

Used by 1