@@ -10,6 +10,7 @@ public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Basic
1010public import Mathlib.Analysis.SpecialFunctions.Trigonometric.Chebyshev.Orthogonality
1111public import Mathlib.Analysis.Complex.Trigonometric
1212import Mathlib.Topology.Algebra.Polynomial
13+ import Mathlib.Algebra.Polynomial.Sequence
1314
1415/-!
1516# Chebyshev polynomials over the reals: Chebyshev–Gauss
@@ -103,68 +104,28 @@ theorem sumZeroes_T_of_not_dvd {n : ℕ} {k : ℤ} (hk : ¬ (2 * n : ℤ) ∣ k)
103104 field [show z ≠ 0 by grind [Complex.exp_ne_zero],
104105 show (z ^ 2 - 1 ≠ 0 ) ∧ (1 - z ^ 2 ≠ 0 ) by grind [exp_sub_one_ne_zero]]
105106
106- -- This probably belongs somewhere else
107- theorem poly_eq_sum_of_deg {F : Type *} [Field F] {n : ℕ} {P : F[X]} {Q : Fin n → F[X]}
108- (hP : P.degree < n) (hQ : ∀ i, (Q i).degree = i) :
109- ∃ c : Fin n → F, P = ∑ i, c i • Q i := by
110- cases hd : P.degree
111- case bot => exact ⟨fun _ => 0 , by simp [P.degree_eq_bot.mp hd]⟩
112- case coe d =>
113- replace hP : d < n := by rw [hd] at hP; exact WithBot.coe_lt_coe.mp hP
114- induction d using Nat.strong_induction_on generalizing P
115- case h d hind =>
116- let γ := P.coeff d / (Q ⟨d, hP⟩).coeff d
117- let cγ (i : Fin n) := if i = d then γ else 0
118- have hcγ : ∑ i, cγ i • Q i = γ • Q ⟨d, hP⟩ := by
119- rw [sum_eq_single ⟨d, hP⟩ (by aesop) (by simp)]
120- simp [cγ]
121- let P' := P - γ • Q ⟨d, hP⟩
122- have hP' : P'.degree < d := by
123- refine (degree_lt_iff_coeff_zero _ _).mpr (fun m hm => ?_)
124- by_cases! m = d
125- case pos hm' =>
126- have : (Q ⟨d, hP⟩).coeff d ≠ 0 := coeff_ne_zero_of_eq_degree (hQ ⟨d, hP⟩)
127- simp [hm', P', γ]; field
128- case neg hm' =>
129- have : P'.degree < d + 1 := by
130- suffices P'.degree ≤ d by
131- grw [this, ← Nat.cast_one, ← Nat.cast_add]
132- norm_cast; simp
133- have := degree_sub_le P (γ • Q ⟨d, hP⟩)
134- grw [this, hd, degree_smul_le, hQ]
135- simp; rfl
136- apply (degree_lt_iff_coeff_zero _ _).mp this
137- grind
138- cases hd' : P'.degree
139- case bot =>
140- use cγ
141- suffices P = γ • Q ⟨d, hP⟩ by rw [this, hcγ]
142- grind [P'.degree_eq_bot.mp hd']
143- case coe d' =>
144- have : d' < d := by rw [hd'] at hP'; exact WithBot.coe_lt_coe.mp hP'
145- obtain ⟨c, hc⟩ := hind d' this hd' (by grind)
146- use fun i => c i + cγ i
147- simp_rw [add_smul]
148- rw [sum_add_distrib, ← hc, hcγ]
149- grind
150-
151107/-- The integral of a polynomial of degree `< 2 * n` with respect to the weight function
152108 `√(1 - x ^ 2)⁻¹` supported on `[-1, 1]` is equal to `π` times the average of its values
153109 on the points `cos ((2 * i + 1) / (2 * n) * π)` for `0 ≤ i < n`. -/
154110theorem integral_eq_sumZeroes {n : ℕ} {P : ℝ[X]} (hn : n ≠ 0 ) (hP : P.degree < 2 * n) :
155111 ∫ x, P.eval x ∂measureT = sumZeroes n P := by
156- obtain ⟨c, rfl⟩ := poly_eq_sum_of_deg hP (fun i => show (T ℝ i).degree = i by simp; rfl)
112+ have hmem : P ∈ degreeLT ℝ (2 * n) := by rwa [mem_degreeLT]
113+ rw [← Sequence.span_degreeLT (m := 2 * n) (chebyshevTsequence ℝ) (by simp),
114+ show Set.Iio (2 * n) = Finset.range (2 * n) by simp, ← Finset.coe_image] at hmem
115+ obtain ⟨c, rfl⟩ := Submodule.mem_span_finset'.mp hmem
157116 simp_rw [eval_finset_sum, eval_smul]
158117 rw [MeasureTheory.integral_finset_sum, sumZeroes_sum]
159118 · simp_rw [sumZeroes_smul, smul_eq_mul, MeasureTheory.integral_const_mul]
160- congr! with i hi
161- by_cases i.val = 0
119+ congr! with t _
120+ obtain ⟨i, hrange, ht⟩ := mem_image.mp t.prop
121+ simp_rw [← ht, chebyshevTsequence]
122+ by_cases i = 0
162123 case pos hi => rw [hi, Nat.cast_zero, integral_eval_T_real_measureT_zero, sumZeroes_T_zero hn]
163124 case neg hi =>
164125 have : ¬ (2 * n : ℤ) ∣ i := by
165126 refine (Int.not_dvd_iff_lt_mul_succ _ (by grind)).mpr ⟨0 , ⟨by grind, ?_⟩⟩
166127 rw_mod_cast [zero_add, mul_one]
167- exact i.isLt
128+ exact mem_range.mp hrange
168129 rw [integral_eval_T_real_measureT_of_ne_zero (by grind), sumZeroes_T_of_not_dvd this]
169130 · simp_rw [← eval_smul]
170131 exact fun i hi => integrable_measureT (by fun_prop)
0 commit comments