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