• Nakafa

    Nakafa

    Learn free and with quality.
Subject
    • Bachelor
Exercises
Holy
  • Quran
Articles
  • Politics
  • Community
  • About

Command Palette

Search for a command to run...

Linear Methods of AI

Cramer's Rule

Solving Linear Systems

Cramer's rule is a method for solving systems of linear equations using determinants. This method provides a direct way to calculate solutions of linear equation systems when the coefficient matrix is invertible.

This method is very useful for understanding the relationship between determinants and solutions of linear systems, although it is computationally less efficient compared to Gaussian elimination for large systems.

Complementary Matrix

Before discussing Cramer's rule, we need to understand the concept of complementary matrix which forms the basis of this method.

For matrix A∈Rn×nA \in \mathbb{R}^{n \times n}A∈Rn×n, the complementary matrix is defined as:

A~=(a~ij)i=1,…,nj=1,…,n∈Rn×n\tilde{A} = (\tilde{a}_{ij})_{i=1,\ldots,n \atop j=1,\ldots,n} \in \mathbb{R}^{n \times n}A~=(a~ij​)j=1,…,ni=1,…,n​​∈Rn×n

with elements:

a~ij=(−1)i+j⋅det⁡Aji\tilde{a}_{ij} = (-1)^{i+j} \cdot \det A_{ji}a~ij​=(−1)i+j⋅detAji​

Note that the indices in AjiA_{ji}Aji​ are swapped (not AijA_{ij}Aij​).

The complementary matrix A~\tilde{A}A~ is a matrix consisting of cofactors of matrix AAA, but with transposed positions.

Structure of Complementary Matrix

The complementary matrix has the following structure:

A~=(det⁡A11−det⁡A21det⁡A31⋯−det⁡A12det⁡A22−det⁡A32⋯det⁡A13−det⁡A23det⁡A33⋯⋮⋮⋮⋱)\tilde{A} = \begin{pmatrix} \det A_{11} & -\det A_{21} & \det A_{31} & \cdots \\ -\det A_{12} & \det A_{22} & -\det A_{32} & \cdots \\ \det A_{13} & -\det A_{23} & \det A_{33} & \cdots \\ \vdots & \vdots & \vdots & \ddots \end{pmatrix}A~=​detA11​−detA12​detA13​⋮​−detA21​detA22​−detA23​⋮​detA31​−detA32​detA33​⋮​⋯⋯⋯⋱​​

Each element is calculated by taking the determinant of the corresponding submatrix, then given a sign based on the checkerboard pattern (−1)i+j(-1)^{i+j}(−1)i+j.

Fundamental Properties of Complementary Matrix

One of the most important properties of the complementary matrix is its relationship with the original matrix:

A⋅A~=A~⋅A=(det⁡A0⋯00det⁡A⋯0⋮⋮⋱⋮00⋯det⁡A)A \cdot \tilde{A} = \tilde{A} \cdot A = \begin{pmatrix} \det A & 0 & \cdots & 0 \\ 0 & \det A & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & \det A \end{pmatrix}A⋅A~=A~⋅A=​detA0⋮0​0detA⋮0​⋯⋯⋱⋯​00⋮detA​​

In other words:

A⋅A~=(det⁡A)⋅IA \cdot \tilde{A} = (\det A) \cdot IA⋅A~=(detA)⋅I

This property is very important because it provides a direct relationship between the matrix, its complementary matrix, and its determinant.

Matrix Inverse Formula

From the fundamental property above, we can derive the matrix inverse formula using the complementary matrix.

If matrix A∈Rn×nA \in \mathbb{R}^{n \times n}A∈Rn×n is invertible, then:

A−1=1det⁡A⋅A~A^{-1} = \frac{1}{\det A} \cdot \tilde{A}A−1=detA1​⋅A~

However, calculating matrix inverse using this formula is much less efficient compared to Gaussian elimination for large matrices.

Example for 2×2 Matrix

For matrix n=2n = 2n=2:

A=(abcd)A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}A=(ac​bd​)

Its determinant is:

det⁡A=a⋅d−b⋅c\det A = a \cdot d - b \cdot cdetA=a⋅d−b⋅c

Its complementary matrix is:

A~=(d−b−ca)\tilde{A} = \begin{pmatrix} d & -b \\ -c & a \end{pmatrix}A~=(d−c​−ba​)

So its inverse is:

A−1=1a⋅d−b⋅c⋅(d−b−ca)A^{-1} = \frac{1}{a \cdot d - b \cdot c} \cdot \begin{pmatrix} d & -b \\ -c & a \end{pmatrix}A−1=a⋅d−b⋅c1​⋅(d−c​−ba​)

We can verify that:

A⋅A−1=1a⋅d−b⋅c(a⋅d−b⋅c−a⋅b+a⋅bc⋅d−c⋅d−c⋅b+a⋅d)A \cdot A^{-1} = \frac{1}{a \cdot d - b \cdot c} \begin{pmatrix} a \cdot d - b \cdot c & -a \cdot b + a \cdot b \\ c \cdot d - c \cdot d & -c \cdot b + a \cdot d \end{pmatrix}A⋅A−1=a⋅d−b⋅c1​(a⋅d−b⋅cc⋅d−c⋅d​−a⋅b+a⋅b−c⋅b+a⋅d​)
=(1001)=I= \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} = I=(10​01​)=I

Theorem Statement

Now we can formulate Cramer's rule for solving systems of linear equations.

Let A∈Rn×nA \in \mathbb{R}^{n \times n}A∈Rn×n be an invertible matrix and a1,a2,…,an∈Rna^1, a^2, \ldots, a^n \in \mathbb{R}^na1,a2,…,an∈Rn be the columns of AAA. For vector b∈Rnb \in \mathbb{R}^nb∈Rn, the solution x∈Rnx \in \mathbb{R}^nx∈Rn of the linear equation system A⋅x=bA \cdot x = bA⋅x=b is given by:

xj=det⁡(a1  …  aj−1  b  aj+1  …  an)det⁡Ax_j = \frac{\det(a^1 \; \ldots \; a^{j-1} \; b \; a^{j+1} \; \ldots \; a^n)}{\det A}xj​=detAdet(a1…aj−1baj+1…an)​

for j=1,2,…,nj = 1, 2, \ldots, nj=1,2,…,n.

To calculate the jjj-th component of solution xxx, we replace the jjj-th column of matrix AAA with vector bbb, then calculate the determinant of this modified matrix and divide it by the determinant of the original matrix AAA.

Proof Using Laplace Expansion

The proof of Cramer's rule uses Laplace expansion and properties of the complementary matrix.

For j=1,…,nj = 1, \ldots, nj=1,…,n:

xj=(A−1⋅b)j=∑i=1n(A−1)ji⋅bi=∑i=1n1det⁡A⋅a~ji⋅bix_j = (A^{-1} \cdot b)_j = \sum_{i=1}^{n} (A^{-1})_{ji} \cdot b_i = \sum_{i=1}^{n} \frac{1}{\det A} \cdot \tilde{a}_{ji} \cdot b_ixj​=(A−1⋅b)j​=i=1∑n​(A−1)ji​⋅bi​=i=1∑n​detA1​⋅a~ji​⋅bi​
=1det⁡A∑i=1n(−1)i+j⋅det⁡Aij⋅bi= \frac{1}{\det A} \sum_{i=1}^{n} (-1)^{i+j} \cdot \det A_{ij} \cdot b_i=detA1​i=1∑n​(−1)i+j⋅detAij​⋅bi​
=1det⁡A⋅det⁡(a1  …  aj−1  b  aj+1  …  an)= \frac{1}{\det A} \cdot \det(a^1 \; \ldots \; a^{j-1} \; b \; a^{j+1} \; \ldots \; a^n)=detA1​⋅det(a1…aj−1baj+1…an)

based on Laplace expansion with respect to the jjj-th column.

Application Example

Let's look at a concrete example of applying Cramer's rule:

A=(11−11−11−111),b=(204030)A = \begin{pmatrix} 1 & 1 & -1 \\ 1 & -1 & 1 \\ -1 & 1 & 1 \end{pmatrix}, \quad b = \begin{pmatrix} 20 \\ 40 \\ 30 \end{pmatrix}A=​11−1​1−11​−111​​,b=​204030​​

Since:

det⁡A=1⋅((−1)⋅1−1⋅1)−1⋅(1⋅1−(−1)⋅1)\det A = 1 \cdot ((-1) \cdot 1 - 1 \cdot 1) - 1 \cdot (1 \cdot 1 - (-1) \cdot 1)detA=1⋅((−1)⋅1−1⋅1)−1⋅(1⋅1−(−1)⋅1)
+(−1)⋅(1⋅1−(−1)⋅(−1))=−4≠0+ (-1) \cdot (1 \cdot 1 - (-1) \cdot (-1)) = -4 \neq 0+(−1)⋅(1⋅1−(−1)⋅(−1))=−4=0

matrix AAA is invertible and the system has a unique solution.

According to Cramer's rule:

x1=1det⁡A⋅det⁡(201−140−113011)=−120−4=30x_1 = \frac{1}{\det A} \cdot \det \begin{pmatrix} 20 & 1 & -1 \\ 40 & -1 & 1 \\ 30 & 1 & 1 \end{pmatrix} = \frac{-120}{-4} = 30x1​=detA1​⋅det​204030​1−11​−111​​=−4−120​=30
x2=1det⁡A⋅det⁡(120−11401−1301)=−100−4=25x_2 = \frac{1}{\det A} \cdot \det \begin{pmatrix} 1 & 20 & -1 \\ 1 & 40 & 1 \\ -1 & 30 & 1 \end{pmatrix} = \frac{-100}{-4} = 25x2​=detA1​⋅det​11−1​204030​−111​​=−4−100​=25
x3=1det⁡A⋅det⁡(11201−140−1130)=−140−4=35x_3 = \frac{1}{\det A} \cdot \det \begin{pmatrix} 1 & 1 & 20 \\ 1 & -1 & 40 \\ -1 & 1 & 30 \end{pmatrix} = \frac{-140}{-4} = 35x3​=detA1​⋅det​11−1​1−11​204030​​=−4−140​=35

Verification shows that A⋅x−b=0A \cdot x - b = 0A⋅x−b=0.

Solution Properties for Integer Matrices

If A∈Zn×nA \in \mathbb{Z}^{n \times n}A∈Zn×n is an invertible matrix with integer elements and b∈Znb \in \mathbb{Z}^nb∈Zn is a vector with integer elements, then the elements of the inverse A−1A^{-1}A−1 and solution xxx of the system A⋅x=bA \cdot x = bA⋅x=b are rational numbers with denominator that (if not reduced) equals ∣det⁡A∣|\det A|∣detA∣.

This occurs because determinant calculation only involves addition, subtraction, and multiplication operations, so the determinant of an integer matrix is always an integer. In the inverse formula and Cramer's rule, the only division operation is division by det⁡A\det AdetA.

Previous

Laplace Expansion Theorem

Next

Complex Vector Space

  • Cramer's RuleSolve linear systems using determinants with Cramer's rule. Learn complementary matrices, inverse formulas, and step-by-step examples for AI applications.
On this page
  • Solving Linear Systems
  • Complementary Matrix
    • Structure of Complementary Matrix
  • Fundamental Properties of Complementary Matrix
  • Matrix Inverse Formula
    • Example for 2×2 Matrix
  • Theorem Statement
  • Proof Using Laplace Expansion
  • Application Example
  • Solution Properties for Integer Matrices
  • Comments
  • Report
  • Source code