Skip to content

Commit 990b386

Browse files
urkudj-loreaux
andcommitted
feat: port Analysis.InnerProductSpace.Rayleigh (#4920)
Co-authored-by: Jireh Loreaux <loreaujy@gmail.com>
1 parent 29838ac commit 990b386

File tree

2 files changed

+296
-0
lines changed

2 files changed

+296
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ import Mathlib.Analysis.InnerProductSpace.Orthogonal
594594
import Mathlib.Analysis.InnerProductSpace.PiL2
595595
import Mathlib.Analysis.InnerProductSpace.Positive
596596
import Mathlib.Analysis.InnerProductSpace.Projection
597+
import Mathlib.Analysis.InnerProductSpace.Rayleigh
597598
import Mathlib.Analysis.InnerProductSpace.Symmetric
598599
import Mathlib.Analysis.InnerProductSpace.TwoDim
599600
import Mathlib.Analysis.InnerProductSpace.l2Space
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
/-
2+
Copyright (c) 2021 Heather Macbeth. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Heather Macbeth, Frédéric Dupuis
5+
6+
! This file was ported from Lean 3 source module analysis.inner_product_space.rayleigh
7+
! leanprover-community/mathlib commit 6b0169218d01f2837d79ea2784882009a0da1aa1
8+
! Please do not edit these lines, except to modify the commit id
9+
! if you have ported upstream changes.
10+
-/
11+
import Mathlib.Analysis.InnerProductSpace.Calculus
12+
import Mathlib.Analysis.InnerProductSpace.Dual
13+
import Mathlib.Analysis.InnerProductSpace.Adjoint
14+
import Mathlib.Analysis.Calculus.LagrangeMultipliers
15+
import Mathlib.LinearAlgebra.Eigenspace.Basic
16+
17+
/-!
18+
# The Rayleigh quotient
19+
20+
The Rayleigh quotient of a self-adjoint operator `T` on an inner product space `E` is the function
21+
`λ x, ⟪T x, x⟫ / ‖x‖ ^ 2`.
22+
23+
The main results of this file are `IsSelfAdjoint.hasEigenvector_of_isMaxOn` and
24+
`IsSelfAdjoint.hasEigenvector_of_isMinOn`, which state that if `E` is complete, and if the
25+
Rayleigh quotient attains its global maximum/minimum over some sphere at the point `x₀`, then `x₀`
26+
is an eigenvector of `T`, and the `iSup`/`iInf` of `λ x, ⟪T x, x⟫ / ‖x‖ ^ 2` is the corresponding
27+
eigenvalue.
28+
29+
The corollaries `LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` and
30+
`LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional` state that if `E` is
31+
finite-dimensional and nontrivial, then `T` has some (nonzero) eigenvectors with eigenvalue the
32+
`iSup`/`iInf` of `λ x, ⟪T x, x⟫ / ‖x‖ ^ 2`.
33+
34+
## TODO
35+
36+
A slightly more elaborate corollary is that if `E` is complete and `T` is a compact operator, then
37+
`T` has some (nonzero) eigenvector with eigenvalue either `⨆ x, ⟪T x, x⟫ / ‖x‖ ^ 2` or
38+
`⨅ x, ⟪T x, x⟫ / ‖x‖ ^ 2` (not necessarily both).
39+
40+
-/
41+
42+
43+
variable {𝕜 : Type _} [IsROrC 𝕜]
44+
45+
variable {E : Type _} [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
46+
47+
local notation "⟪" x ", " y "⟫" => @inner 𝕜 _ _ x y
48+
49+
open scoped NNReal
50+
51+
open Module.End Metric
52+
53+
namespace ContinuousLinearMap
54+
55+
variable (T : E →L[𝕜] E)
56+
57+
/-- The *Rayleigh quotient* of a continuous linear map `T` (over `ℝ` or `ℂ`) at a vector `x` is
58+
the quantity `re ⟪T x, x⟫ / ‖x‖ ^ 2`. -/
59+
noncomputable abbrev rayleighQuotient (x : E) := T.reApplyInnerSelf x / ‖(x : E)‖ ^ 2
60+
61+
theorem rayleigh_smul (x : E) {c : 𝕜} (hc : c ≠ 0) :
62+
rayleighQuotient T (c • x) = rayleighQuotient T x := by
63+
by_cases hx : x = 0
64+
· simp [hx]
65+
have : ‖c‖ ≠ 0 := by simp [hc]
66+
have : ‖x‖ ≠ 0 := by simp [hx]
67+
field_simp [norm_smul, T.reApplyInnerSelf_smul]
68+
ring
69+
#align continuous_linear_map.rayleigh_smul ContinuousLinearMap.rayleigh_smul
70+
71+
theorem image_rayleigh_eq_image_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
72+
rayleighQuotient T '' {0}ᶜ = rayleighQuotient T '' sphere 0 r := by
73+
ext a
74+
constructor
75+
· rintro ⟨x, hx : x ≠ 0, hxT⟩
76+
have : ‖x‖ ≠ 0 := by simp [hx]
77+
let c : 𝕜 := ↑‖x‖⁻¹ * r
78+
have : c ≠ 0 := by simp [hx, hr.ne']
79+
refine' ⟨c • x, _, _⟩
80+
· field_simp [norm_smul, abs_of_pos hr]
81+
· rw [T.rayleigh_smul x this]
82+
exact hxT
83+
· rintro ⟨x, hx, hxT⟩
84+
exact ⟨x, ne_zero_of_mem_sphere hr.ne' ⟨x, hx⟩, hxT⟩
85+
#align continuous_linear_map.image_rayleigh_eq_image_rayleigh_sphere ContinuousLinearMap.image_rayleigh_eq_image_rayleigh_sphere
86+
87+
theorem iSup_rayleigh_eq_iSup_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
88+
(⨆ x : { x : E // x ≠ 0 }, rayleighQuotient T x) =
89+
⨆ x : sphere (0 : E) r, rayleighQuotient T x :=
90+
show (⨆ x : ({0}ᶜ : Set E), rayleighQuotient T x) = _ by
91+
simp only [← @sSup_image' _ _ _ _ (rayleighQuotient T),
92+
T.image_rayleigh_eq_image_rayleigh_sphere hr]
93+
#align continuous_linear_map.supr_rayleigh_eq_supr_rayleigh_sphere ContinuousLinearMap.iSup_rayleigh_eq_iSup_rayleigh_sphere
94+
95+
theorem iInf_rayleigh_eq_iInf_rayleigh_sphere {r : ℝ} (hr : 0 < r) :
96+
(⨅ x : { x : E // x ≠ 0 }, rayleighQuotient T x) =
97+
⨅ x : sphere (0 : E) r, rayleighQuotient T x :=
98+
show (⨅ x : ({0}ᶜ : Set E), rayleighQuotient T x) = _ by
99+
simp only [← @sInf_image' _ _ _ _ (rayleighQuotient T),
100+
T.image_rayleigh_eq_image_rayleigh_sphere hr]
101+
#align continuous_linear_map.infi_rayleigh_eq_infi_rayleigh_sphere ContinuousLinearMap.iInf_rayleigh_eq_iInf_rayleigh_sphere
102+
103+
end ContinuousLinearMap
104+
105+
namespace IsSelfAdjoint
106+
107+
section Real
108+
109+
variable {F : Type _} [NormedAddCommGroup F] [InnerProductSpace ℝ F]
110+
111+
theorem _root_.LinearMap.IsSymmetric.hasStrictFDerivAt_reApplyInnerSelf {T : F →L[ℝ] F}
112+
(hT : (T : F →ₗ[ℝ] F).IsSymmetric) (x₀ : F) :
113+
HasStrictFDerivAt T.reApplyInnerSelf (2 • (innerSL ℝ (T x₀))) x₀ := by
114+
convert T.hasStrictFDerivAt.inner ℝ (hasStrictFDerivAt_id x₀) using 1
115+
ext y
116+
rw [ContinuousLinearMap.smul_apply, ContinuousLinearMap.comp_apply, fderivInnerClm_apply,
117+
ContinuousLinearMap.prod_apply, innerSL_apply, id.def, ContinuousLinearMap.id_apply,
118+
hT.apply_clm x₀ y, real_inner_comm _ x₀, two_smul]
119+
#align linear_map.is_symmetric.has_strict_fderiv_at_re_apply_inner_self LinearMap.IsSymmetric.hasStrictFDerivAt_reApplyInnerSelf
120+
121+
variable [CompleteSpace F] {T : F →L[ℝ] F}
122+
123+
local macro_rules | `($x ^ $y) => `(HPow.hPow $x $y)
124+
125+
theorem linearly_dependent_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : F}
126+
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : F) ‖x₀‖) x₀) :
127+
∃ a b : ℝ, (a, b) ≠ 0 ∧ a • x₀ + b • T x₀ = 0 := by
128+
have H : IsLocalExtrOn T.reApplyInnerSelf {x : F | ‖x‖ ^ 2 = ‖x₀‖ ^ 2} x₀ := by
129+
convert hextr
130+
ext x
131+
simp [dist_eq_norm]
132+
-- find Lagrange multipliers for the function `T.re_apply_inner_self` and the
133+
-- hypersurface-defining function `λ x, ‖x‖ ^ 2`
134+
obtain ⟨a, b, h₁, h₂⟩ :=
135+
IsLocalExtrOn.exists_multipliers_of_hasStrictFDerivAt_1d H (hasStrictFDerivAt_norm_sq x₀)
136+
(hT.isSymmetric.hasStrictFDerivAt_reApplyInnerSelf x₀)
137+
refine' ⟨a, b, h₁, _⟩
138+
apply (InnerProductSpace.toDualMap ℝ F).injective
139+
simp only [LinearIsometry.map_add, LinearIsometry.map_smul, LinearIsometry.map_zero]
140+
simp only [map_smulₛₗ, IsROrC.conj_to_real]
141+
change a • innerSL ℝ x₀ + b • innerSL ℝ (T x₀) = 0
142+
apply smul_right_injective (F →L[ℝ] ℝ) (two_ne_zero : (2 : ℝ) ≠ 0)
143+
simpa only [two_smul, smul_add, add_smul, add_zero] using h₂
144+
#align is_self_adjoint.linearly_dependent_of_is_local_extr_on IsSelfAdjoint.linearly_dependent_of_isLocalExtrOn
145+
146+
theorem eq_smul_self_of_isLocalExtrOn_real (hT : IsSelfAdjoint T) {x₀ : F}
147+
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : F) ‖x₀‖) x₀) :
148+
T x₀ = T.rayleighQuotient x₀ • x₀ := by
149+
obtain ⟨a, b, h₁, h₂⟩ := hT.linearly_dependent_of_isLocalExtrOn hextr
150+
by_cases hx₀ : x₀ = 0
151+
· simp [hx₀]
152+
by_cases hb : b = 0
153+
· have : a ≠ 0 := by simpa [hb] using h₁
154+
refine' absurd _ hx₀
155+
apply smul_right_injective F this
156+
simpa [hb] using h₂
157+
let c : ℝ := -b⁻¹ * a
158+
have hc : T x₀ = c • x₀ := by
159+
have : b * (b⁻¹ * a) = a := by field_simp [mul_comm]
160+
apply smul_right_injective F hb
161+
simp [eq_neg_of_add_eq_zero_left h₂, ← mul_smul, this]
162+
convert hc
163+
have : ‖x₀‖ ≠ 0 := by simp [hx₀]
164+
have := congr_arg (fun x => ⟪x, x₀⟫_ℝ) hc
165+
field_simp [inner_smul_left, real_inner_self_eq_norm_mul_norm, sq] at this ⊢
166+
exact this
167+
#align is_self_adjoint.eq_smul_self_of_is_local_extr_on_real IsSelfAdjoint.eq_smul_self_of_isLocalExtrOn_real
168+
169+
end Real
170+
171+
section CompleteSpace
172+
173+
variable [CompleteSpace E] {T : E →L[𝕜] E}
174+
175+
theorem eq_smul_self_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : E}
176+
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
177+
T x₀ = (↑(T.rayleighQuotient x₀) : 𝕜) • x₀ := by
178+
letI := InnerProductSpace.isROrCToReal 𝕜 E
179+
let hSA := hT.isSymmetric.restrictScalars.toSelfAdjoint.prop
180+
exact hSA.eq_smul_self_of_isLocalExtrOn_real hextr
181+
#align is_self_adjoint.eq_smul_self_of_is_local_extr_on IsSelfAdjoint.eq_smul_self_of_isLocalExtrOn
182+
183+
/-- For a self-adjoint operator `T`, a local extremum of the Rayleigh quotient of `T` on a sphere
184+
centred at the origin is an eigenvector of `T`. -/
185+
theorem hasEigenvector_of_isLocalExtrOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
186+
(hextr : IsLocalExtrOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
187+
HasEigenvector (T : E →ₗ[𝕜] E) (↑(T.rayleighQuotient x₀)) x₀ := by
188+
refine' ⟨_, hx₀⟩
189+
rw [Module.End.mem_eigenspace_iff]
190+
exact hT.eq_smul_self_of_isLocalExtrOn hextr
191+
#align is_self_adjoint.has_eigenvector_of_is_local_extr_on IsSelfAdjoint.hasEigenvector_of_isLocalExtrOn
192+
193+
/-- For a self-adjoint operator `T`, a maximum of the Rayleigh quotient of `T` on a sphere centred
194+
at the origin is an eigenvector of `T`, with eigenvalue the global supremum of the Rayleigh
195+
quotient. -/
196+
theorem hasEigenvector_of_isMaxOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
197+
(hextr : IsMaxOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
198+
HasEigenvector (T : E →ₗ[𝕜] E) (↑(⨆ x : { x : E // x ≠ 0 }, T.rayleighQuotient x)) x₀ := by
199+
convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inr hextr.localize)
200+
have hx₀' : 0 < ‖x₀‖ := by simp [hx₀]
201+
have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp
202+
rw [T.iSup_rayleigh_eq_iSup_rayleigh_sphere hx₀']
203+
refine' IsMaxOn.iSup_eq hx₀'' _
204+
intro x hx
205+
dsimp
206+
have : ‖x‖ = ‖x₀‖ := by simpa using hx
207+
simp only [ContinuousLinearMap.rayleighQuotient]
208+
rw [this]
209+
gcongr
210+
exact hextr hx
211+
#align is_self_adjoint.has_eigenvector_of_is_max_on IsSelfAdjoint.hasEigenvector_of_isMaxOn
212+
213+
/-- For a self-adjoint operator `T`, a minimum of the Rayleigh quotient of `T` on a sphere centred
214+
at the origin is an eigenvector of `T`, with eigenvalue the global infimum of the Rayleigh
215+
quotient. -/
216+
theorem hasEigenvector_of_isMinOn (hT : IsSelfAdjoint T) {x₀ : E} (hx₀ : x₀ ≠ 0)
217+
(hextr : IsMinOn T.reApplyInnerSelf (sphere (0 : E) ‖x₀‖) x₀) :
218+
HasEigenvector (T : E →ₗ[𝕜] E) (↑(⨅ x : { x : E // x ≠ 0 }, T.rayleighQuotient x)) x₀ := by
219+
convert hT.hasEigenvector_of_isLocalExtrOn hx₀ (Or.inl hextr.localize)
220+
have hx₀' : 0 < ‖x₀‖ := by simp [hx₀]
221+
have hx₀'' : x₀ ∈ sphere (0 : E) ‖x₀‖ := by simp
222+
rw [T.iInf_rayleigh_eq_iInf_rayleigh_sphere hx₀']
223+
refine' IsMinOn.iInf_eq hx₀'' _
224+
intro x hx
225+
dsimp
226+
have : ‖x‖ = ‖x₀‖ := by simpa using hx
227+
simp only [ContinuousLinearMap.rayleighQuotient]
228+
rw [this]
229+
gcongr
230+
exact hextr hx
231+
#align is_self_adjoint.has_eigenvector_of_is_min_on IsSelfAdjoint.hasEigenvector_of_isMinOn
232+
233+
end CompleteSpace
234+
235+
end IsSelfAdjoint
236+
237+
section FiniteDimensional
238+
239+
variable [FiniteDimensional 𝕜 E] [_i : Nontrivial E] {T : E →ₗ[𝕜] E}
240+
241+
namespace LinearMap
242+
243+
namespace IsSymmetric
244+
245+
/-- The supremum of the Rayleigh quotient of a symmetric operator `T` on a nontrivial
246+
finite-dimensional vector space is an eigenvalue for that operator. -/
247+
theorem hasEigenvalue_iSup_of_finiteDimensional (hT : T.IsSymmetric) :
248+
HasEigenvalue T ↑(⨆ x : { x : E // x ≠ 0 }, IsROrC.re ⟪T x, x⟫ / ‖(x : E)‖ ^ 2) := by
249+
haveI := FiniteDimensional.proper_isROrC 𝕜 E
250+
let T' := hT.toSelfAdjoint
251+
obtain ⟨x, hx⟩ : ∃ x : E, x ≠ 0 := exists_ne 0
252+
have H₁ : IsCompact (sphere (0 : E) ‖x‖) := isCompact_sphere _ _
253+
have H₂ : (sphere (0 : E) ‖x‖).Nonempty := ⟨x, by simp⟩
254+
-- key point: in finite dimension, a continuous function on the sphere has a max
255+
obtain ⟨x₀, hx₀', hTx₀⟩ :=
256+
H₁.exists_forall_ge H₂ T'.val.reApplyInnerSelf_continuous.continuousOn
257+
have hx₀ : ‖x₀‖ = ‖x‖ := by simpa using hx₀'
258+
have : IsMaxOn T'.val.reApplyInnerSelf (sphere 0 ‖x₀‖) x₀ := by simpa only [← hx₀] using hTx₀
259+
have hx₀_ne : x₀ ≠ 0 := by
260+
have : ‖x₀‖ ≠ 0 := by simp only [hx₀, norm_eq_zero, hx, Ne.def, not_false_iff]
261+
simpa [← norm_eq_zero, Ne.def]
262+
exact hasEigenvalue_of_hasEigenvector (T'.prop.hasEigenvector_of_isMaxOn hx₀_ne this)
263+
#align linear_map.is_symmetric.has_eigenvalue_supr_of_finite_dimensional LinearMap.IsSymmetric.hasEigenvalue_iSup_of_finiteDimensional
264+
265+
/-- The infimum of the Rayleigh quotient of a symmetric operator `T` on a nontrivial
266+
finite-dimensional vector space is an eigenvalue for that operator. -/
267+
theorem hasEigenvalue_iInf_of_finiteDimensional (hT : T.IsSymmetric) :
268+
HasEigenvalue T ↑(⨅ x : { x : E // x ≠ 0 }, IsROrC.re ⟪T x, x⟫ / ‖(x : E)‖ ^ 2) := by
269+
haveI := FiniteDimensional.proper_isROrC 𝕜 E
270+
let T' := hT.toSelfAdjoint
271+
obtain ⟨x, hx⟩ : ∃ x : E, x ≠ 0 := exists_ne 0
272+
have H₁ : IsCompact (sphere (0 : E) ‖x‖) := isCompact_sphere _ _
273+
have H₂ : (sphere (0 : E) ‖x‖).Nonempty := ⟨x, by simp⟩
274+
-- key point: in finite dimension, a continuous function on the sphere has a min
275+
obtain ⟨x₀, hx₀', hTx₀⟩ :=
276+
H₁.exists_forall_le H₂ T'.val.reApplyInnerSelf_continuous.continuousOn
277+
have hx₀ : ‖x₀‖ = ‖x‖ := by simpa using hx₀'
278+
have : IsMinOn T'.val.reApplyInnerSelf (sphere 0 ‖x₀‖) x₀ := by simpa only [← hx₀] using hTx₀
279+
have hx₀_ne : x₀ ≠ 0 := by
280+
have : ‖x₀‖ ≠ 0 := by simp only [hx₀, norm_eq_zero, hx, Ne.def, not_false_iff]
281+
simpa [← norm_eq_zero, Ne.def]
282+
exact hasEigenvalue_of_hasEigenvector (T'.prop.hasEigenvector_of_isMinOn hx₀_ne this)
283+
#align linear_map.is_symmetric.has_eigenvalue_infi_of_finite_dimensional LinearMap.IsSymmetric.hasEigenvalue_iInf_of_finiteDimensional
284+
285+
theorem subsingleton_of_no_eigenvalue_finiteDimensional (hT : T.IsSymmetric)
286+
(hT' : ∀ μ : 𝕜, Module.End.eigenspace (T : E →ₗ[𝕜] E) μ = ⊥) : Subsingleton E :=
287+
(subsingleton_or_nontrivial E).resolve_right fun _h =>
288+
absurd (hT' _) hT.hasEigenvalue_iSup_of_finiteDimensional
289+
#align linear_map.is_symmetric.subsingleton_of_no_eigenvalue_finite_dimensional LinearMap.IsSymmetric.subsingleton_of_no_eigenvalue_finiteDimensional
290+
291+
end IsSymmetric
292+
293+
end LinearMap
294+
295+
end FiniteDimensional

0 commit comments

Comments
 (0)