Cramer's Rule

Cramer's rule offers a straightforward procedure for solving a nonhomogeneous linear system when the number of equations equals the number of unknowns.

Each variable is obtained from the ratio $$ \frac{ \Delta_x }{ \Delta } $$ where Δ is the determinant of the coefficient matrix and Δx is the determinant of the matrix obtained by replacing the column of x with the right-hand side vector.

If the determinant is nonzero, Δ≠0, the system has a unique solution (system with a unique solution).

$$ \Delta \ne 0 \ \ \ \ \Rightarrow \ has \ a \ unique \ solution $$

If the determinant of the coefficient matrix is zero, Δ=0, the system has no solutions.

$$ \Delta = 0 \ \ \ \ \Rightarrow \ has \ no \ solutions $$

In this case the system is either inconsistent (no solutions) or it admits infinitely many solutions (infinitely many solutions).

Note. Cramer's rule applies only to square systems. When the number of equations and unknowns differs, the existence of solutions can be assessed by examining the ranks and minors of the coefficient matrix (analysis based on matrix minors).

How the method works

  1. Compute the determinant Δ of the coefficient matrix A. $$ \Delta = det(A) $$ If Δ is zero, the system has no solutions. Otherwise, proceed to the next step.
  2. Construct the matrix Ax by replacing the column of x with the right-hand side vector b, then compute its determinant: $$ \Delta_x = det(A_x) $$
  3. The value of x is given by $$ \frac{ \Delta_x }{ \Delta } $$ which is the ratio of the determinant of the modified matrix to the determinant of the coefficient matrix.
  4. Repeat the process for each remaining variable: $$ \frac{ \Delta_y }{ \Delta }, \frac{ \Delta_z }{ \Delta }, ... $$

A practical example

This system consists of 3 linear equations in 3 unknowns.

It is nonhomogeneous because its constant terms are nonzero.

$$ \begin{cases} 3x+2y-z= 1 \\ x - y +5z =-2 \\2x + y = 3 \end{cases} $$

The coefficient matrix is

$$ A = \begin{pmatrix} 3 & 2 & -1 \\ 1 & -1 & 5 \\ 2 & 1 & 0 \end{pmatrix} $$

The right-hand side vector is

$$ b = \begin{pmatrix} 1 \\ -2 \\ 3 \end{pmatrix} $$

First compute the determinant of A:

$$ \Delta = 3 \cdot \begin{vmatrix} -1 & 5 \\ 1 & 0 \end{vmatrix} - 2 \begin{vmatrix} 1 & 5 \\ 2 & 0 \end{vmatrix} + (-1) \begin{vmatrix} 1 & -1 \\ 2 & 1 \end{vmatrix} $$

$$ \Delta = 3 \cdot (-5) - 2 \cdot (-10) - 1 \cdot (3) $$

$$ \Delta = -15 + 20 - 3 $$

$$ \Delta = 2 $$

Since the determinant is nonzero, the system has a unique solution.

Computing x

Replace the first column with the right-hand side vector:

$$ A_x = \begin{pmatrix} \color{red} 1 & 2 & -1 \\ \color{red}{-2} & -1 & 5 \\ \color{red}3 & 1 & 0 \end{pmatrix} $$

Compute Δx:

$$ \Delta_x = 1 \cdot \begin{vmatrix} -1 & 5 \\ 1 & 0 \end{vmatrix} - 2 \cdot \begin{vmatrix} -2 & 5 \\ 3 & 0 \end{vmatrix} + (-1) \cdot \begin{vmatrix} -2 & -1 \\ 3 & 1 \end{vmatrix} $$

$$ \Delta_x = 1 \cdot (-5) - 2 \cdot (-15) - 1 \cdot 1 $$

$$ \Delta_x = -5 + 30 - 1 $$

$$ \Delta_x = 24 $$

Thus

$$ x = \frac{\Delta_x}{\Delta} = \frac{24}{2} = 12 $$

Computing y

Replace the second column with the vector b:

$$ A_y = \begin{pmatrix} 3 & \color{red}1 & -1 \\ 1 & \color{red}{-2} & 5 \\ 2 & \color{red}3 & 0 \end{pmatrix} $$

Compute Δy:

$$ \Delta_y = 3 \cdot \begin{vmatrix} -2 & 5 \\ 3 & 0 \end{vmatrix} - 1 \cdot \begin{vmatrix} 1 & 5 \\ 2 & 0 \end{vmatrix} + (-1) \cdot \begin{vmatrix} 1 & -2 \\ 2 & 3 \end{vmatrix} $$

$$ \Delta_y = 3 \cdot (-15) - 1 \cdot (-10) - 1 \cdot 7 $$

$$ \Delta_y = -45 + 10 - 7 $$

$$ \Delta_y = -42 $$

Thus

$$ y = \frac{\Delta_y}{\Delta} = \frac{-42}{2} = -21 $$

Computing z

Replace the third column with the vector b:

$$ A_z = \begin{pmatrix} 3 & 2 & \color{red}1 \\ 1 & -1 & \color{red}{-2} \\ 2 & 1 & \color{red}3 \end{pmatrix} $$

Compute Δz:

$$ \Delta_z = 3 \cdot \begin{vmatrix} -1 & -2 \\ 1 & 3 \end{vmatrix} - 2 \cdot \begin{vmatrix} 1 & -2 \\ 2 & 3 \end{vmatrix} + 1 \cdot \begin{vmatrix} 1 & -1 \\ 2 & 1 \end{vmatrix} $$

$$ \Delta_z = 3 \cdot (-1) - 2 \cdot 7 + 1 \cdot (3) $$

$$ \Delta_z = -3 - 14 + 3 $$

$$ \Delta_z = -14 $$

Thus

$$ z = \frac{\Delta_z}{\Delta} = \frac{-14}{2} = -7 $$

The solution

The complete solution of the system is

$$ x = 12 \\ y = -21 \\ z = -7 $$

Verification. Substitute the computed values back into the system. $$ \begin{cases} 3x+2y-z= 1 \\ x - y +5z =-2 \\2x + y = 3 \end{cases} $$ $$ \begin{cases} 3(12)+2(-21)-(-7)= 1 \\ 12 - (-21) +5(-7) =-2 \\2(12) + (-21) = 3 \end{cases} $$ $$ \begin{cases} 36-42+7= 1 \\ 12 +21 -35 =-2 \\ 24 - 21 = 3 \end{cases} $$ $$ \begin{cases} 1= 1 \\ -2 = -2 \\ 3 = 3 \end{cases} $$ The computation confirms the solution.

Proof

Consider a linear system in two variables:

$$ \begin{cases} a_1 x + b_1 y = c_1 \\ \\ a_2 x + b_2 y = c_2 \end{cases} $$

To derive Cramer's rule in the 2×2 case, we apply the elimination method and solve the system systematically.

Multiply both sides of the first equation by b2:

$$ \begin{cases} b_2 (a_1 x + b_1 y) = b_2 c_1 \\ \\ a_2 x + b_2 y = c_2 \end{cases} $$

$$ \begin{cases} a_1 b_2 x + b_1 b_2 y = b_2 c_1 \\ \\ a_2 x + b_2 y = c_2 \end{cases} $$

Next, multiply both sides of the second equation by b1:

$$ \begin{cases} a_1 b_2 x + b_1 b_2 y = b_2 c_1 \\ \\ b_1 (a_2 x + b_2 y) = b_1 c_2 \end{cases} $$

$$ \begin{cases} a_1 b_2 x + b_1 b_2 y = b_2 c_1 \\ \\ a_2 b_1 x + b_1 b_2 y = b_1 c_2 \end{cases} $$

Subtract the second equation from the first, term by term:

$$ \begin{matrix} a_1 b_2 x & + b_1 b_2 y & = b_2 c_1 & - \\ a_2 b_1 x & + b_1 b_2 y & = b_1 c_2 & \\ \hline a_1 b_2 x - a_2 b_1 x & \require{cancel} \cancel{+ b_1 b_2 y} - \cancel{b_1 b_2 y} & = b_2 c_1 - b_1 c_2 \end{matrix} $$

This gives an equation in x alone:

$$ a_1 b_2 x - a_2 b_1 x = b_2 c_1 - b_1 c_2 $$

$$ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} $$

With x determined, substitute it into either equation to solve for y. Using the first equation:

$$ \begin{cases} a_1 x + b_1 y = c_1 \\ \\ \cancel{a_2 x + b_2 y = c_2} \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

Substituting the expression for x:

$$ \begin{cases} a_1 \left( \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \right) + b_1 y = c_1 \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

Rearranging to isolate y:

$$ \begin{cases} b_1 y = c_1 - a_1 \left( \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \right) \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

$$ \begin{cases} y = \frac{c_1}{b_1} - \frac{a_1}{b_1} \left( \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \right) \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

Now combine the fractions:

$$ \begin{cases} y = \frac{c_1(a_1 b_2 - a_2 b_1) - a_1(b_2 c_1 - b_1 c_2)}{b_1 (a_1 b_2 - a_2 b_1)} \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

Simplify the numerator:

$$ \begin{cases} y = \frac{a_1 b_2 c_1 - a_2 b_1 c_1 - a_1 b_2 c_1 + a_1 b_1 c_2}{b_1 (a_1 b_2 - a_2 b_1)} \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

$$ \begin{cases} y = \frac{-a_2 b_1 c_1 + a_1 b_1 c_2}{b_1 (a_1 b_2 - a_2 b_1)} \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

Thus we obtain:

$$ \begin{cases} y = \frac{a_1 c_2 - a_2 c_1}{a_1 b_2 - a_2 b_1} \\ \\ x = \frac{b_2 c_1 - b_1 c_2}{a_1 b_2 - a_2 b_1} \end{cases} $$

The common denominator appearing in both expressions is the determinant of the coefficient matrix:

$$ \Delta = \begin{vmatrix} a_1 & b_1 \\ a_2 & b_2 \end{vmatrix} = a_1 b_2 - a_2 b_1 $$

The numerator in the expression for y is

$$ a_1 c_2 - a_2 c_1 $$

which matches the determinant Δy obtained by replacing the x-column with the right-hand side vector:

$$ \Delta_y = \begin{vmatrix} a_1 & c_1 \\ a_2 & c_2 \end{vmatrix} = a_1 c_2 - a_2 c_1 $$

The numerator in the expression for x is

$$ b_2 c_1 - b_1 c_2 $$

This corresponds to the determinant Δx obtained by replacing the y-column with the right-hand side vector:

$$ \Delta_x = \begin{vmatrix} c_1 & b_1 \\ c_2 & b_2 \end{vmatrix} = b_2 c_1 - b_1 c_2 $$

Substituting Δ, Δx and Δy yields the compact form:

$$ \begin{cases} y = \frac{\Delta_y}{\Delta} \\ \\ x = \frac{\Delta_x}{\Delta} \end{cases} $$

This completes the derivation of Cramer's rule for the 2×2 case.

Note. If Δ≠0 the system has a unique solution. If Δ=0, the system has infinitely many solutions when both Δx=0 and Δy=0, and no solutions when at least one of Δx or Δy is nonzero.

And so on.

 
 

Please feel free to point out any errors or typos, or share suggestions to improve these notes. English isn't my first language, so if you notice any mistakes, let me know, and I'll be sure to fix them.

FacebookTwitterLinkedinLinkedin
knowledge base

Equations

Systems of Equations

Other Types of Equations