/- Copyright (c) 2022 Alexander Bentkamp. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Alexander Bentkamp -/ import linear_algebra.matrix.spectrum import linear_algebra.quadratic_form.basic /-! # Positive Definite Matrices This file defines positive definite matrices and connects this notion to positive definiteness of quadratic forms. ## Main definition * `matrix.pos_def` : a matrix `M : matrix n n R` is positive definite if it is hermitian and `xα΄΄Mx` is greater than zero for all nonzero `x`. -/ namespace matrix variables {π•œ : Type*} [is_R_or_C π•œ] {n : Type*} [fintype n] open_locale matrix /-- A matrix `M : matrix n n R` is positive definite if it is hermitian and `xα΄΄Mx` is greater than zero for all nonzero `x`. -/ def pos_def (M : matrix n n π•œ) := M.is_hermitian ∧ βˆ€ x : n β†’ π•œ, x β‰  0 β†’ 0 < is_R_or_C.re (dot_product (star x) (M.mul_vec x)) lemma pos_def.is_hermitian {M : matrix n n π•œ} (hM : M.pos_def) : M.is_hermitian := hM.1 lemma pos_def_of_to_quadratic_form' [decidable_eq n] {M : matrix n n ℝ} (hM : M.is_symm) (hMq : M.to_quadratic_form'.pos_def) : M.pos_def := begin refine ⟨hM, Ξ» x hx, _⟩, simp only [to_quadratic_form', quadratic_form.pos_def, bilin_form.to_quadratic_form_apply, matrix.to_bilin'_apply'] at hMq, apply hMq x hx, end lemma pos_def_to_quadratic_form' [decidable_eq n] {M : matrix n n ℝ} (hM : M.pos_def) : M.to_quadratic_form'.pos_def := begin intros x hx, simp only [to_quadratic_form', bilin_form.to_quadratic_form_apply, matrix.to_bilin'_apply'], apply hM.2 x hx, end end matrix namespace quadratic_form variables {n : Type*} [fintype n] lemma pos_def_of_to_matrix' [decidable_eq n] {Q : quadratic_form ℝ (n β†’ ℝ)} (hQ : Q.to_matrix'.pos_def) : Q.pos_def := begin rw [←to_quadratic_form_associated ℝ Q, ←bilin_form.to_matrix'.left_inv ((associated_hom _) Q)], apply matrix.pos_def_to_quadratic_form' hQ end lemma pos_def_to_matrix' [decidable_eq n] {Q : quadratic_form ℝ (n β†’ ℝ)} (hQ : Q.pos_def) : Q.to_matrix'.pos_def := begin rw [←to_quadratic_form_associated ℝ Q, ←bilin_form.to_matrix'.left_inv ((associated_hom _) Q)] at hQ, apply matrix.pos_def_of_to_quadratic_form' (is_symm_to_matrix' Q) hQ, end end quadratic_form namespace matrix variables {π•œ : Type*} [is_R_or_C π•œ] {n : Type*} [fintype n] /-- A positive definite matrix `M` induces an inner product `βŸͺx, y⟫ = xα΄΄My`. -/ noncomputable def inner_product_space.of_matrix {M : matrix n n π•œ} (hM : M.pos_def) : inner_product_space π•œ (n β†’ π•œ) := inner_product_space.of_core { inner := Ξ» x y, dot_product (star x) (M.mul_vec y), conj_sym := Ξ» x y, by rw [star_dot_product, star_ring_end_apply, star_star, star_mul_vec, dot_product_mul_vec, hM.is_hermitian.eq], nonneg_re := Ξ» x, begin by_cases h : x = 0, { simp [h] }, { exact le_of_lt (hM.2 x h) } end, definite := Ξ» x hx, begin by_contra' h, simpa [hx, lt_self_iff_false] using hM.2 x h, end, add_left := by simp only [star_add, add_dot_product, eq_self_iff_true, forall_const], smul_left := Ξ» x y r, by rw [← smul_eq_mul, ←smul_dot_product, star_ring_end_apply, ← star_smul] } end matrix