fn

zeta

Tensor
zeta(x: Tensor, q: Tensor)
source

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

xTensor
Exponent; must satisfy (x)>1\Re(x) > 1 for the series to converge. Any floating-point dtype.
qTensor
Shift parameter; broadcast-compatible with x. Should be positive (avoid the poles at non-positive integers).

Returns

Tensor

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

Notes

Series definition:

ζ(x,q)=k=01(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)xa1xx1+ax2+jB2j(2j)!i=02j2(x+i)ax2j+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. Accuracy is roughly 10610^{-6} for x>1x > 1 and moderate q — adequate for ML log-density work, not for heroic-precision scientific computing. 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.6449, 1.2021])