Zeta functions, polylogarithms and Fermi-Dirac integrals
| Problem | Evaluate the Riemann zeta function and the Hurwitz zeta function for real arguments, the polylogarithm for real order and argument, and the complete Fermi-Dirac integrals |
| Devised by | Leonhard Euler (1735–1737), and the product over primes; Bernhard Riemann (1859); Adolf Hurwitz (1882); the dilogarithm: Euler (1768), William Spence (1809); Enrico Fermi and Paul Dirac (1926); the acceleration used here: Peter Borwein (2000) |
| Accuracy | About relative; near , loses a few digits to the pole of its functional equation |
| Cost | Borwein’s method: 24 terms; Euler-Maclaurin: a dozen terms plus a short sum; Fermi-Dirac: composite Gauss-Legendre quadrature |
| Read first | The gamma function and related functions |
| API | zeta, hurwitz_zeta, polylog, fermi_dirac_integral |
Overview
The Riemann zeta function links analysis and number theory: its product over the primes, , makes it the generating function of the primes, and its complex zeros control their distribution (the Riemann hypothesis). Its real values appear throughout physics: in Bose-Einstein condensation, in the Stefan-Boltzmann law, in the Casimir effect and string theory.
The polylogarithm generalises both the zeta function () and the logarithm (). It appears in quantum field theory, in the statistics of quantum gases, and in number theory. The Fermi-Dirac integrals are polylogarithms in disguise and give the electron density and energy in metals, semiconductors and white dwarf stars.
Where it is used
Zeta functions connect number theory and physics.
- Statistical physics. Fermi-Dirac and Bose-Einstein integrals give the electron density in semiconductors, the specific heat of metals and the thermodynamics of photons; the Stefan-Boltzmann law involves .
- Number theory. The Riemann zeta function is tied to the distribution of primes.
- Series acceleration. Sums of reciprocal powers, which appear in many engineering formulas, are zeta values.
- Zipf-type laws. Normalising a power-law distribution of word frequencies or city sizes uses .
History
Euler solved the Basel problem, , in 1735, found all the even values in terms of Bernoulli numbers, and discovered the product over primes in 1737. Bernhard Riemann’s only paper on number theory (1859) continued to the complex plane, proved its functional equation, and stated the hypothesis on its zeros. Adolf Hurwitz (1882) introduced the shifted function . The dilogarithm appears in Euler’s and Spence’s work, and Leonard Lewin’s books (1958, 1981) collected the theory of polylogarithms. Enrico Fermi and Paul Dirac derived the statistics of electrons in 1926, and Arnold Sommerfeld’s 1928 theory of metals introduced the asymptotic expansion of the Fermi-Dirac integrals.
The idea
The Riemann zeta function
The defining series converges for , but far too slowly to be used: its terms all have the same sign and decay only like a power. Comparing the tail with an integral, , so for the error after terms is about . Even terms leave an error near (not one correct digit of ), and sixteen digits would need about terms.
An alternating series. Changing the sign of every second term gives the Dirichlet eta function
The two functions are simply related. Subtracting twice the even-numbered terms from the zeta series flips their signs, and the even-numbered terms sum to . Hence
An alternating series is a much better starting point: it converges for all , and alternating series can be accelerated. Borwein’s algorithm replaces the partial sum by a weighted sum of the first terms, with weights derived from Chebyshev polynomials and chosen so that the errors of successive partial sums cancel. The error is about : each extra term gains a factor of nearly 6. The library’s 24 terms give . Dividing by then gives .
Negative arguments. For the functional equation
maps to positive arguments, and gives the trivial zeros at exactly. has a simple pole at with residue 1, and .
Figure 6.13. The Riemann zeta function.
The Hurwitz zeta function generalises the series by starting it at instead of 1. It is computed for by Euler-Maclaurin summation: sum the first terms directly, and replace the slowly converging tail by the integral of the summand, which is elementary, plus a few correction terms involving Bernoulli numbers. (This is the Euler-Maclaurin formula of the integration chapter, used in the opposite direction: there it corrects a sum to approximate an integral, here it uses an integral to approximate a sum.)
The polylogarithm
The polylogarithm is defined by the series , which converges for (for ) but quickly only when is small. As with the hypergeometric functions, the strategy is to use identities that move the argument to where some expansion converges fast. No single expansion covers all real ; the library combines several:
- : the defining series, converging like ;
- : the expansion in powers of , (with a logarithmic term replacing the singular one when is an integer);
- : the duplication formula ;
- : the inversion formula for integer orders, and the Fermi-Dirac connection below for other ;
- integer : closed forms, , , and rational functions for negative integers (through Stirling numbers).
For non-integer and the library returns NaN (that case is not implemented), and at it
returns for and the limit for .
Fermi-Dirac integrals
The complete Fermi-Dirac integral, normalised as in most modern work, is
For (non-degenerate, classical gas) ; for (degenerate, as in metals) , with Sommerfeld’s corrections:
Figure 6.14. Fermi-Dirac integrals.
The library computes the integral by composite 20-point Gauss-Legendre quadrature, after a substitution that removes the singularity of at the origin; the accuracy is about or better for integer and half-integer orders.
Accuracy
Table 6.9. Accuracy of the zeta function and its relatives.
| function | test points | median relative error | largest relative error | at arguments |
|---|---|---|---|---|
zeta | 27 | 2e-16 | 7e-12 | (-0.00001) |
hurwitz_zeta | 20 | 2e-16 | 4e-16 | (3.3, 1) |
polylog | 51 | 1e-16 | 4e-14 | (-3, -50) |
fermi_dirac_integral | 42 | 6e-16 | 4e-15 | (1, 40) |
The largest error of zeta, at , comes from the functional equation: near , is
evaluated near its pole, where it is ill-conditioned.
Algorithm
for real :
- : return (the pole).
- : compute as Borwein’s weighted sum of its first 24 terms, with the weights tabulated in advance, and return .
- : compute by step 2 and apply the functional equation. The factor makes the result exactly zero at the negative even integers.
for (Euler-Maclaurin):
- choose from and so that the correction terms decrease quickly;
- add the first terms directly;
- add the integral of the remaining terms, , half the next term, and the Bernoulli-number corrections until they fall below rounding error.
: return the closed form if is an integer below 2; otherwise select the expansion for the interval containing , as listed above, and sum it until its terms are below . The duplication and inversion formulas call the function again with an argument in a region already covered.
: map the half-line onto a finite interval by a substitution that removes the singularity of at the origin, and apply composite 20-point Gauss-Legendre quadrature.
Implementation
The Dirichlet eta function by Borwein’s algorithm:
/// The Dirichlet eta function `η(s) = Σ (−1)^{k−1} / k^s` for `s ≥ 0` by Borwein's algorithm.
fn eta(s: f64) -> f64 {
let d = borwein_d();
let dn = d[BORWEIN_TERMS];
let sum: f64 = (0..BORWEIN_TERMS)
.map(|k| {
let sign = if k % 2 == 0 { 1.0 } else { -1.0 };
sign * (d[k] - dn) / ((k + 1) as f64).powf(s)
})
.sum();
-sum / dn
}
- Real arguments only: the zeta function on the critical line, where its non-trivial zeros lie, needs complex arithmetic (and the Riemann-Siegel formula), which the library does not provide.
polylogloses accuracy for orders within about of an integer in the expansion.
In practice
//! The Riemann zeta function, the polylogarithm and Fermi-Dirac integrals.
//!
//! Run with `cargo run -p lib_jsl_special_functions --example special_zeta`.
use lib_jsl_special_functions::{fermi_dirac_integral, hurwitz_zeta, polylog, zeta};
fn main() {
let pi = std::f64::consts::PI;
println!("ζ(2) = {:.15} (π²/6 = {:.15})", zeta(2.0), pi * pi / 6.0);
println!("ζ(−1) = {:.15} (−1/12), ζ(−2) = {}", zeta(-1.0), zeta(-2.0));
println!("ζ(3, 2) = ζ(3) − 1 = {:.15}", hurwitz_zeta(3.0, 2.0));
println!("Li₂(½) = {:.15} (π²/12 − ln²2/2 = {:.15})", polylog(2.0, 0.5), pi * pi / 12.0 - 2f64.ln().powi(2) / 2.0);
// The electron density of a semiconductor: F_½ of the reduced Fermi level.
for eta in [-4.0, 0.0, 4.0, 20.0] {
println!("F_½({eta}) = {:.10}", fermi_dirac_integral(0.5, eta));
}
}
Strengths
- Fast, accurate real zeta and Hurwitz zeta functions; the polylogarithm over most of its real domain.
Weaknesses
- No complex arguments.
- Gaps in the polylogarithm’s domain (non-integer with ).
Exercises
- Show that by subtracting twice the even terms.
- Prove Euler’s product formula by expanding each factor as a geometric series and using unique factorisation.
- Estimate how many terms of are needed for 15 correct digits of , and how many Borwein terms.
- Use the functional equation to show that from .
- Derive the first Sommerfeld correction, , and compare with
fermi_dirac_integralfor .
Hints and answers
- .
- Expand and multiply over all primes: the product of the series contains each exactly once, by unique factorisation.
- The tail after terms of is about , so 15 digits need about terms. Borwein’s algorithm needs about terms, since its error is about .
- The functional equation at gives .
- The Sommerfeld expansion applies to for large : replace the Fermi function by a step and expand the difference about , which gives the leading term times corrections in . The error of the two-term formula falls rapidly with .
Further reading
- H. M. Edwards, Riemann’s Zeta Function, Academic Press, 1974 (Dover reprint, 2001).
- P. Borwein, “An efficient algorithm for the Riemann zeta function”, Canadian Mathematical Society Conference Proceedings 27 (2000) 29–34.
- L. Lewin, Polylogarithms and Associated Functions, North-Holland, 1981.
- NIST Digital Library of Mathematical Functions, chapters 25 and 25.12, https://dlmf.nist.gov/25.