Mode of #cas
eigenvalues
The exact eigenvalues of a square matrix with rational entries, with their multiplicities and a theorem that there are no others.
#cas [eigenvalues] Aeigenvalues gives you the eigenvalues exactly. They come back as rational numbers, quadratic surds such as , complex numbers, or roots of a factor of higher degree, and a root of that last kind is named by an interval that contains it. I reach for this mode when the eigenvalues have to go into a proof, because the theorem doesn’t stop at saying that each number is an eigenvalue. It says the list is the whole spectrum. When every eigenvalue is rational, that theorem is a factorization of the characteristic polynomial over . Otherwise it is a statement about Mathlib’s spectrum over or , together with the roots of A.charpoly and their multiplicities.
Examples (12)#
Basic Examples (2)
Rational eigenvalues. The theorem factors the characteristic polynomial over :
#cas [eigenvalues] !![2, 0, 0; 0, 3, 4; 0, 4, 9]
eigenvalues with multiplicity
[1, 2, 11]- Domain
ℚ^(3×3)- Input (matrix)
!![2, 0, 0; 0, 3, 4; 0, 4, 9]
Checked by Lean’s kernel: Characteristic polynomial factored over ℚ
!![2, 0, 0; 0, 3, 4; 0, 4, 9].charpoly = (Polynomial.X - 1) * (Polynomial.X - 2) * (Polynomial.X - 11)
The certificate: 1 checked step
Characteristic polynomial factored over ℚ
!![2, 0, 0; 0, 3, 4; 0, 4, 9].charpoly = (Polynomial.X - 1) * (Polynomial.X - 2) * (Polynomial.X - 11)
The golden ratio and its conjugate. The theorem is about spectrum ℝ:
#cas [eigenvalues] !![0, 1; 1, 1]
eigenvalues with multiplicity
[1/2 - √5/2, 1/2 + √5/2]- Domain
ℚ^(2×2)- Input (matrix)
!![0, 1; 1, 1]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℝ !![0, 1; 1, 1] = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5} ∧ !![0, 1; 1, 1].charpoly.roots = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℝ !![0, 1; 1, 1] = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5} ∧ !![0, 1; 1, 1].charpoly.roots = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5}
Scope (5)
A rotation by a right angle has the eigenvalues , and the theorem is about spectrum ℂ:
#cas [eigenvalues] !![0, -1; 1, 0]
eigenvalues with multiplicity
[i, -i]- Domain
ℚ^(2×2)- Input (matrix)
!![0, -1; 1, 0]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℂ !![0, -1; 1, 0] = {Complex.I, -Complex.I} ∧ !![0, -1; 1, 0].charpoly.roots = {Complex.I, -Complex.I}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℂ !![0, -1; 1, 0] = {Complex.I, -Complex.I} ∧ !![0, -1; 1, 0].charpoly.roots = {Complex.I, -Complex.I}
Complex eigenvalues with a nonzero real part:
#cas [eigenvalues] !![1, 2; -2, 1]
eigenvalues with multiplicity
[1 + 2i, 1 - 2i]- Domain
ℚ^(2×2)- Input (matrix)
!![1, 2; -2, 1]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℂ !![1, 2; -2, 1] = {1 + 2 * Complex.I, 1 - 2 * Complex.I} ∧ !![1, 2; -2, 1].charpoly.roots = {1 + 2 * Complex.I, 1 - 2 * Complex.I}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℂ !![1, 2; -2, 1] = {1 + 2 * Complex.I, 1 - 2 * Complex.I} ∧ !![1, 2; -2, 1].charpoly.roots = {1 + 2 * Complex.I, 1 - 2 * Complex.I}
A real and two complex eigenvalues together:
#cas [eigenvalues] !![2, 0, 0; 0, 0, -1; 0, 1, 0]
eigenvalues with multiplicity
[2, i, -i]- Domain
ℚ^(3×3)- Input (matrix)
!![2, 0, 0; 0, 0, -1; 0, 1, 0]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℂ !![2, 0, 0; 0, 0, -1; 0, 1, 0] = {2, Complex.I, -Complex.I} ∧ !![2, 0, 0; 0, 0, -1; 0, 1, 0].charpoly.roots = {2, Complex.I, -Complex.I}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℂ !![2, 0, 0; 0, 0, -1; 0, 1, 0] = {2, Complex.I, -Complex.I} ∧ !![2, 0, 0; 0, 0, -1; 0, 1, 0].charpoly.roots = {2, Complex.I, -Complex.I}
Each eigenvalue appears as often as its multiplicity:
#cas [eigenvalues] !![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1]
eigenvalues with multiplicity
[1/2 - √5/2, 1/2 - √5/2, 1/2 + √5/2, 1/2 + √5/2]- Domain
ℚ^(4×4)- Input (matrix)
!![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℝ !![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1] = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5} ∧ !![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1].charpoly.roots = {1 / 2 - 1 / 2 * √5, 1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5, 1 / 2 + 1 / 2 * √5}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℝ !![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1] = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5} ∧ !![0, 1, 0, 0; 1, 1, 0, 0; 0, 0, 0, 1; 0, 0, 1, 1].charpoly.roots = {1 / 2 - 1 / 2 * √5, 1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5, 1 / 2 + 1 / 2 * √5}
The roots of are named by intervals: the real root and two complex roots :
#cas [eigenvalues] !![0, 0, 2; 1, 0, 0; 0, 1, 0]
eigenvalues with multiplicity
[r₁, z₁, conj z₁]; r₁ ∈ (1.25992104, 1.25992106), z₁, conj z₁ = α ± iβ, α ∈ [-0.62996054, -0.62996050], β ∈ [1.09112362, 1.09112366]- Domain
ℚ^(3×3)- Input (matrix)
!![0, 0, 2; 1, 0, 0; 0, 1, 0]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
let r₁ := CAS.AlgRoot.real [-2, 0, 0, 1] 1.25992104 1.25992106; let z₁ := CAS.AlgRoot.complex [-2, 0, 0, 1] (-0.62996052) 1.09112364 2e-8; (r₁ ∈ Set.Ioo 1.25992104 1.25992106 ∧ r₁ ^ 3 - 2 = 0) ∧ (z₁.re ∈ Set.Icc (-0.62996054) (-0.62996050) ∧ z₁.im ∈ Set.Icc 1.09112362 1.09112366 ∧ z₁ ^ 3 - 2 = 0) ∧ spectrum ℂ !![0, 0, 2; 1, 0, 0; 0, 1, 0] = {↑r₁, z₁, (starRingEnd ℂ) z₁} ∧ !![0, 0, 2; 1, 0, 0; 0, 1, 0].charpoly.roots = {↑r₁, z₁, (starRingEnd ℂ) z₁}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
let r₁ := CAS.AlgRoot.real [-2, 0, 0, 1] 1.25992104 1.25992106; let z₁ := CAS.AlgRoot.complex [-2, 0, 0, 1] (-0.62996052) 1.09112364 2e-8; (r₁ ∈ Set.Ioo 1.25992104 1.25992106 ∧ r₁ ^ 3 - 2 = 0) ∧ (z₁.re ∈ Set.Icc (-0.62996054) (-0.62996050) ∧ z₁.im ∈ Set.Icc 1.09112362 1.09112366 ∧ z₁ ^ 3 - 2 = 0) ∧ spectrum ℂ !![0, 0, 2; 1, 0, 0; 0, 1, 0] = {↑r₁, z₁, (starRingEnd ℂ) z₁} ∧ !![0, 0, 2; 1, 0, 0; 0, 1, 0].charpoly.roots = {↑r₁, z₁, (starRingEnd ℂ) z₁}
Applications (2)
A proof can take the first part of the printed theorem as a hypothesis and read an eigenvalue off it, here the golden ratio:
theorem golden_ratio_mem_spectrum (h : spectrum ℝ !![(0 : ℝ), 1; 1, 1] = {1 / 2 - 1 / 2 * √5, 1 / 2 + 1 / 2 * √5}) : 1 / 2 + 1 / 2 * √5 ∈ spectrum ℝ !![(0 : ℝ), 1; 1, 1] := by rw [h] exact Set.mem_insert_of_mem _ (Set.mem_singleton _)
Lean accepts the proof.
A transition matrix of a Markov chain has the eigenvalue 1. The other eigenvalue, , says how fast the chain forgets where it started:
#cas [eigenvalues] !![1/2, 1/2; 1/4, 3/4]
eigenvalues with multiplicity
[1/4, 1]- Domain
ℚ^(2×2)- Input (matrix)
!![1/2, 1/2; 1/4, 3/4]
Checked by Lean’s kernel: Characteristic polynomial factored over ℚ
!![1 / 2, 1 / 2; 1 / 4, 3 / 4].charpoly = (Polynomial.X - Polynomial.C (1 / 4)) * (Polynomial.X - 1)
The certificate: 1 checked step
Characteristic polynomial factored over ℚ
!![1 / 2, 1 / 2; 1 / 4, 3 / 4].charpoly = (Polynomial.X - Polynomial.C (1 / 4)) * (Polynomial.X - 1)
Properties and Relations (2)
The eigenvalues are the roots of the characteristic polynomial. Here their sum is the trace 5 and their product is the determinant :
#cas [eigenvalues] !![1, 2; 3, 4]
eigenvalues with multiplicity
[5/2 - √33/2, 5/2 + √33/2]- Domain
ℚ^(2×2)- Input (matrix)
!![1, 2; 3, 4]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℝ !![1, 2; 3, 4] = {5 / 2 - 1 / 2 * √33, 5 / 2 + 1 / 2 * √33} ∧ !![1, 2; 3, 4].charpoly.roots = {5 / 2 - 1 / 2 * √33, 5 / 2 + 1 / 2 * √33}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℝ !![1, 2; 3, 4] = {5 / 2 - 1 / 2 * √33, 5 / 2 + 1 / 2 * √33} ∧ !![1, 2; 3, 4].charpoly.roots = {5 / 2 - 1 / 2 * √33, 5 / 2 + 1 / 2 * √33}
#cas [characteristicPolynomial] !![1, 2; 3, 4]
det (x I - A)
x^2 - 5*x - 2- Domain
ℚ^(2×2)- Input (matrix)
!![1, 2; 3, 4]
Checked by Lean’s kernel: Characteristic polynomial in ℚ[X]
!![1, 2; 3, 4].charpoly = Polynomial.X ^ 2 - 5 * Polynomial.X - 2
The certificate: 1 checked step
Characteristic polynomial in ℚ[X]
!![1, 2; 3, 4].charpoly = Polynomial.X ^ 2 - 5 * Polynomial.X - 2
For a symmetric matrix, eigenvalueBounds bounds the smallest and the largest eigenvalue in decimals. Here they are :
#cas [eigenvalues] !![4, 1, 0; 1, 3, 1; 0, 1, 2]
eigenvalues with multiplicity
[3, 3 - √3, 3 + √3]- Domain
ℚ^(3×3)- Input (matrix)
!![4, 1, 0; 1, 3, 1; 0, 1, 2]
Checked by Lean’s kernel: The spectrum with algebraic multiplicities
spectrum ℝ !![4, 1, 0; 1, 3, 1; 0, 1, 2] = {3, 3 - √3, 3 + √3} ∧ !![4, 1, 0; 1, 3, 1; 0, 1, 2].charpoly.roots = {3, 3 - √3, 3 + √3}
The certificate: 1 checked step
The spectrum with algebraic multiplicities
spectrum ℝ !![4, 1, 0; 1, 3, 1; 0, 1, 2] = {3, 3 - √3, 3 + √3} ∧ !![4, 1, 0; 1, 3, 1; 0, 1, 2].charpoly.roots = {3, 3 - √3, 3 + √3}
#cas [eigenvalueBounds] !![4, 1, 0; 1, 3, 1; 0, 1, 2]
Rayleigh bounds
1.267949 ≤ λ_min, λ_max ≤ 4.732051- Domain
3 × 3 symmetric real matrix- Input (matrix)
!![4, 1, 0; 1, 3, 1; 0, 1, 2]
Checked by Lean’s kernel: Rayleigh bounds, sharp to 10^-6
(∀ (x : Fin 3 → ℝ), 1.267949 * ∑ i, x i ^ 2 ≤ ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j ∧ ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j ≤ 4.732051 * ∑ i, x i ^ 2) ∧ (∃ x, ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j < 1.267950 * ∑ i, x i ^ 2) ∧ ∃ x, 4.732050 * ∑ i, x i ^ 2 < ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j
The certificate: 1 checked step
Rayleigh bounds, sharp to 10^-6
(∀ (x : Fin 3 → ℝ), 1.267949 * ∑ i, x i ^ 2 ≤ ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j ∧ ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j ≤ 4.732051 * ∑ i, x i ^ 2) ∧ (∃ x, ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j < 1.267950 * ∑ i, x i ^ 2) ∧ ∃ x, 4.732050 * ∑ i, x i ^ 2 < ∑ i, ∑ j, !![4, 1, 0; 1, 3, 1; 0, 1, 2] i j * x i * x j
The computation
Certificate
A - cI = L D Lᵀ and μI - A = L' D' L'ᵀ over ℚ, with nonnegative pivots x, y over ℚ with xᵀAx < (c + 10^-6) |x|² and yᵀAy > (μ - 10^-6) |y|²
Possible Issues (1)
The matrix has to be square. matrixRank and nullSpace describe a matrix of any shape:
#cas [eigenvalues] !![1, 2, 3; 4, 5, 6]
Error
eigenvalues: the matrix must be square
See Also
characteristicPolynomial · eigenvectors · eigenvalueBounds · roots
