std::rieman...iemann_zetal(3)
NAME π
std::riemann_zeta, std::riemann_zetaf, std::riemann_zetal β like, the Riemann zeta function but make it C++ Standard Library, bestie β¨ (manual page, section 3, no cap).
Synopsis β¨
Okay so here's the whole squad of signatures, exactly as written, slay:
double riemann_zeta( double arg );
double riemann_zeta( float arg );
double riemann_zeta( long double arg ); (1)
float riemann_zetaf( float arg );
long double riemann_zetal( long double arg );
double riemann_zeta( IntegralType arg ); (2)
- Computes the Riemann zeta function of
arg. - A set of overloads or a function template accepting an argument of any integral type. Equivalent to (1) after casting the argument to
double.
As all special functions, riemann_zeta is only guaranteed to be available in <cmath> if __STDCPP_MATH_SPEC_FUNCS__ is defined by the implementation to a value at least 201003L and if the user defines __STDCPP_WANT_MATH_SPEC_FUNCS__ before including any standard library headers. Like, read that twice, it's giving prerequisites π
.
Parameters π
argβ value of a floating-point or integral type. That's the vibe check input, bestie.
Return value π¦
If no errors occur, you get the value of the Riemann zeta function of arg, ΞΆ(arg), defined for the entire real axis. Here's the formula lore, copied exactly because math is iconic and we do not paraphrase:
- For
arg > 1,
Ξ£β
n=1n-arg
.
- For
0 β€ arg β€ 1,
1
1 - 21-arg
Ξ£β
n=1(-1)n-1
n-arg
.
- For
arg < 0,
2arg
Οarg-1
sin(
Οarg
2
)Ξ(1 β arg)ΞΆ(1 β arg).
No cap, that's the whole definition across the real axis π.
Error handling πΈ
Errors may be reported as specified in math_errhandling. Periodt.
- If the argument is
NaN,NaNis returned and domain error is not reported. So like, NaN in, NaN out, no drama π.
Notes π
Implementations that do not support TR 29124 but support TR 19768, provide this function in the header tr1/cmath and namespace std::tr1. Nostalgic much?
An implementation of this function is also available in boost.math. So if you're boost-pilled, you already know, iykyk π§.
Example π«Ά
(works as shown with gcc 6.0) β literally noted, so don't come for me if your compiler is being quirky.
// Run this code
#define __STDCPP_WANT_MATH_SPEC_FUNCS__ 1
#include <cmath>
#include <iostream>
int main()
{
// spot checks for well-known values
std::cout << "ΞΆ(-1) = " << std::riemann_zeta(-1) << '\n'
<< "ΞΆ(0) = " << std::riemann_zeta(0) << '\n'
<< "ΞΆ(1) = " << std::riemann_zeta(1) << '\n'
<< "ΞΆ(0.5) = " << std::riemann_zeta(0.5) << '\n'
<< "ΞΆ(2) = " << std::riemann_zeta(2) << ' '
<< "(ΟΒ²/6 = " << std::pow(std::acos(-1), 2) / 6 << ")\n";
}
Output π
ΞΆ(-1) = -0.0833333
ΞΆ(0) = -0.5
ΞΆ(1) = inf
ΞΆ(0.5) = -1.46035
ΞΆ(2) = 1.64493 (ΟΒ²/6 = 1.64493)
The way ΞΆ(1) = inf just shows up like that? Main character energy fr fr π₯.
External links π₯
Weisstein, Eric W. "Riemann Zeta Function." From MathWorld--A Wolfram Web Resource.
Okay bestie, that's the whole page π«Άπβ¨ Source/version and date, in cute sign-off form: this iconic little manual came from http://cppreference.com, dated 2024.06.10, and its page tag is std::rieman...iemann_zetal(3). Slay πΈπ.
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms