state
stringlengths 0
159k
| srcUpToTactic
stringlengths 387
167k
| nextTactic
stringlengths 3
9k
| declUpToTactic
stringlengths 22
11.5k
| declId
stringlengths 38
95
| decl
stringlengths 16
1.89k
| file_tag
stringlengths 17
73
|
---|---|---|---|---|---|---|
s : β
n : β
hn : n β 0
| βn / (βn + 1 + s) * GammaSeq s n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)] | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
n : β
hn : n β 0
| βn / (βn + 1 + s) * GammaSeq s n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)] | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
n : β
hn : n β 0
| βn / (βn + 1 + s) * GammaSeq s n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)] | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
n : β
hn : n β 0
β’ βn ^ (s + 1) * βn ! / ((β x in Finset.range n, (s + 1 + βx)) * (s + 1 + βn) * s) =
βn * βn ^ s * βn ! / ((β k in Finset.range n, (s + β(k + 1))) * (βn + 1 + s) * s) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
| congr 3 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a
s : β
n : β
hn : n β 0
β’ βn ^ (s + 1) = βn * βn ^ s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· | rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm] | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a.e_a
s : β
n : β
hn : n β 0
β’ β x in Finset.range n, (s + 1 + βx) = β k in Finset.range n, (s + β(k + 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· | refine' Finset.prod_congr (by rfl) fun x _ => _ | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
n : β
hn : n β 0
β’ Finset.range n = Finset.range n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by | rfl | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a.e_a
s : β
n : β
hn : n β 0
x : β
xβ : x β Finset.range n
β’ s + 1 + βx = s + β(x + 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
| push_cast | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a.e_a
s : β
n : β
hn : n β 0
x : β
xβ : x β Finset.range n
β’ s + 1 + βx = s + (βx + 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; | ring | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a.e_a
s : β
n : β
hn : n β 0
β’ s + 1 + βn = βn + 1 + s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· | abel | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case e_a.e_a.e_a
s : β
n : β
hn : n β 0
β’ s + 1 + βn = βn + 1 + s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· | abel | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.251_0.in2QiCFW52coQT2 | theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
β’ GammaSeq s n = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
| have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
β’ β (x : β), x = x / βn * βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by | intro x | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
x : β
β’ x = x / βn * βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; | rw [div_mul_cancel] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h
s : β
hs : 0 < s.re
n : β
hn : n β 0
x : β
β’ βn β 0 | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; | exact Nat.cast_ne_zero.mpr hn | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
β’ GammaSeq s n = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
| conv_rhs => enter [1, x, 2, 1]; rw [this x] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
| β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | enter [1, x, 2, 1]; rw [this x] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
| β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | enter [1, x, 2, 1]; rw [this x] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
| β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | enter [1, x, 2, 1] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
x : β
| βx | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; | rw [this x] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
β’ GammaSeq s n = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
| rw [GammaSeq_eq_betaIntegral_of_re_pos hs] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
this : β (x : β), x = x / βn * βn
β’ βn ^ s * betaIntegral s (βn + 1) = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
| have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn) | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, (fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1)) (x / βn) =
βn β’ β« (x : β) in 0 / βn..βn / βn, (fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1)) x
β’ βn ^ s * betaIntegral s (βn + 1) = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
| dsimp only at this | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ βn ^ s * betaIntegral s (βn + 1) = β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
| rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ β« (x : β) in 0 ..1, βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) =
β« (x : β) in 0 ..1, ββn * (β((1 - x) ^ n) * β(x * βn) ^ (s - 1))
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ βn β 0 | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
| swap | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ βn β 0 | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· | exact Nat.cast_ne_zero.mpr hn | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ β« (x : β) in 0 ..1, βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) =
β« (x : β) in 0 ..1, ββn * (β((1 - x) ^ n) * β(x * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
| simp_rw [intervalIntegral.integral_of_le zero_le_one] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
β’ β« (x : β) in Ioc 0 1, βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) βvolume =
β« (x : β) in Ioc 0 1, ββn * (β((1 - x) ^ n) * β(x * βn) ^ (s - 1)) βvolume | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
| refine' set_integral_congr measurableSet_Ioc fun x hx => _ | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
β’ βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) = ββn * (β((1 - x) ^ n) * β(x * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
| push_cast | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
β’ βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) = βn * ((1 - βx) ^ n * (βx * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
| have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
β’ βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) = βn * ((1 - βx) ^ n * (βx * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
| have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
β’ βn ^ s = βn ^ (s - 1) * βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
| conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn'] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
| βn ^ s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn'] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
| βn ^ s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn'] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
| βn ^ s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn'] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
β’ s = s - 1 + 1 | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by | ring | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
β’ βn ^ (s - 1) * βn ^ 1 = βn ^ (s - 1) * βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
| simp | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
A : βn ^ s = βn ^ (s - 1) * βn
β’ βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) = βn * ((1 - βx) ^ n * (βx * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
| have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
A : βn ^ s = βn ^ (s - 1) * βn
β’ (βx * βn) ^ (s - 1) = βx ^ (s - 1) * βn ^ (s - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
| rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
A : βn ^ s = βn ^ (s - 1) * βn
B : (βx * βn) ^ (s - 1) = βx ^ (s - 1) * βn ^ (s - 1)
β’ βn ^ s * (βx ^ (s - 1) * (1 - βx) ^ βn) = βn * ((1 - βx) ^ n * (βx * βn) ^ (s - 1)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
| rw [A, B, cpow_nat_cast] | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
n : β
hn : n β 0
thisβ : β (x : β), x = x / βn * βn
this :
β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * β(x / βn * βn) ^ (s - 1) =
βn β’ β« (x : β) in 0 / βn..βn / βn, β((1 - x) ^ n) * β(x * βn) ^ (s - 1)
x : β
hx : x β Ioc 0 1
hn' : βn β 0
A : βn ^ s = βn ^ (s - 1) * βn
B : (βx * βn) ^ (s - 1) = βx ^ (s - 1) * βn ^ (s - 1)
β’ βn ^ (s - 1) * βn * (βx ^ (s - 1) * (1 - βx) ^ n) = βn * ((1 - βx) ^ n * (βx ^ (s - 1) * βn ^ (s - 1))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; | ring | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.264_0.in2QiCFW52coQT2 | theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
β’ Tendsto (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) atTop (π (Gamma s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
| rw [Gamma_eq_integral hs] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
β’ Tendsto (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) atTop (π (GammaIntegral s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
| let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
β’ Tendsto (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) atTop (π (GammaIntegral s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
| have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
β’ β (n : β), Integrable (f n) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
| intro n | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ Integrable (f n) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
| rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ 0 β€ βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by | positivity | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ IntervalIntegrable (fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)) volume 0 βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
| apply IntervalIntegrable.continuousOn_mul | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hf
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ IntervalIntegrable (fun x => βx ^ (s - 1)) volume 0 βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· | refine' intervalIntegral.intervalIntegrable_cpow' _ | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hf
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ -1 < (s - 1).re | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
| rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hg
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ ContinuousOn (fun x => β((1 - x / βn) ^ n)) (uIcc 0 βn) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· | apply Continuous.continuousOn | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hg.h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
n : β
β’ Continuous fun x => β((1 - x / βn) ^ n) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
| exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
β’ Tendsto (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) atTop (π (GammaIntegral s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
| have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
β’ β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
| intro x hx | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
| apply Tendsto.congr' | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ ?fβ =αΆ [atTop] fun n => f n x
case h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ Tendsto ?fβ atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
case fβ
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ β β β | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
| show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ βαΆ (n : β) in atTop, β((1 - x / βn) ^ n) * βx ^ (s - 1) = f n x | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· | refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
n : β
hn : βxββ β€ n
β’ β((1 - x / βn) ^ n) * βx ^ (s - 1) = f n x | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
| rw [Nat.ceil_le] at hn | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
n : β
hn : x β€ βn
β’ β((1 - x / βn) ^ n) * βx ^ (s - 1) = f n x | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
| dsimp only | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
n : β
hn : x β€ βn
β’ β((1 - x / βn) ^ n) * βx ^ (s - 1) = indicator (Ioc 0 βn) (fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)) x | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
| rw [indicator_of_mem] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case hl.h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
n : β
hn : x β€ βn
β’ x β Ioc 0 βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
| exact β¨hx, hnβ© | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ Tendsto (fun x_1 => β((1 - x / βx_1) ^ x_1) * βx ^ (s - 1)) atTop (π (β(rexp (-x)) * βx ^ (s - 1))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· | simp_rw [mul_comm] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ Tendsto (fun x_1 => βx ^ (s - 1) * β((1 - x / βx_1) ^ x_1)) atTop (π (βx ^ (s - 1) * β(rexp (-x)))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
| refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _ | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ Tendsto (fun x_1 => (1 - x / βx_1) ^ x_1) atTop (π (rexp (-x))) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
| convert tendsto_one_plus_div_pow_exp (-x) using 1 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h.e'_3
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
β’ (fun x_1 => (1 - x / βx_1) ^ x_1) = fun x_1 => (1 + -x / βx_1) ^ x_1 | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
| ext1 n | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h.e'_3.h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
x : β
hx : x β Ioi 0
n : β
β’ (1 - x / βn) ^ n = (1 + -x / βn) ^ n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
| rw [neg_div, β sub_eq_add_neg] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
β’ Tendsto (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) atTop (π (GammaIntegral s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
| convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h.e'_3
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
β’ (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) = fun n => β« (a : β) in Ioi 0, f n a | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· | ext1 n | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case h.e'_3.h
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
β’ β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1) = β« (a : β) in Ioi 0, f n a | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
| rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
β’ 0 β€ βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by | positivity | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
β’ β (n : β), βα΅ (a : β) βMeasure.restrict volume (Ioi 0), βf n aβ β€ rexp (-a) * a ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· | intro n | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
β’ βα΅ (a : β) βMeasure.restrict volume (Ioi 0), βf n aβ β€ rexp (-a) * a ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
| refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
β’ βf n xβ β€ rexp (-x) * x ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
| dsimp only | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
β’ βindicator (Ioc 0 βn) (fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)) xβ β€ rexp (-x) * x ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
| rcases lt_or_le (n : β) x with (hxn | hxn) | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case inl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
hxn : βn < x
β’ βindicator (Ioc 0 βn) (fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)) xβ β€ rexp (-x) * x ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· | rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case inl
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
hxn : βn < x
β’ 0 β€ x ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
| exact rpow_nonneg_of_nonneg (le_of_lt hx) _ | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case inr
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
hxn : x β€ βn
β’ βindicator (Ioc 0 βn) (fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)) xβ β€ rexp (-x) * x ^ (s.re - 1) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· | rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)] | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
hxn : x β€ βn
β’ 0 β€ βn | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by | positivity | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case inr
s : β
hs : 0 < s.re
f : β β β β β := fun n => indicator (Ioc 0 βn) fun x => β((1 - x / βn) ^ n) * βx ^ (s - 1)
f_ible : β (n : β), Integrable (f n)
f_tends : β x β Ioi 0, Tendsto (fun n => f n x) atTop (π (β(rexp (-x)) * βx ^ (s - 1)))
n : β
x : β
hx : x β Ioi 0
hxn : x β€ βn
β’ (1 - x / βn) ^ n β€ rexp (-x) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
| exact one_sub_div_pow_le_exp_neg hxn | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.288_0.in2QiCFW52coQT2 | /-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
β’ Tendsto (GammaSeq s) atTop (π (Gamma s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
| suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
β’ Tendsto (GammaSeq s) atTop (π (Gamma s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
| rw [Gamma] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
β’ Tendsto (GammaSeq s) atTop (π (GammaAux β1 - s.reββ s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
| apply this | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case a
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
β’ -ββ1 - s.reββ < s.re | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
| rw [neg_lt] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case a
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
β’ -s.re < ββ1 - s.reββ | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
| rcases lt_or_le 0 (re s) with (hs | hs) | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case a.inl
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
hs : 0 < s.re
β’ -s.re < ββ1 - s.reββ | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· | exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _) | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case a.inr
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
hs : s.re β€ 0
β’ -s.re < ββ1 - s.reββ | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· | refine' (Nat.lt_floor_add_one _).trans_le _ | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case a.inr
s : β
this : β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
hs : s.re β€ 0
β’ ββ-s.reββ + 1 β€ ββ1 - s.reββ | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
| rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
β’ β (m : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
| intro m | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
s : β
m : β
β’ -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
| induction' m with m IH generalizing s | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
β’ -βNat.zero < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux Nat.zero s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
| intro hs | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
hs : -βNat.zero < s.re
β’ Tendsto (GammaSeq s) atTop (π (GammaAux Nat.zero s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
| rw [Nat.cast_zero, neg_zero] at hs | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
hs : 0 < s.re
β’ Tendsto (GammaSeq s) atTop (π (GammaAux Nat.zero s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
| rw [β Gamma_eq_GammaAux] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
hs : 0 < s.re
β’ Tendsto (GammaSeq s) atTop (π (Gamma s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· | refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs) | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
hs : 0 < s.re
β’ (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) =αΆ [atTop] GammaSeq s | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
| refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _) | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero
s : β
hs : 0 < s.re
n : β
hn : n β 0
β’ (fun n => β« (x : β) in 0 ..βn, β((1 - x / βn) ^ n) * βx ^ (s - 1)) n = GammaSeq s n | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
| exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case zero.h1
s : β
hs : 0 < s.re
β’ -s.re < βNat.zero | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· | rwa [Nat.cast_zero, neg_lt_zero] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· | Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case succ
m : β
IH : β (s : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
s : β
β’ -β(Nat.succ m) < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux (Nat.succ m) s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
| intro hs | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case succ
m : β
IH : β (s : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
s : β
hs : -β(Nat.succ m) < s.re
β’ Tendsto (GammaSeq s) atTop (π (GammaAux (Nat.succ m) s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
| rw [Nat.cast_succ, neg_add, β sub_eq_add_neg, sub_lt_iff_lt_add, β one_re, β add_re] at hs | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case succ
m : β
IH : β (s : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
s : β
hs : -βm < (s + 1).re
β’ Tendsto (GammaSeq s) atTop (π (GammaAux (Nat.succ m) s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
rw [Nat.cast_succ, neg_add, β sub_eq_add_neg, sub_lt_iff_lt_add, β one_re, β add_re] at hs
| rw [GammaAux] | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
rw [Nat.cast_succ, neg_add, β sub_eq_add_neg, sub_lt_iff_lt_add, β one_re, β add_re] at hs
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
case succ
m : β
IH : β (s : β), -βm < s.re β Tendsto (GammaSeq s) atTop (π (GammaAux m s))
s : β
hs : -βm < (s + 1).re
β’ Tendsto (GammaSeq s) atTop (π ((fun s => GammaAux m (s + 1) / s) s)) | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.Convolution
import Mathlib.Analysis.SpecialFunctions.Trigonometric.EulerSineProd
import Mathlib.Analysis.SpecialFunctions.Gamma.BohrMollerup
import Mathlib.Analysis.Analytic.IsolatedZeros
#align_import analysis.special_functions.gamma.beta from "leanprover-community/mathlib"@"a3209ddf94136d36e5e5c624b10b2a347cc9d090"
/-!
# The Beta function, and further properties of the Gamma function
In this file we define the Beta integral, relate Beta and Gamma functions, and prove some
refined properties of the Gamma function using these relations.
## Results on the Beta function
* `Complex.betaIntegral`: the Beta function `Ξ(u, v)`, where `u`, `v` are complex with positive
real part.
* `Complex.Gamma_mul_Gamma_eq_betaIntegral`: the formula
`Gamma u * Gamma v = Gamma (u + v) * betaIntegral u v`.
## Results on the Gamma function
* `Complex.Gamma_ne_zero`: for all `s : β` with `s β {-n : n β β}` we have `Ξ s β 0`.
* `Complex.GammaSeq_tendsto_Gamma`: for all `s`, the limit as `n β β` of the sequence
`n β¦ n ^ s * n! / (s * (s + 1) * ... * (s + n))` is `Ξ(s)`.
* `Complex.Gamma_mul_Gamma_one_sub`: Euler's reflection formula
`Gamma s * Gamma (1 - s) = Ο / sin Ο s`.
* `Complex.differentiable_one_div_Gamma`: the function `1 / Ξ(s)` is differentiable everywhere.
* `Complex.Gamma_mul_Gamma_add_half`: Legendre's duplication formula
`Gamma s * Gamma (s + 1 / 2) = Gamma (2 * s) * 2 ^ (1 - 2 * s) * sqrt Ο`.
* `Real.Gamma_ne_zero`, `Real.GammaSeq_tendsto_Gamma`,
`Real.Gamma_mul_Gamma_one_sub`, `Real.Gamma_mul_Gamma_add_half`: real versions of the above.
-/
noncomputable section
set_option linter.uppercaseLean3 false
open Filter intervalIntegral Set Real MeasureTheory
open scoped Nat Topology BigOperators Real
section BetaIntegral
/-! ## The Beta function -/
namespace Complex
/-- The Beta function `Ξ (u, v)`, defined as `β« x:β in 0..1, x ^ (u - 1) * (1 - x) ^ (v - 1)`. -/
noncomputable def betaIntegral (u v : β) : β :=
β« x : β in (0)..1, (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)
#align complex.beta_integral Complex.betaIntegral
/-- Auxiliary lemma for `betaIntegral_convergent`, showing convergence at the left endpoint. -/
theorem betaIntegral_convergent_left {u : β} (hu : 0 < re u) (v : β) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 (1 / 2) := by
apply IntervalIntegrable.mul_continuousOn
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply ContinuousAt.continuousOn
intro x hx
rw [uIcc_of_le (by positivity : (0 : β) β€ 1 / 2)] at hx
apply ContinuousAt.cpow
Β· exact (continuous_const.sub continuous_ofReal).continuousAt
Β· exact continuousAt_const
Β· rw [sub_re, one_re, ofReal_re, sub_pos]
exact Or.inl (hx.2.trans_lt (by norm_num : (1 / 2 : β) < 1))
#align complex.beta_integral_convergent_left Complex.betaIntegral_convergent_left
/-- The Beta integral is convergent for all `u, v` of positive real part. -/
theorem betaIntegral_convergent {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
IntervalIntegrable (fun x =>
(x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1) : β β β) volume 0 1 := by
refine' (betaIntegral_convergent_left hu v).trans _
rw [IntervalIntegrable.iff_comp_neg]
convert ((betaIntegral_convergent_left hv u).comp_add_right 1).symm using 1
Β· ext1 x
conv_lhs => rw [mul_comm]
congr 2 <;> Β· push_cast; ring
Β· norm_num
Β· norm_num
#align complex.beta_integral_convergent Complex.betaIntegral_convergent
theorem betaIntegral_symm (u v : β) : betaIntegral v u = betaIntegral u v := by
rw [betaIntegral, betaIntegral]
have := intervalIntegral.integral_comp_mul_add (a := 0) (b := 1) (c := -1)
(fun x : β => (x : β) ^ (u - 1) * (1 - (x : β)) ^ (v - 1)) neg_one_lt_zero.ne 1
rw [inv_neg, inv_one, neg_one_smul, β intervalIntegral.integral_symm] at this
simp? at this says
simp only [neg_mul, one_mul, ofReal_add, ofReal_neg, ofReal_one, sub_add_cancel'', neg_neg,
mul_one, add_left_neg, mul_zero, zero_add] at this
conv_lhs at this => arg 1; intro x; rw [add_comm, β sub_eq_add_neg, mul_comm]
exact this
#align complex.beta_integral_symm Complex.betaIntegral_symm
theorem betaIntegral_eval_one_right {u : β} (hu : 0 < re u) : betaIntegral u 1 = 1 / u := by
simp_rw [betaIntegral, sub_self, cpow_zero, mul_one]
rw [integral_cpow (Or.inl _)]
Β· rw [ofReal_zero, ofReal_one, one_cpow, zero_cpow, sub_zero, sub_add_cancel]
rw [sub_add_cancel]
contrapose! hu; rw [hu, zero_re]
Β· rwa [sub_re, one_re, β sub_pos, sub_neg_eq_add, sub_add_cancel]
#align complex.beta_integral_eval_one_right Complex.betaIntegral_eval_one_right
theorem betaIntegral_scaled (s t : β) {a : β} (ha : 0 < a) :
β« x in (0)..a, (x : β) ^ (s - 1) * ((a : β) - x) ^ (t - 1) =
(a : β) ^ (s + t - 1) * betaIntegral s t := by
have ha' : (a : β) β 0 := ofReal_ne_zero.mpr ha.ne'
rw [betaIntegral]
have A : (a : β) ^ (s + t - 1) = a * ((a : β) ^ (s - 1) * (a : β) ^ (t - 1)) := by
rw [(by abel : s + t - 1 = 1 + (s - 1) + (t - 1)), cpow_add _ _ ha', cpow_add 1 _ ha', cpow_one,
mul_assoc]
rw [A, mul_assoc, β intervalIntegral.integral_const_mul, β real_smul, β zero_div a, β
div_self ha.ne', β intervalIntegral.integral_comp_div _ ha.ne', zero_div]
simp_rw [intervalIntegral.integral_of_le ha.le]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
rw [mul_mul_mul_comm]
congr 1
Β· rw [β mul_cpow_ofReal_nonneg ha.le (div_pos hx.1 ha).le, ofReal_div, mul_div_cancel' _ ha']
Β· rw [(by norm_cast : (1 : β) - β(x / a) = β(1 - x / a)), β
mul_cpow_ofReal_nonneg ha.le (sub_nonneg.mpr <| (div_le_one ha).mpr hx.2)]
push_cast
rw [mul_sub, mul_one, mul_div_cancel' _ ha']
#align complex.beta_integral_scaled Complex.betaIntegral_scaled
/-- Relation between Beta integral and Gamma function. -/
theorem Gamma_mul_Gamma_eq_betaIntegral {s t : β} (hs : 0 < re s) (ht : 0 < re t) :
Gamma s * Gamma t = Gamma (s + t) * betaIntegral s t := by
-- Note that we haven't proved (yet) that the Gamma function has no zeroes, so we can't formulate
-- this as a formula for the Beta function.
have conv_int := integral_posConvolution
(GammaIntegral_convergent hs) (GammaIntegral_convergent ht) (ContinuousLinearMap.mul β β)
simp_rw [ContinuousLinearMap.mul_apply'] at conv_int
have hst : 0 < re (s + t) := by rw [add_re]; exact add_pos hs ht
rw [Gamma_eq_integral hs, Gamma_eq_integral ht, Gamma_eq_integral hst, GammaIntegral,
GammaIntegral, GammaIntegral, β conv_int, β integral_mul_right (betaIntegral _ _)]
refine' set_integral_congr measurableSet_Ioi fun x hx => _
rw [mul_assoc, β betaIntegral_scaled s t hx, β intervalIntegral.integral_const_mul]
congr 1 with y : 1
push_cast
suffices Complex.exp (-x) = Complex.exp (-y) * Complex.exp (-(x - y)) by rw [this]; ring
Β· rw [β Complex.exp_add]; congr 1; abel
#align complex.Gamma_mul_Gamma_eq_beta_integral Complex.Gamma_mul_Gamma_eq_betaIntegral
/-- Recurrence formula for the Beta function. -/
theorem betaIntegral_recurrence {u v : β} (hu : 0 < re u) (hv : 0 < re v) :
u * betaIntegral u (v + 1) = v * betaIntegral (u + 1) v := by
-- NB: If we knew `Gamma (u + v + 1) β 0` this would be an easy consequence of
-- `Gamma_mul_Gamma_eq_betaIntegral`; but we don't know that yet. We will prove it later, but
-- this lemma is needed in the proof. So we give a (somewhat laborious) direct argument.
let F : β β β := fun x => (x : β) ^ u * (1 - (x : β)) ^ v
have hu' : 0 < re (u + 1) := by rw [add_re, one_re]; positivity
have hv' : 0 < re (v + 1) := by rw [add_re, one_re]; positivity
have hc : ContinuousOn F (Icc 0 1) := by
refine' (ContinuousAt.continuousOn fun x hx => _).mul (ContinuousAt.continuousOn fun x hx => _)
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hu).comp continuous_ofReal.continuousAt
rw [ofReal_re]; exact hx.1
Β· refine' (continuousAt_cpow_const_of_re_pos (Or.inl _) hv).comp
(continuous_const.sub continuous_ofReal).continuousAt
rw [sub_re, one_re, ofReal_re, sub_nonneg]
exact hx.2
have hder : β x : β, x β Ioo (0 : β) 1 β
HasDerivAt F (u * ((x : β) ^ (u - 1) * (1 - (x : β)) ^ v) -
v * ((x : β) ^ u * (1 - (x : β)) ^ (v - 1))) x := by
intro x hx
have U : HasDerivAt (fun y : β => y ^ u) (u * (x : β) ^ (u - 1)) βx := by
have := @HasDerivAt.cpow_const _ _ _ u (hasDerivAt_id (x : β)) (Or.inl ?_)
simp only [id_eq, mul_one] at this
Β· exact this
Β· rw [id_eq, ofReal_re]; exact hx.1
have V : HasDerivAt (fun y : β => (1 - y) ^ v) (-v * (1 - (x : β)) ^ (v - 1)) βx := by
have A := @HasDerivAt.cpow_const _ _ _ v (hasDerivAt_id (1 - (x : β))) (Or.inl ?_)
swap; Β· rw [id.def, sub_re, one_re, ofReal_re, sub_pos]; exact hx.2
simp_rw [id.def] at A
have B : HasDerivAt (fun y : β => 1 - y) (-1) βx := by
apply HasDerivAt.const_sub; apply hasDerivAt_id
convert HasDerivAt.comp (βx) A B using 1
ring
convert (U.mul V).comp_ofReal using 1
ring
have h_int := ((betaIntegral_convergent hu hv').const_mul u).sub
((betaIntegral_convergent hu' hv).const_mul v)
rw [add_sub_cancel, add_sub_cancel] at h_int
have int_ev := intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le zero_le_one hc hder h_int
have hF0 : F 0 = 0 := by
simp only [mul_eq_zero, ofReal_zero, cpow_eq_zero_iff, eq_self_iff_true, Ne.def, true_and_iff,
sub_zero, one_cpow, one_ne_zero, or_false_iff]
contrapose! hu; rw [hu, zero_re]
have hF1 : F 1 = 0 := by
simp only [mul_eq_zero, ofReal_one, one_cpow, one_ne_zero, sub_self, cpow_eq_zero_iff,
eq_self_iff_true, Ne.def, true_and_iff, false_or_iff]
contrapose! hv; rw [hv, zero_re]
rw [hF0, hF1, sub_zero, intervalIntegral.integral_sub, intervalIntegral.integral_const_mul,
intervalIntegral.integral_const_mul] at int_ev
Β· rw [betaIntegral, betaIntegral, β sub_eq_zero]
convert int_ev <;> ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu hv'; ring
Β· apply IntervalIntegrable.const_mul
convert betaIntegral_convergent hu' hv; ring
#align complex.beta_integral_recurrence Complex.betaIntegral_recurrence
/-- Explicit formula for the Beta function when second argument is a positive integer. -/
theorem betaIntegral_eval_nat_add_one_right {u : β} (hu : 0 < re u) (n : β) :
betaIntegral u (n + 1) = n ! / β j : β in Finset.range (n + 1), (u + j) := by
induction' n with n IH generalizing u
Β· rw [Nat.cast_zero, zero_add, betaIntegral_eval_one_right hu, Nat.factorial_zero, Nat.cast_one]
simp
Β· have := betaIntegral_recurrence hu (?_ : 0 < re n.succ)
swap; Β· rw [β ofReal_nat_cast, ofReal_re]; positivity
rw [mul_comm u _, β eq_div_iff] at this
swap; Β· contrapose! hu; rw [hu, zero_re]
rw [this, Finset.prod_range_succ', Nat.cast_succ, IH]
swap; Β· rw [add_re, one_re]; positivity
rw [Nat.factorial_succ, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_zero, add_zero, β
mul_div_assoc, β div_div]
congr 3 with j : 1
push_cast; abel
#align complex.beta_integral_eval_nat_add_one_right Complex.betaIntegral_eval_nat_add_one_right
end Complex
end BetaIntegral
section LimitFormula
/-! ## The Euler limit formula -/
namespace Complex
/-- The sequence with `n`-th term `n ^ s * n! / (s * (s + 1) * ... * (s + n))`, for complex `s`.
We will show that this tends to `Ξ(s)` as `n β β`. -/
noncomputable def GammaSeq (s : β) (n : β) :=
(n : β) ^ s * n ! / β j : β in Finset.range (n + 1), (s + j)
#align complex.Gamma_seq Complex.GammaSeq
theorem GammaSeq_eq_betaIntegral_of_re_pos {s : β} (hs : 0 < re s) (n : β) :
GammaSeq s n = (n : β) ^ s * betaIntegral s (n + 1) := by
rw [GammaSeq, betaIntegral_eval_nat_add_one_right hs n, β mul_div_assoc]
#align complex.Gamma_seq_eq_beta_integral_of_re_pos Complex.GammaSeq_eq_betaIntegral_of_re_pos
theorem GammaSeq_add_one_left (s : β) {n : β} (hn : n β 0) :
GammaSeq (s + 1) n / s = n / (n + 1 + s) * GammaSeq s n := by
conv_lhs => rw [GammaSeq, Finset.prod_range_succ, div_div]
conv_rhs =>
rw [GammaSeq, Finset.prod_range_succ', Nat.cast_zero, add_zero, div_mul_div_comm, β mul_assoc,
β mul_assoc, mul_comm _ (Finset.prod _ _)]
congr 3
Β· rw [cpow_add _ _ (Nat.cast_ne_zero.mpr hn), cpow_one, mul_comm]
Β· refine' Finset.prod_congr (by rfl) fun x _ => _
push_cast; ring
Β· abel
#align complex.Gamma_seq_add_one_left Complex.GammaSeq_add_one_left
theorem GammaSeq_eq_approx_Gamma_integral {s : β} (hs : 0 < re s) {n : β} (hn : n β 0) :
GammaSeq s n = β« x : β in (0)..n, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) := by
have : β x : β, x = x / n * n := by intro x; rw [div_mul_cancel]; exact Nat.cast_ne_zero.mpr hn
conv_rhs => enter [1, x, 2, 1]; rw [this x]
rw [GammaSeq_eq_betaIntegral_of_re_pos hs]
have := intervalIntegral.integral_comp_div (a := 0) (b := n)
(fun x => β((1 - x) ^ n) * β(x * βn) ^ (s - 1) : β β β) (Nat.cast_ne_zero.mpr hn)
dsimp only at this
rw [betaIntegral, this, real_smul, zero_div, div_self, add_sub_cancel,
β intervalIntegral.integral_const_mul, β intervalIntegral.integral_const_mul]
swap; Β· exact Nat.cast_ne_zero.mpr hn
simp_rw [intervalIntegral.integral_of_le zero_le_one]
refine' set_integral_congr measurableSet_Ioc fun x hx => _
push_cast
have hn' : (n : β) β 0 := Nat.cast_ne_zero.mpr hn
have A : (n : β) ^ s = (n : β) ^ (s - 1) * n := by
conv_lhs => rw [(by ring : s = s - 1 + 1), cpow_add _ _ hn']
simp
have B : ((x : β) * βn) ^ (s - 1) = (x : β) ^ (s - 1) * (n : β) ^ (s - 1) := by
rw [β ofReal_nat_cast,
mul_cpow_ofReal_nonneg hx.1.le (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hn)).le]
rw [A, B, cpow_nat_cast]; ring
#align complex.Gamma_seq_eq_approx_Gamma_integral Complex.GammaSeq_eq_approx_Gamma_integral
/-- The main techical lemma for `GammaSeq_tendsto_Gamma`, expressing the integral defining the
Gamma function for `0 < re s` as the limit of a sequence of integrals over finite intervals. -/
theorem approx_Gamma_integral_tendsto_Gamma_integral {s : β} (hs : 0 < re s) :
Tendsto (fun n : β => β« x : β in (0)..n, ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)) atTop
(π <| Gamma s) := by
rw [Gamma_eq_integral hs]
-- We apply dominated convergence to the following function, which we will show is uniformly
-- bounded above by the Gamma integrand `exp (-x) * x ^ (re s - 1)`.
let f : β β β β β := fun n =>
indicator (Ioc 0 (n : β)) fun x : β => ((1 - x / n) ^ n : β) * (x : β) ^ (s - 1)
-- integrability of f
have f_ible : β n : β, Integrable (f n) (volume.restrict (Ioi 0)) := by
intro n
rw [integrable_indicator_iff (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)), IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self, β IntegrableOn, β
intervalIntegrable_iff_integrableOn_Ioc_of_le (by positivity : (0 : β) β€ n)]
apply IntervalIntegrable.continuousOn_mul
Β· refine' intervalIntegral.intervalIntegrable_cpow' _
rwa [sub_re, one_re, β zero_sub, sub_lt_sub_iff_right]
Β· apply Continuous.continuousOn
exact IsROrC.continuous_ofReal.comp -- Porting note: was `continuity`
((continuous_const.sub (continuous_id'.div_const βn)).pow n)
-- pointwise limit of f
have f_tends : β x : β, x β Ioi (0 : β) β
Tendsto (fun n : β => f n x) atTop (π <| β(Real.exp (-x)) * (x : β) ^ (s - 1)) := by
intro x hx
apply Tendsto.congr'
show βαΆ n : β in atTop, β((1 - x / n) ^ n) * (x : β) ^ (s - 1) = f n x
Β· refine' Eventually.mp (eventually_ge_atTop βxββ) (eventually_of_forall fun n hn => _)
rw [Nat.ceil_le] at hn
dsimp only
rw [indicator_of_mem]
exact β¨hx, hnβ©
Β· simp_rw [mul_comm]
refine' (Tendsto.comp (continuous_ofReal.tendsto _) _).const_mul _
convert tendsto_one_plus_div_pow_exp (-x) using 1
ext1 n
rw [neg_div, β sub_eq_add_neg]
-- let `convert` identify the remaining goals
convert tendsto_integral_of_dominated_convergence _ (fun n => (f_ible n).1)
(Real.GammaIntegral_convergent hs) _
((ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ f_tends)) using 1
-- limit of f is the integrand we want
Β· ext1 n
rw [integral_indicator (measurableSet_Ioc : MeasurableSet (Ioc (_ : β) _)),
intervalIntegral.integral_of_le (by positivity : 0 β€ (n : β)),
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
-- f is uniformly bounded by the Gamma integrand
Β· intro n
refine' (ae_restrict_iff' measurableSet_Ioi).mpr (ae_of_all _ fun x hx => _)
dsimp only
rcases lt_or_le (n : β) x with (hxn | hxn)
Β· rw [indicator_of_not_mem (not_mem_Ioc_of_gt hxn), norm_zero,
mul_nonneg_iff_right_nonneg_of_pos (exp_pos _)]
exact rpow_nonneg_of_nonneg (le_of_lt hx) _
Β· rw [indicator_of_mem (mem_Ioc.mpr β¨mem_Ioi.mp hx, hxnβ©), norm_mul, Complex.norm_eq_abs,
Complex.abs_of_nonneg
(pow_nonneg (sub_nonneg.mpr <| div_le_one_of_le hxn <| by positivity) _),
Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos hx, sub_re, one_re,
mul_le_mul_right (rpow_pos_of_pos hx _)]
exact one_sub_div_pow_le_exp_neg hxn
#align complex.approx_Gamma_integral_tendsto_Gamma_integral Complex.approx_Gamma_integral_tendsto_Gamma_integral
/-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
rw [Nat.cast_succ, neg_add, β sub_eq_add_neg, sub_lt_iff_lt_add, β one_re, β add_re] at hs
rw [GammaAux]
| have := @Tendsto.congr' _ _ _ ?_ _ _
((eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => ?_)) ((IH _ hs).div_const s) | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) := by
suffices β m : β, -βm < re s β Tendsto (GammaSeq s) atTop (π <| GammaAux m s) by
rw [Gamma]
apply this
rw [neg_lt]
rcases lt_or_le 0 (re s) with (hs | hs)
Β· exact (neg_neg_of_pos hs).trans_le (Nat.cast_nonneg _)
Β· refine' (Nat.lt_floor_add_one _).trans_le _
rw [sub_eq_neg_add, Nat.floor_add_one (neg_nonneg.mpr hs), Nat.cast_add_one]
intro m
induction' m with m IH generalizing s
Β· -- Base case: `0 < re s`, so Gamma is given by the integral formula
intro hs
rw [Nat.cast_zero, neg_zero] at hs
rw [β Gamma_eq_GammaAux]
Β· refine' Tendsto.congr' _ (approx_Gamma_integral_tendsto_Gamma_integral hs)
refine' (eventually_ne_atTop 0).mp (eventually_of_forall fun n hn => _)
exact (GammaSeq_eq_approx_Gamma_integral hs hn).symm
Β· rwa [Nat.cast_zero, neg_lt_zero]
Β· -- Induction step: use recurrence formulae in `s` for Gamma and GammaSeq
intro hs
rw [Nat.cast_succ, neg_add, β sub_eq_add_neg, sub_lt_iff_lt_add, β one_re, β add_re] at hs
rw [GammaAux]
| Mathlib.Analysis.SpecialFunctions.Gamma.Beta.351_0.in2QiCFW52coQT2 | /-- Euler's limit formula for the complex Gamma function. -/
theorem GammaSeq_tendsto_Gamma (s : β) : Tendsto (GammaSeq s) atTop (π <| Gamma s) | Mathlib_Analysis_SpecialFunctions_Gamma_Beta |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.