# Cramer’s Rule

Source: algebrica.org - CC BY-NC 4.0
https://algebrica.org/cramers-rule/
Fetched from algebrica.org post 12277; source modified 2026-03-20T22:31:14.

## What is Cramer’s rule?

Cramer’s Rule provides a method for solving [systems](../systems-of-linear-equations.md) of \\( n \\) [linear equations](../linear-equations.md) in \\( n \\) unknowns, by using the determinant of the system’s coefficient [matrix](../matrices.md). This rule applies only when the coefficient matrix is square and its determinant is non-zero, ensuring that the system has a unique solution.

## Applying Cramer’s Rule

Let us consider a general system of \\( n \\) equations in \\( n \\) unknowns:

\\[
\\begin{cases} a\_{11}x\_1 + a\_{12}x\_2 + \\dots + a\_{1n}x\_n = b\_1 \\[0.5em] a\_{21}x\_1 + a\_{22}x\_2 + \\dots + a\_{2n}x\_n = b\_2 \\[0.5em] \\quad\\vdots \\[0.5em] a\_{n1}x\_1 + a\_{n2}x\_2 + \\dots + a\_{nn}x\_n = b\_n \\end{cases}
\\]

We can rewrite the system using matrix notation as \\( A \\cdot \\mathbf{X} = \\mathbf{B} \\). The system becomes:

\\[
A = \\begin{bmatrix} a\_{11} & a\_{12} & \\cdots & a\_{1n} \\\\ a\_{21} & a\_{22} & \\cdots & a\_{2n} \\\\ \\vdots & \\vdots & \\ddots & \\vdots \\\\ a\_{m1} & a\_{n2} & \\cdots & a\_{nn} \\end{bmatrix}
\\]

The constant terms and variables can be organized into two column [vectors](../vectors.md):

\\[
X = \\begin{bmatrix} x\_1 \\\\ x\_2 \\\\ \\vdots \\\\ x\_n \\end{bmatrix} \\quad\\quad B = \\begin{bmatrix} b\_1 \\\\ b\_2 \\\\ \\vdots \\\\ b\_m \\end{bmatrix}
\\]

* * *

Suppose that the coefficient matrix \\( A \\) is invertible, which means that its determinant is non-zero (\\(\\det(A) \\ne 0\\)). Under this condition, the system has a unique solution, and it can be expressed using the inverse of \\( A \\) as:

\\[
\\begin{bmatrix} x\_1 \\\\ x\_2 \\\\ \\vdots \\\\ x\_n \\end{bmatrix} = \\frac{1}{\\det(A)} \\begin{bmatrix} A\_{11} & A\_{21} & \\cdots & A\_{n1} \\\\ A\_{12} & A\_{22} & \\cdots & A\_{n2} \\\\ \\vdots & \\vdots & \\ddots & \\vdots \\\\ A\_{1n} & A\_{2n} & \\cdots & A\_{nn} \\\\ \\end{bmatrix} \\begin{bmatrix} b\_1 \\\\ b\_2 \\\\ \\vdots \\\\ b\_n \\end{bmatrix}
\\]

This is the general form of Cramer’s Rule, where each \\( A\_{ij} \\) is the cofactor of the element \\( a\_{ji} \\) in the original matrix \\( A \\).

##### In this context, \\( A\_{ij} \\) refers to the cofactor of the element \\( a\_{ji} \\) from the original matrix \\( A \\), not to the entry of the matrix itself. The matrix used here is the adjugate of \\( A \\), denoted as \\( \\text{adj}(A) \\).

* * *

The value of the unknown in position \\( k \\) is given by a fraction. Its denominator is \\( \\det(A) \\) and its numerator is the determinant of the matrix obtained by replacing the \\( k \\)-th column of \\( A \\) with the column of constants:

\\[
x\_k = \\frac{\\det(A\_k)}{\\det(A)}
\\]

##### For a clearer understanding of this step, see the detailed explanation in Example 2.

## Solutions of homogeneous systems

A [homogeneous system](../systems-of-linear-equations.md) is a system of linear equations where all the constant terms are zero. These systems always have at least one solution: the trivial solution, where all the variables are zero. But something interesting happens when we look at the determinant of the coefficient matrix:

-   If \\( \\det(A) \\ne 0 \\), the system has only the trivial solution.
-   If \\( \\det(A) = 0 \\), the system admits infinitely many solutions, including non-trivial ones, where at least one variable is not zero.

##### Homogeneous systems never have no solution. They’re always consistent, but the number of solutions depends entirely on the determinant.

## Example 1

Let’s consider the following homogeneous system of three equations in three unknowns:

\\[
\\begin{cases} x + y + z = 0 \\[0.5em] 2x - y + z = 0 \\[0.5em] 3x + y + 2z = 0 \\end{cases}
\\]

* * *

This system can be written in matrix form as \\( A \\cdot \\mathbf{x} = \\mathbf{0} \\), where the coefficient matrix is:

\\[
A = \\begin{bmatrix} 1 & 1 & 1 \\[0.5em] 2 & -1 & 1 \\[0.5em] 3 & 1 & 2 \\end{bmatrix}
\\]

* * *

To understand the nature of the solutions, we compute the determinant of the matrix \\( A \\):

\\[
\\begin{align\*} \\det(A) &= 1 \\cdot (-1 \\cdot 2 - 1 \\cdot 1) -1 \\cdot (2 \\cdot 2 - 1 \\cdot 3) +1 \\cdot (2 \\cdot 1 - (-1) \\cdot 3) \\[0.5em] &= 1(-2 - 1) - 1(4 - 3) + 1(2 + 3) \\[0.5em] &= -3 - 1 + 5 \\[0.5em] & = 1 \\end{align\*}
\\]

Since the determinant is non-zero, the system admits only the trivial solution:

\\[
x = 0 \\quad y = 0 \\quad z = 0
\\]

##### This outcome aligns with Cramer’s Rule: when \\( \\det(A) \\ne 0 \\), the only possible solution to a homogeneous system is the trivial one, since all the determinants in the numerators of Cramer’s formula become zero.

## Example 2

Let’s solve the following system of two linear equations in two unknowns:

\\[
\\begin{cases} 2x + 3y = 8 \\[0.5em] 4x - y = 2 \\end{cases}
\\]

* * *

We identify the coefficient matrix \\( A \\), the vector of unknowns \\( \\mathbf{x} \\), and the constants vector \\( \\mathbf{b} \\):

\\[
A = \\begin{bmatrix} 2 & 3 \\\\ 4 & -1 \\end{bmatrix} \\quad\\quad \\mathbf{x} = \\begin{bmatrix} x \\\\ y \\end{bmatrix} \\quad\\quad \\mathbf{b} = \\begin{bmatrix} 8 \\\\ 2 \\end{bmatrix}
\\]

* * *

We compute the determinant of the coefficient matrix \\( A \\):

\\[
\\det(A) = 2 \\cdot (-1) - 3 \\cdot 4 = -2 - 12 = -14
\\]

Since the determinant is non-zero, the system has exactly one solution, and we can apply Cramer’s rule.

* * *

We build the matrix \\( A\_1 \\) by replacing the first column of \\( A \\) with the constants:

\\[
A\_1 = \\begin{bmatrix} 8 & 3 \\\\ 2 & -1 \\end{bmatrix} \\quad \\rightarrow \\quad \\det(A\_1) = 8 \\cdot (-1) - 3 \\cdot 2 = -8 - 6 = -14
\\]

* * *

We now build \\( A\_2 \\) by replacing the second column of \\( A \\) with the constants:

\\[
A\_2 = \\begin{bmatrix} 2 & 8 \\\\ 4 & 2 \\end{bmatrix} \\quad \\rightarrow \\quad \\det(A\_2) = 2 \\cdot 2 - 8 \\cdot 4 = 4 - 32 = -28
\\]

* * *

Now we compute the values of the unknowns using the formula:

\\begin{align\*} x &= \\frac{\\det(A\_1)}{\\det(A)} = \\frac{-14}{-14} = 1 \\[0.5em] y &= \\frac{\\det(A\_2)}{\\det(A)} = \\frac{-28}{-14} = 2 \\end{align\*}

The solution to the system is:

\\[
x = 1 \\quad\\quad y = 2
\\]

##### Remember that the solution to a system of linear equations refers to the \\(n\\)-tuple of values that satisfies all equations in the system simultaneously. In this case, the pair \\( (x, y) = (1, 2) \\) is the only combination of values that makes both equations true at the same time.
