mathlib documentation

data.real.pi

Pi #

This file contains lemmas which establish bounds on or approximations of real.pi. Notably, these include pi_gt_sqrt_two_add_series and pi_lt_sqrt_two_add_series, which bound π using series; numerical bounds on π such as pi_gt_314and pi_lt_315 (more precise versions are given, too); and exact (infinite) formulas involving π, such as tendsto_sum_pi_div_four, Leibniz's series for π, and tendsto_prod_pi_div_two, the Wallis product for π.

theorem real.pi_lt_sqrt_two_add_series (n : ) :
π < (2 ^ (n + 1)) * real.sqrt (2 - real.sqrt_two_add_series 0 n) + 1 / 4 ^ n
theorem real.pi_lower_bound_start (n : ) {a : } (h : real.sqrt_two_add_series (0 / 1) n 2 - (a / 2 ^ (n + 1)) ^ 2) :
a < π

From an upper bound on sqrt_two_add_series 0 n = 2 cos (π / 2 ^ (n+1)) of the form sqrt_two_add_series 0 n ≤ 2 - (a / 2 ^ (n + 1)) ^ 2), one can deduce the lower bound a < π thanks to basic trigonometric inequalities as expressed in pi_gt_sqrt_two_add_series.

theorem real.sqrt_two_add_series_step_up (c d : ) {a b n : } {z : } (hz : real.sqrt_two_add_series (c / d) n z) (hb : 0 < b) (hd : 0 < d) (h : (2 * b + a) * d ^ 2 (c ^ 2) * b) :
meta def real.pi_lower_bound (l : list ) :

Create a proof of a < π for a fixed rational number a, given a witness, which is a sequence of rational numbers sqrt 2 < r 1 < r 2 < ... < r n < 2 satisfying the property that sqrt (2 + r i) ≤ r(i+1), where r 0 = 0 and sqrt (2 - r n) ≥ a/2^(n+1).

theorem real.pi_upper_bound_start (n : ) {a : } (h : 2 - ((a - 1 / 4 ^ n) / 2 ^ (n + 1)) ^ 2 real.sqrt_two_add_series (0 / 1) n) (h₂ : 1 / 4 ^ n a) :
π < a

From a lower bound on sqrt_two_add_series 0 n = 2 cos (π / 2 ^ (n+1)) of the form 2 - ((a - 1 / 4 ^ n) / 2 ^ (n + 1)) ^ 2 ≤ sqrt_two_add_series 0 n, one can deduce the upper bound π < a thanks to basic trigonometric formulas as expressed in pi_lt_sqrt_two_add_series.

theorem real.sqrt_two_add_series_step_down (a b : ) {c d n : } {z : } (hz : z real.sqrt_two_add_series (a / b) n) (hb : 0 < b) (hd : 0 < d) (h : (a ^ 2) * d (2 * d + c) * b ^ 2) :
meta def real.pi_upper_bound (l : list ) :

Create a proof of π < a for a fixed rational number a, given a witness, which is a sequence of rational numbers sqrt 2 < r 1 < r 2 < ... < r n < 2 satisfying the property that sqrt (2 + r i) ≥ r(i+1), where r 0 = 0 and sqrt (2 - r n) ≥ (a - 1/4^n) / 2^(n+1).

theorem real.pi_gt_three  :
3 < π
theorem real.pi_gt_314  :
157 / 50 < π
theorem real.pi_lt_315  :
π < 63 / 20
theorem real.pi_gt_31415  :
6283 / 2000 < π
theorem real.pi_lt_31416  :
π < 3927 / 1250
theorem real.pi_gt_3141592  :
392699 / 125000 < π
theorem real.pi_lt_3141593  :
π < 3141593 / 1000000

Leibniz's Series for Pi #

theorem real.tendsto_sum_pi_div_four  :
filter.tendsto (λ (k : ), ∑ (i : ) in finset.range k, (-1) ^ i / (2 * i + 1)) filter.at_top (𝓝 (π / 4))

This theorem establishes Leibniz's series for π: The alternating sum of the reciprocals of the odd numbers is π/4. Note that this is a conditionally rather than absolutely convergent series. The main tool that this proof uses is the Mean Value Theorem (specifically avoiding the Fundamental Theorem of Calculus).

Intuitively, the theorem holds because Leibniz's series is the Taylor series of arctan x centered about 0 and evaluated at the value x = 1. Therefore, much of this proof consists of reasoning about a function f := arctan x - ∑ i in finset.range k, (-(1:ℝ))^i * x^(2*i+1) / (2*i+1), the difference between arctan and the k-th partial sum of its Taylor series. Some ingenuity is required due to the fact that the Taylor series is not absolutely convergent at x = 1.

This proof requires a bound on f 1, the key idea being that f 1 can be split as the sum of f 1 - f u and f u, where u is a sequence of values in [0,1], carefully chosen such that each of these two terms can be controlled (in different ways).

We begin the proof by (1) introducing that sequence u and then proving that another sequence constructed from u tends to 0 at +∞. After (2) converting the limit in our goal to an inequality, we (3) introduce the auxiliary function f defined above. Next, we (4) compute the derivative of f, denoted by f', first generally and then on each of two subintervals of [0,1]. We then (5) prove a bound for f', again both generally as well as on each of the two subintervals. Finally, we (6) apply the Mean Value Theorem twice, obtaining bounds on f 1 - f u and f u - f 0 from the bounds on f' (note that f 0 = 0).

The Wallis Product for Pi #

theorem real.integral_sin_pow_div_tendsto_one  :
filter.tendsto (λ (k : ), (∫ (x : ) in 0..π, real.sin x ^ (2 * k + 1)) / ∫ (x : ) in 0..π, real.sin x ^ 2 * k) filter.at_top (𝓝 1)
theorem real.tendsto_prod_pi_div_two  :
filter.tendsto (λ (k : ), ∏ (i : ) in finset.range k, ((2 * i + 2) / (2 * i + 1)) * ((2 * i + 2) / (2 * i + 3))) filter.at_top (𝓝 (π / 2))

This theorem establishes the Wallis Product for π. Our proof is largely about analyzing the behavior of the ratio of the integral of sin x ^ n as n → ∞. See: https://en.wikipedia.org/wiki/Wallis_product

The proof can be broken down into two pieces. (Pieces involving general properties of the integral of sin x ^n can be found in analysis.special_functions.integrals.) First, we use integration by parts to obtain a recursive formula for ∫ x in 0..π, sin x ^ (n + 2) in terms of ∫ x in 0..π, sin x ^ n. From this we can obtain closed form products of ∫ x in 0..π, sin x ^ (2 * n) and ∫ x in 0..π, sin x ^ (2 * n + 1) via induction. Next, we study the behavior of the ratio ∫ (x : ℝ) in 0..π, sin x ^ (2 * k + 1)) / ∫ (x : ℝ) in 0..π, sin x ^ (2 * k) and prove that it converges to one using the squeeze theorem. The final product for π is obtained after some algebraic manipulation.