mathlib documentation

linear_algebra.matrix.adjugate

Cramer's rule and adjugate matrices #

The adjugate matrix is the transpose of the cofactor matrix. It is calculated with Cramer's rule, which we introduce first. The vectors returned by Cramer's rule are given by the linear map cramer, which sends a matrix A and vector b to the vector consisting of the determinant of replacing the ith column of A with b at index i (written as (A.update_column i b).det). Using Cramer's rule, we can compute for each matrix A the matrix adjugate A. The entries of the adjugate are the determinants of each minor of A. Instead of defining a minor to be A with row i and column j deleted, we replace the ith row of A with the jth basis vector; this has the same determinant as the minor but more importantly equals Cramer's rule applied to A and the jth basis vector, simplifying the subsequent proofs. We prove the adjugate behaves like det A • A⁻¹.

Main definitions #

References #

Tags #

cramer, cramer's rule, adjugate

cramer section #

Introduce the linear map cramer with values defined by cramer_map. After defining cramer_map and showing it is linear, we will restrict our proofs to using cramer.

def matrix.cramer_map {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) (i : n) :
α

cramer_map A b i is the determinant of the matrix A with column i replaced with b, and thus cramer_map A b is the vector output by Cramer's rule on A and b.

If A ⬝ x = b has a unique solution in x, cramer_map A sends the vector b to A.det • x. Otherwise, the outcome of cramer_map is well-defined but not necessarily useful.

Equations
theorem matrix.cramer_map_is_linear {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (i : n) :
is_linear_map α (λ (b : n → α), A.cramer_map b i)
theorem matrix.cramer_is_linear {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
def matrix.cramer {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
(n → α) →ₗ[α] n → α

cramer A b i is the determinant of the matrix A with column i replaced with b, and thus cramer A b is the vector output by Cramer's rule on A and b.

If A ⬝ x = b has a unique solution in x, cramer A sends the vector b to A.det • x. Otherwise, the outcome of cramer is well-defined but not necessarily useful.

Equations
theorem matrix.cramer_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) (i : n) :
(A.cramer) b i = (A.update_column i b).det
theorem matrix.cramer_transpose_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) (i : n) :
(A.cramer) b i = (A.update_row i b).det
theorem matrix.cramer_transpose_row_self {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (i : n) :
(A.cramer) (A i) = pi.single i A.det
theorem matrix.cramer_row_self {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) (i : n) (h : ∀ (j : n), b j = A j i) :
@[simp]
theorem matrix.cramer_one {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] :
1.cramer = 1
theorem matrix.cramer_smul {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (r : α) (A : matrix n n α) :
(r A).cramer = r ^ (fintype.card n - 1) A.cramer
@[simp]
theorem matrix.cramer_subsingleton_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] [subsingleton n] (A : matrix n n α) (b : n → α) (i : n) :
(A.cramer) b i = b i
theorem matrix.cramer_zero {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] [nontrivial n] :
0.cramer = 0
theorem matrix.sum_cramer {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) {β : Type u_1} (s : finset β) (f : β → n → α) :
∑ (x : β) in s, (A.cramer) (f x) = (A.cramer) (∑ (x : β) in s, f x)

Use linearity of cramer to take it out of a summation.

theorem matrix.sum_cramer_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) {β : Type u_1} (s : finset β) (f : n → β → α) (i : n) :
∑ (x : β) in s, (A.cramer) (λ (j : n), f j x) i = (A.cramer) (λ (j : n), ∑ (x : β) in s, f j x) i

Use linearity of cramer and vector evaluation to take cramer A _ i out of a summation.

adjugate section #

Define the adjugate matrix and a few equations. These will hold for any matrix over a commutative ring.

def matrix.adjugate {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
matrix n n α

The adjugate matrix is the transpose of the cofactor matrix.

Typically, the cofactor matrix is defined by taking the determinant of minors, i.e. the matrix with a row and column removed. However, the proof of mul_adjugate becomes a lot easier if we define the minor as replacing a column with a basis vector, since it allows us to use facts about the cramer map.

Equations
theorem matrix.adjugate_def {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
A.adjugate = λ (i : n), (A.cramer) (pi.single i 1)
theorem matrix.adjugate_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (i j : n) :
A.adjugate i j = (A.update_row j (pi.single i 1)).det
theorem matrix.adjugate_transpose {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
theorem matrix.cramer_eq_adjugate_mul_vec {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) :

Since the map b ↦ cramer A b is linear in b, it must be multiplication by some matrix. This matrix is A.adjugate.

theorem matrix.mul_adjugate_apply {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (i j k : n) :
(A i k) * A.adjugate k j = (A.cramer) (pi.single k (A i k)) j
theorem matrix.mul_adjugate {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
A A.adjugate = A.det 1
theorem matrix.adjugate_mul {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
A.adjugate A = A.det 1
theorem matrix.adjugate_smul {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (r : α) (A : matrix n n α) :
@[simp]
theorem matrix.mul_vec_cramer {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (b : n → α) :
A.mul_vec ((A.cramer) b) = A.det b

A stronger form of Cramer's rule that allows us to solve some instances of A ⬝ x = b even if the determinant is not a unit. A sufficient (but still not necessary) condition is that A.det divides b.

theorem matrix.adjugate_subsingleton {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] [subsingleton n] (A : matrix n n α) :
theorem matrix.adjugate_eq_one_of_card_eq_one {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] {A : matrix n n α} (h : fintype.card n = 1) :
@[simp]
theorem matrix.adjugate_zero {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] [nontrivial n] :
@[simp]
theorem matrix.adjugate_one {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] :
theorem ring_hom.map_adjugate {n : Type u} [decidable_eq n] [fintype n] {R : Type u_1} {S : Type u_2} [comm_ring R] [comm_ring S] (f : R →+* S) (M : matrix n n R) :
theorem alg_hom.map_adjugate {n : Type u} [decidable_eq n] [fintype n] {R : Type u_1} {A : Type u_2} {B : Type u_3} [comm_semiring R] [comm_ring A] [comm_ring B] [algebra R A] [algebra R B] (f : A →ₐ[R] B) (M : matrix n n A) :
theorem matrix.det_adjugate {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
@[simp]
theorem matrix.adjugate_fin_zero {α : Type v} [comm_ring α] (A : matrix (fin 0) (fin 0) α) :
@[simp]
theorem matrix.adjugate_fin_one {α : Type v} [comm_ring α] (A : matrix (fin 1) (fin 1) α) :
theorem matrix.adjugate_fin_two {α : Type v} [comm_ring α] (A : matrix (fin 2) (fin 2) α) :
A.adjugate = ![![A 1 1, -A 0 1], ![-A 1 0, A 0 0]]
@[simp]
theorem matrix.adjugate_fin_two' {α : Type v} [comm_ring α] (a b c d : α) :
matrix.adjugate ![![a, b], ![c, d]] = ![![d, -b], ![-c, a]]
theorem matrix.adjugate_conj_transpose {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] [star_ring α] (A : matrix n n α) :
theorem matrix.is_regular_of_is_left_regular_det {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] {A : matrix n n α} (hA : is_left_regular A.det) :
theorem matrix.adjugate_mul_distrib_aux {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A B : matrix n n α) (hA : is_left_regular A.det) (hB : is_left_regular B.det) :
theorem matrix.adjugate_mul_distrib {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A B : matrix n n α) :

Proof follows from "The trace Cayley-Hamilton theorem" by Darij Grinberg, Section 5.3

@[simp]
theorem matrix.adjugate_pow {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (k : ) :
(A ^ k).adjugate = A.adjugate ^ k
theorem matrix.det_smul_adjugate_adjugate {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) :
theorem matrix.adjugate_adjugate {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) (h : fintype.card n 1) :

Note that this is not true for fintype.card n = 1 since 1 - 2 = 0 and not -1.

theorem matrix.adjugate_adjugate' {n : Type u} [decidable_eq n] [fintype n] {α : Type v} [comm_ring α] (A : matrix n n α) [nontrivial n] :

A weaker version of matrix.adjugate_adjugate that uses nontrivial.