Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
/- | |
Copyright (c) 2022 Alexander Bentkamp. All rights reserved. | |
Released under Apache 2.0 license as described in the file LICENSE. | |
Authors: Alexander Bentkamp | |
-/ | |
import analysis.inner_product_space.spectrum | |
import linear_algebra.matrix.hermitian | |
/-! # Spectral theory of hermitian matrices | |
This file proves the spectral theorem for matrices. The proof of the spectral theorem is based on | |
the spectral theorem for linear maps (`diagonalization_basis_apply_self_apply`). | |
## Tags | |
spectral theorem, diagonalization theorem | |
-/ | |
namespace matrix | |
variables {π : Type*} [is_R_or_C π] [decidable_eq π] {n : Type*} [fintype n] [decidable_eq n] | |
variables {A : matrix n n π} | |
open_locale matrix | |
namespace is_hermitian | |
variables (hA : A.is_hermitian) | |
/-- The eigenvalues of a hermitian matrix, indexed by `fin (fintype.card n)` where `n` is the index | |
type of the matrix. -/ | |
noncomputable def eigenvaluesβ : fin (fintype.card n) β β := | |
@inner_product_space.is_self_adjoint.eigenvalues π _ _ (pi_Lp 2 (Ξ» (_ : n), π)) _ A.to_lin' | |
(is_hermitian_iff_is_self_adjoint.1 hA) _ (fintype.card n) finrank_euclidean_space | |
/-- The eigenvalues of a hermitian matrix, reusing the index `n` of the matrix entries. -/ | |
noncomputable def eigenvalues : n β β := | |
Ξ» i, hA.eigenvaluesβ $ (fintype.equiv_of_card_eq (fintype.card_fin _)).symm i | |
/-- A choice of an orthonormal basis of eigenvectors of a hermitian matrix. -/ | |
noncomputable def eigenvector_basis : orthonormal_basis n π (euclidean_space π n) := | |
(@inner_product_space.is_self_adjoint.eigenvector_basis π _ _ | |
(pi_Lp 2 (Ξ» (_ : n), π)) _ A.to_lin' (is_hermitian_iff_is_self_adjoint.1 hA) _ | |
(fintype.card n) finrank_euclidean_space).reindex | |
(fintype.equiv_of_card_eq (fintype.card_fin _)) | |
/-- A matrix whose columns are an orthonormal basis of eigenvectors of a hermitian matrix. -/ | |
noncomputable def eigenvector_matrix : matrix n n π := | |
(pi.basis_fun π n).to_matrix (eigenvector_basis hA).to_basis | |
/-- The inverse of `eigenvector_matrix` -/ | |
noncomputable def eigenvector_matrix_inv : matrix n n π := | |
(eigenvector_basis hA).to_basis.to_matrix (pi.basis_fun π n) | |
lemma eigenvector_matrix_mul_inv : | |
hA.eigenvector_matrix β¬ hA.eigenvector_matrix_inv = 1 := | |
by apply basis.to_matrix_mul_to_matrix_flip | |
/-- *Diagonalization theorem*, *spectral theorem* for matrices; A hermitian matrix can be | |
diagonalized by a change of basis. | |
For the spectral theorem on linear maps, see `diagonalization_basis_apply_self_apply`. -/ | |
theorem spectral_theorem : | |
hA.eigenvector_matrix_inv β¬ A = | |
diagonal (coe β hA.eigenvalues) β¬ hA.eigenvector_matrix_inv := | |
begin | |
rw [eigenvector_matrix_inv, basis_to_matrix_basis_fun_mul], | |
ext i j, | |
convert @inner_product_space.is_self_adjoint.diagonalization_basis_apply_self_apply π _ _ | |
(pi_Lp 2 (Ξ» (_ : n), π)) _ A.to_lin' (is_hermitian_iff_is_self_adjoint.1 hA) _ (fintype.card n) | |
finrank_euclidean_space (euclidean_space.single j 1) | |
((fintype.equiv_of_card_eq (fintype.card_fin _)).symm i), | |
{ rw [eigenvector_basis, to_lin'_apply], | |
simp only [basis.to_matrix, basis.coe_to_orthonormal_basis_repr, basis.equiv_fun_apply], | |
simp_rw [orthonormal_basis.coe_to_basis_repr_apply, orthonormal_basis.reindex_repr, | |
euclidean_space.single, pi_Lp.equiv_symm_apply', mul_vec_single, mul_one], | |
refl }, | |
{ simp only [diagonal_mul, (β), eigenvalues, eigenvector_basis], | |
rw [basis.to_matrix_apply, | |
orthonormal_basis.coe_to_basis_repr_apply, orthonormal_basis.reindex_repr, | |
pi.basis_fun_apply, eigenvaluesβ, linear_map.coe_std_basis, | |
euclidean_space.single, pi_Lp.equiv_symm_apply'] } | |
end | |
end is_hermitian | |
end matrix | |