mathlib documentation

number_theory.bernoulli

Bernoulli numbers #

The Bernoulli numbers are a sequence of rational numbers that frequently show up in number theory.

Mathematical overview #

The Bernoulli numbers $(B_0, B_1, B_2, \ldots)=(1, -1/2, 1/6, 0, -1/30, \ldots)$ are a sequence of rational numbers. They show up in the formula for the sums of $k$th powers. They are related to the Taylor series expansions of $x/\tan(x)$ and of $\coth(x)$, and also show up in the values that the Riemann Zeta function takes both at both negative and positive integers (and hence in the theory of modular forms). For example, if $1 \leq n$ is even then

$$\zeta(2n)=\sum_{t\geq1}t^{-2n}=(-1)^{n+1}\frac{(2\pi)^{2n}B_{2n}}{2(2n)!}.$$

Note however that this result is not yet formalised in Lean.

The Bernoulli numbers can be formally defined using the power series

$$\sum B_n\frac{t^n}{n!}=\frac{t}{1-e^{-t}}$$

although that happens to not be the definition in mathlib (this is an implementation detail and need not concern the mathematician).

Note that $B_1=-1/2$, meaning that we are using the $B_n^-$ of from Wikipedia.

Implementation detail #

The Bernoulli numbers are defined using well-founded induction, by the formula $$B_n=1-\sum_{k\lt n}\frac{\binom{n}{k}}{n-k+1}B_k.$$ This formula is true for all $n$ and in particular $B_0=1$. Note that this is the definition for positive Bernoulli numbers, which we call bernoulli'. The negative Bernoulli numbers are then defined as bernoulli := (-1)^n * bernoulli'.

Main theorems #

sum_bernoulli : ∑ k in finset.range n, (n.choose k : ℚ) * bernoulli k = 0

Definitions #

def bernoulli'  :

The Bernoulli numbers: the $n$-th Bernoulli number $B_n$ is defined recursively via $$B_n = 1 - \sum_{k < n} \binom{n}{k}\frac{B_k}{n+1-k}$$

Equations
theorem bernoulli'_def' (n : ) :
bernoulli' n = 1 - finset.univ.sum (λ (k : fin n), (n.choose k) / (n - k + 1) * bernoulli' k)
theorem bernoulli'_def (n : ) :
bernoulli' n = 1 - (finset.range n).sum (λ (k : ), (n.choose k) / (n - k + 1) * bernoulli' k)
theorem bernoulli'_spec (n : ) :
(finset.range n.succ).sum (λ (k : ), (n.choose (n - k)) / (n - k + 1) * bernoulli' k) = 1
theorem bernoulli'_spec' (n : ) :
(finset.nat.antidiagonal n).sum (λ (k : × ), ((k.fst + k.snd).choose k.snd) / ((k.snd) + 1) * bernoulli' k.fst) = 1

Examples #

@[simp]
theorem bernoulli'_zero  :
@[simp]
theorem bernoulli'_one  :
bernoulli' 1 = 1 / 2
@[simp]
theorem bernoulli'_two  :
bernoulli' 2 = 1 / 6
@[simp]
theorem bernoulli'_three  :
@[simp]
theorem bernoulli'_four  :
bernoulli' 4 = (-1) / 30
@[simp]
theorem sum_bernoulli' (n : ) :
(finset.range n).sum (λ (k : ), (n.choose k) * bernoulli' k) = n
def bernoulli'_power_series (A : Type u_1) [comm_ring A] [algebra A] :

The exponential generating function for the Bernoulli numbers bernoulli' n.

Equations
theorem bernoulli'_odd_eq_zero {n : } (h_odd : odd n) (hlt : 1 < n) :

Odd Bernoulli numbers (greater than 1) are zero.

def bernoulli (n : ) :

The Bernoulli numbers are defined to be bernoulli' with a parity sign.

Equations
theorem bernoulli'_eq_bernoulli (n : ) :
bernoulli' n = (-1) ^ n * bernoulli n
@[simp]
theorem bernoulli_zero  :
@[simp]
theorem bernoulli_one  :
bernoulli 1 = (-1) / 2
@[simp]
theorem sum_bernoulli (n : ) :
(finset.range n).sum (λ (k : ), (n.choose k) * bernoulli k) = ite (n = 1) 1 0
theorem bernoulli_spec' (n : ) :
(finset.nat.antidiagonal n).sum (λ (k : × ), ((k.fst + k.snd).choose k.snd) / ((k.snd) + 1) * bernoulli k.fst) = ite (n = 0) 1 0
def bernoulli_power_series (A : Type u_1) [comm_ring A] [algebra A] :

The exponential generating function for the Bernoulli numbers bernoulli n.

Equations
theorem sum_range_pow (n p : ) :
(finset.range n).sum (λ (k : ), k ^ p) = (finset.range (p + 1)).sum (λ (i : ), bernoulli i * ((p + 1).choose i) * n ^ (p + 1 - i) / (p + 1))

Faulhaber's theorem relating the sum of of p-th powers to the Bernoulli numbers: $$\sum_{k=0}^{n-1} k^p = \sum_{i=0}^p B_i\binom{p+1}{i}\frac{n^{p+1-i}}{p+1}.$$ See https://proofwiki.org/wiki/Faulhaber%27s_Formula and [Oro18] for the proof provided here.

theorem sum_Ico_pow (n p : ) :
(finset.Ico 1 (n + 1)).sum (λ (k : ), k ^ p) = (finset.range (p + 1)).sum (λ (i : ), bernoulli' i * ((p + 1).choose i) * n ^ (p + 1 - i) / (p + 1))

Alternate form of Faulhaber's theorem, relating the sum of p-th powers to the Bernoulli numbers: $$\sum_{k=1}^{n} k^p = \sum_{i=0}^p (-1)^iB_i\binom{p+1}{i}\frac{n^{p+1-i}}{p+1}.$$ Deduced from sum_range_pow.