zeta

constexpr double zeta(const double x) noexcept

Evaluates the Riemann zeta function [1] for a real input. Approximated via an integral representation [2].

Parameters

const double z

A real number.

Returns

double

A real number.

The Riemann zeta function is an infinite series defined as:

\[\zeta(n) = \sum_{n = 1}^{\infty} x^{-n}\]

It may also be expressed as the following integral:

\[\zeta(z) = \frac{1}{\Gamma(z)}\int_{0}^{\infty} \frac{t^{z - 1}}{e^t - 1} dt\]

for \(\Re(z) > 1\).

Example

double z = 2.0;
std::cout << zeta(z) << "\n";

Output:

1.64494

References