The areas / V07. Linear algebra
Mathlib.LinearAlgebra.Matrix.Charpoly.Basic
47 declarations and 1 deprecated aliases. Mathlib docs · Source
Characteristic polynomials and the Cayley-Hamilton theorem
We define characteristic polynomials of matrices and prove the Cayley–Hamilton theorem over arbitrary commutative rings.
See the file Mathlib/LinearAlgebra/Matrix/Charpoly/Coeff.lean for corollaries of this theorem.
Main definitions
Matrix.charpolyis the characteristic polynomial of a matrix.
Implementation notes
We follow a nice proof from http://drorbn.net/AcademicPensieve/2015-12/CayleyHamilton.pdf
theorem Matrix.charpoly.congr_simp E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} {inst_1 : DecidableEq n} [inst_2 : DecidableEq n]
[inst_3 : Fintype n] (M M_1 : Matrix n n R), M = M_1 → M.charpoly = M_1.charpoly
theorem Matrix.charmatrix.congr_simp E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} {inst_1 : DecidableEq n} [inst_2 : DecidableEq n]
[inst_3 : Fintype n] (M M_1 : Matrix n n R),
M = M_1 → ∀ (a a_1 : n), a = a_1 → ∀ (a_2 a_3 : n), a_2 = a_3 → M.charmatrix a a_2 = M_1.charmatrix a_1 a_3
def Matrix.charmatrix E1 #
{R : Type u_1} →
[inst : CommRing R] → {n : Type u_4} → [DecidableEq n] → [Fintype n] → Matrix n n R → Matrix n n (Polynomial R)
The "characteristic matrix" of M : Matrix n n R is the matrix of polynomials $t I - M$.
The determinant of this matrix is the characteristic polynomial.
theorem Matrix.charmatrix_apply E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
(i j : n), M.charmatrix i j = Matrix.diagonal (fun x ↦ Polynomial.X) i j - Polynomial.C (M i j)
theorem Matrix.charmatrix_apply_eq E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
(i : n), M.charmatrix i i = Polynomial.X - Polynomial.C (M i i)
theorem Matrix.charmatrix_apply_ne E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
(i j : n), i ≠ j → M.charmatrix i j = -Polynomial.C (M i j)
theorem Matrix.charmatrix_zero E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n],
Matrix.charmatrix 0 = (Matrix.scalar n) Polynomial.X
theorem Matrix.charmatrix_diagonal E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (d : n → R),
(Matrix.diagonal d).charmatrix = Matrix.diagonal fun i ↦ Polynomial.X - Polynomial.C (d i)
theorem Matrix.charmatrix_one E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n],
Matrix.charmatrix 1 = Matrix.diagonal fun x ↦ Polynomial.X - 1
theorem Matrix.charmatrix_natCast E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (k : ℕ),
(↑k).charmatrix = Matrix.diagonal fun x ↦ Polynomial.X - ↑k
theorem Matrix.charmatrix_ofNat E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (k : ℕ)
[inst_3 : k.AtLeastTwo], (OfNat.ofNat k).charmatrix = Matrix.diagonal fun x ↦ Polynomial.X - OfNat.ofNat k
theorem Matrix.charmatrix_transpose E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R),
M.transpose.charmatrix = M.charmatrix.transpose
theorem Matrix.matPolyEquiv_charmatrix E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R),
matPolyEquiv M.charmatrix = Polynomial.X - Polynomial.C M
theorem Matrix.charmatrix_reindex E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (M : Matrix n n R) (e : n ≃ m),
((Matrix.reindex e e) M).charmatrix = (Matrix.reindex e e) M.charmatrix
theorem Matrix.charmatrix_map E1 #
∀ {R : Type u_1} {S : Type u_2} [inst : CommRing R] [inst_1 : CommRing S] {n : Type u_4} [inst_2 : DecidableEq n]
[inst_3 : Fintype n] (M : Matrix n n R) (f : R →+* S), (M.map ⇑f).charmatrix = M.charmatrix.map (Polynomial.map f)
theorem Matrix.charmatrix_mul_map_C_of_mul_eq_mul E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] {A : Matrix n n R} {B : Matrix m m R} {P : Matrix n m R},
A * P = P * B → A.charmatrix * P.map ⇑Polynomial.C = P.map ⇑Polynomial.C * B.charmatrix
theorem Matrix.charmatrix_fromBlocks E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (M₁₁ : Matrix m m R) (M₁₂ : Matrix m n R) (M₂₁ : Matrix n m R)
(M₂₂ : Matrix n n R),
(Matrix.fromBlocks M₁₁ M₁₂ M₂₁ M₂₂).charmatrix =
Matrix.fromBlocks M₁₁.charmatrix (-M₁₂.map ⇑Polynomial.C) (-M₂₁.map ⇑Polynomial.C) M₂₂.charmatrix
theorem Matrix.charmatrix_blockTriangular_iff E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] {α : Type u_5}
[inst_3 : Preorder α] {M : Matrix n n R} {b : n → α}, M.charmatrix.BlockTriangular b ↔ M.BlockTriangular b
theorem Matrix.BlockTriangular.charmatrix E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] {α : Type u_5}
[inst_3 : Preorder α] {M : Matrix n n R} {b : n → α}, M.BlockTriangular b → M.charmatrix.BlockTriangular b
Alias of the reverse direction of Matrix.charmatrix_blockTriangular_iff.
theorem Matrix.BlockTriangular.of_charmatrix E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] {α : Type u_5}
[inst_3 : Preorder α] {M : Matrix n n R} {b : n → α}, M.charmatrix.BlockTriangular b → M.BlockTriangular b
Alias of the forward direction of Matrix.charmatrix_blockTriangular_iff.
def Matrix.charpoly E3 #
{R : Type u_1} → [inst : CommRing R] → {n : Type u_4} → [DecidableEq n] → [Fintype n] → Matrix n n R → Polynomial R
The characteristic polynomial of a matrix M is given by $\det (t I - M)$.
theorem Matrix.eval_charpoly E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} [inst_1 : DecidableEq m] [inst_2 : Fintype m] (M : Matrix m m R)
(t : R), Polynomial.eval t M.charpoly = ((Matrix.scalar m) t - M).det
theorem Matrix.charpoly_isEmpty E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] [IsEmpty n]
{A : Matrix n n R}, A.charpoly = 1
theorem Matrix.charpoly_zero E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n],
Matrix.charpoly 0 = Polynomial.X ^ Fintype.card n
theorem Matrix.charpoly_diagonal E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (d : n → R),
(Matrix.diagonal d).charpoly = ∏ i, (Polynomial.X - Polynomial.C (d i))
theorem Matrix.charpoly_one E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n],
Matrix.charpoly 1 = (Polynomial.X - 1) ^ Fintype.card n
theorem Matrix.charpoly_natCast E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (k : ℕ),
(↑k).charpoly = (Polynomial.X - ↑k) ^ Fintype.card n
theorem Matrix.charpoly_ofNat E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (k : ℕ)
[inst_3 : k.AtLeastTwo], (OfNat.ofNat k).charpoly = (Polynomial.X - OfNat.ofNat k) ^ Fintype.card n
theorem Matrix.charpoly_transpose E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R),
M.transpose.charpoly = M.charpoly
theorem Matrix.charpoly_reindex E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (e : n ≃ m) (M : Matrix n n R),
((Matrix.reindex e e) M).charpoly = M.charpoly
theorem Matrix.charpoly_map E1 #
∀ {R : Type u_1} {S : Type u_2} [inst : CommRing R] [inst_1 : CommRing S] {n : Type u_4} [inst_2 : DecidableEq n]
[inst_3 : Fintype n] (M : Matrix n n R) (f : R →+* S), (M.map ⇑f).charpoly = Polynomial.map f M.charpoly
theorem Matrix.charpoly_fromBlocks_zero₁₂ E0 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (M₁₁ : Matrix m m R) (M₂₁ : Matrix n m R) (M₂₂ : Matrix n n R),
(Matrix.fromBlocks M₁₁ 0 M₂₁ M₂₂).charpoly = M₁₁.charpoly * M₂₂.charpoly
theorem Matrix.charpoly_fromBlocks_zero₂₁ E0 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (M₁₁ : Matrix m m R) (M₁₂ : Matrix m n R) (M₂₂ : Matrix n n R),
(Matrix.fromBlocks M₁₁ M₁₂ 0 M₂₂).charpoly = M₁₁.charpoly * M₂₂.charpoly
theorem Matrix.charmatrix_toSquareBlock E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
{α : Type u_5} [inst_3 : DecidableEq α] {b : n → α} {a : α},
(M.toSquareBlock b a).charmatrix = M.charmatrix.toSquareBlock b a
theorem Matrix.BlockTriangular.charpoly E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
{α : Type u_5} {b : n → α} [inst_3 : LinearOrder α],
M.BlockTriangular b → M.charpoly = ∏ a ∈ Finset.image b Finset.univ, (M.toSquareBlock b a).charpoly
theorem Matrix.charpoly_of_isUpperTriangular E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n]
[inst_3 : LinearOrder n] (M : Matrix n n R),
M.IsUpperTriangular → M.charpoly = ∏ i, (Polynomial.X - Polynomial.C (M i i))
theorem Matrix.aeval_self_charpoly E3 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R),
(Polynomial.aeval M) M.charpoly = 0
The Cayley-Hamilton Theorem, that the characteristic polynomial of a matrix, applied to the matrix itself, is zero.
This holds over any commutative ring.
See LinearMap.aeval_self_charpoly for the equivalent statement about endomorphisms.
theorem Matrix.charpoly_mul_comm' E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (A : Matrix m n R) (B : Matrix n m R),
Polynomial.X ^ Fintype.card n * (A * B).charpoly = Polynomial.X ^ Fintype.card m * (B * A).charpoly
A version of Matrix.charpoly_mul_comm for rectangular matrices.
See also Matrix.charpoly_mul_comm_of_le which has just (A * B).charpoly as the LHS.
theorem Matrix.charpoly_mul_comm_of_le E1 #
∀ {R : Type u_1} [inst : CommRing R] {m : Type u_3} {n : Type u_4} [inst_1 : DecidableEq m] [inst_2 : DecidableEq n]
[inst_3 : Fintype m] [inst_4 : Fintype n] (A : Matrix m n R) (B : Matrix n m R),
Fintype.card n ≤ Fintype.card m →
(A * B).charpoly = Polynomial.X ^ (Fintype.card m - Fintype.card n) * (B * A).charpoly
theorem Matrix.charpoly_mul_comm E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (A B : Matrix n n R),
(A * B).charpoly = (B * A).charpoly
A version of charpoly_mul_comm' for square matrices.
theorem Matrix.charpoly_vecMulVec E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (u v : n → R),
(Matrix.vecMulVec u v).charpoly = Polynomial.X ^ Fintype.card n - (u ⬝ᵥ v) • Polynomial.X ^ (Fintype.card n - 1)
theorem Matrix.charpoly_units_conj E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : (Matrix n n R)ˣ)
(N : Matrix n n R), (↑M * N * (↑M)⁻¹).charpoly = N.charpoly
theorem Matrix.charpoly_units_conj' E0 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : (Matrix n n R)ˣ)
(N : Matrix n n R), ((↑M)⁻¹ * N * ↑M).charpoly = N.charpoly
theorem Matrix.C_det_mul_charpoly_of_mul_eq_mul E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n]
{A B P : Matrix n n R}, A * P = P * B → Polynomial.C P.det * A.charpoly = Polynomial.C P.det * B.charpoly
theorem Matrix.charpoly_eq_of_mul_eq_mul E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] [IsDomain R]
{A B P : Matrix n n R}, P.det ≠ 0 → A * P = P * B → A.charpoly = B.charpoly
theorem Matrix.charpoly_sub_scalar E1 #
∀ {R : Type u_1} [inst : CommRing R] {n : Type u_4} [inst_1 : DecidableEq n] [inst_2 : Fintype n] (M : Matrix n n R)
(μ : R), (M - (Matrix.scalar n) μ).charpoly = M.charpoly.comp (Polynomial.X + Polynomial.C μ)
theorem Algebra.aeval_charpoly_leftMulMatrix E1 #
∀ {R : Type u_1} {S : Type u_2} [inst : CommRing R] [inst_1 : Semiring S] [inst_2 : Algebra R S] {ι : Type u_3}
[inst_3 : Fintype ι] [inst_4 : DecidableEq ι] (b : Module.Basis ι R S) (a : S),
(Polynomial.aeval a) ((Algebra.leftMulMatrix b) a).charpoly = 0
Cayley–Hamilton: an algebra element is a root of the characteristic polynomial of its matrix of left multiplication in any basis.
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Matrix.charpoly_of_upperTriangular | Matrix.charpoly_of_isUpperTriangular | 2026-07-30 |