Wednesday, August 13, 2025

Cramer’s rule

1.2 The method of determinants

Suppose that we wish to solve the following pair of equations for $x$ and $y$

$$ ax + by = c $$

$$ lx + my = n $$

where $a, b, c, l, m$ and $n$ are constants.

Multiplying the first equation by $m$, the second equation by $b$ and subtracting eliminates $y$ leaving us with the linear equation in $x$

$$ (am - lb)x = cm - nb . $$

Similarly, multiplying the first equation by $l$, the second by $a$ and subtracting would eliminate $x$ and give us a linear equation in $y$ only

$$ (bl - am)y = cl - na . $$

The solution to the pair of equations is then

$$ x = \frac{cm - nb}{am - lb}, \quad y = \frac{an - lc}{am - lb} $$

provided $am - lb \neq 0$. The denominator in these expressions for $x$ and $y$ is called the determinant of the coefficients of $x$ and $y$ and is defined by the notation

$$ \begin{vmatrix} a & b \\ l & m \end{vmatrix} = am - lb . $$

This is called a second order determinant because it has 2 rows and 2 columns bounded by two vertical lines, not brackets. A third order determinant would have 3 rows and 3 columns. A determinant has a single value, for example

$$ \begin{vmatrix} 2 & 4 \\ 1 & 3 \end{vmatrix} = 2 \times 3 - 4 \times 1 = 2 . $$

Notice now that $x$ and $y$ can be written as fractions involving two determinants

$$ x = \frac{\begin{vmatrix} c & b \\ n & m \end{vmatrix}}{\begin{vmatrix} a & b \\ l & m \end{vmatrix}},  \quad y = \frac{\begin{vmatrix} a & c \\ l & n \end{vmatrix}}{\begin{vmatrix} a & b \\ l & m \end{vmatrix}} . $$

The determinants in the numerators are very similar to the denominator. We write the solution in the form

$$ x = \frac{\Delta_x}{\Delta}, \quad y = \frac{\Delta_y}{\Delta} $$

where

$$ \Delta = \begin{vmatrix} a & b \\ l & m \end{vmatrix},  \quad \Delta_x = \begin{vmatrix} c & b \\ n & m \end{vmatrix},  \quad \Delta_y = \begin{vmatrix} a & c \\ l & n \end{vmatrix} $$

The determinants $\Delta_x$ and $\Delta_y$ are obtained from $\Delta$ by replacing the first and second columns respectively by the right-hand sides of the original linear equations.

Remember, the solution is defined only if $\Delta \neq 0$. This approach is called the method of determinants, or Cramer’s rule.


Please tell me more about Cramer’s rule.

Here’s the big picture and the useful details about Cramer’s rule.

What it is (general form)

For a square linear system $A\mathbf{x}=\mathbf{b}$ of size $n\times n$ with $\det(A)\neq 0$,

$$ x_i=\frac{\det(A_i)}{\det(A)}\quad(i=1,\dots,n), $$

where $A_i$ is the matrix $A$ with its $i$-th column replaced by $\mathbf{b}$. That’s exactly what you saw for $n=2$. It works over real or complex numbers.

When it applies

  • Unique solution: only if $\det(A)\ne 0$ (i.e., $A$ is invertible).
  • $\det(A)=0$: either no solution or infinitely many. (Rank test: if $\operatorname{rank}(A)=\operatorname{rank}([A|\mathbf{b}])<n$ → infinitely many; if ranks differ → no solution.)

Why it works (connection to the adjugate)

The matrix inverse has the explicit form

$$ A^{-1}=\frac{1}{\det(A)}\,\operatorname{adj}(A), $$

where $\operatorname{adj}(A)$ is built from cofactors. Multiplying $A^{-1}\mathbf{b}$ yields the same “replace-a-column” determinants in each component—those are the $\det(A_i)$.

A quick 3×3 example

Solve

$$ \begin{cases} 2x-y+3z=9\\ x+4y-z=1\\ 3x+2y+2z=12 \end{cases} \quad\Longleftrightarrow\quad A=\begin{bmatrix}2&-1&3\\[2pt]1&4&-1\\[2pt]3&2&2\end{bmatrix},\ \mathbf{b}=\begin{bmatrix}9\\1\\12\end{bmatrix}. $$

Compute determinants:

$$ \Delta=\det(A)=-5,\quad \Delta_x=\det\!\begin{bmatrix}\mathbf{b}&-1&3\\1&4&-1\\12&2&2\end{bmatrix}=-34,\quad \Delta_y=10,\quad \Delta_z=11. $$

Hence

$$ x=\frac{-34}{-5}=\tfrac{34}{5},\quad y=\frac{10}{-5}=-2,\quad z=\frac{11}{-5}=-\tfrac{11}{5}. $$

Geometric intuition (2×2 case)

$|\det(A)|$ is the area scaling of the unit square under the linear map $A$. Replacing a column by $\mathbf{b}$ forms a new parallelogram; the ratio $\det(A_i)/\det(A)$ extracts the coordinate $x_i$.

Pros & cons

Pros

  • Gives closed-form expressions for each variable.
  • Great for symbolic work (e.g., showing how solutions change with parameters) and small systems (2×2, occasionally 3×3).

Cons

  • Not computationally efficient for large $n$: computing $n+1$ determinants is expensive (typically $O(n^4)$ if done via LU per determinant).
  • Numerically less stable than Gaussian elimination/QR for floating-point data; determinants can overflow/underflow and amplify conditioning issues.

Practical tips

  • For hand calculations: use it for 2×2 and 3×3 (Sarrus’ rule helps for 3×3).
  • For larger systems or numerics: prefer Gaussian elimination, LU/QR factorization, or direct $A^{-1}\mathbf{b}$ via a solver.
  • If $\det(A)$ is (nearly) zero, the system is ill-conditioned or singular—avoid Cramer’s rule and use a stable solver and conditioning checks.

If you want, I can walk you through Sarrus’ rule for 3×3 determinants or set up a couple of practice problems with solutions.

Yes, please tell me about Sarrus’ rule.

happy to! Sarrus’ rule is a quick way to compute only 3×3 determinants.

What it is

For

$$ \begin{vmatrix} a&b&c\\ d&e&f\\ g&h&i \end{vmatrix} $$

Sarrus’ rule says

$$ \det = aei + bfg + cdh \;-\; ceg - bdi - afh. $$

How to do it (the “copy columns” trick)

  1. Rewrite the first two columns to the right:

$$ \begin{array}{ccc|cc} a&b&c& a&b\\ d&e&f& d&e\\ g&h&i& g&h \end{array} $$

  1. Multiply the three down-right diagonals and add:

$$ (a\cdot e\cdot i) + (b\cdot f\cdot g) + (c\cdot d\cdot h). $$

  1. Multiply the three up-right diagonals and add:

$$ (c\cdot e\cdot g) + (b\cdot d\cdot i) + (a\cdot f\cdot h). $$

  1. Subtract: (down sum) − (up sum).

Worked example

Compute

$$ \det\!\begin{bmatrix} 2&-1&3\\ 1&4&-1\\ 3&2&2 \end{bmatrix}. $$

Copy first two columns:

$$ \begin{array}{ccc|cc} 2&-1&3&2&-1\\ 1&4&-1&1&4\\ 3&2&2&3&2 \end{array} $$

Down sum: $2\cdot4\cdot2=16$, $(-1)\cdot(-1)\cdot3=3$, $3\cdot1\cdot2=6$ → $16+3+6=25$. Up sum: $3\cdot4\cdot3=36$, $2\cdot(-1)\cdot2=-4$, $2\cdot1\cdot(-1)=-2$ → $36-4-2=30$. Determinant $=25-30=-5$.

Why it works (intuition)

For 3×3 matrices the determinant is a signed sum over the six permutations of $\{1,2,3\}$. Sarrus’ diagram just groups the three even permutations (the “down” diagonals) and subtracts the three odd permutations (the “up” diagonals).

Tips & pitfalls

  • Only for 3×3. There’s no Sarrus shortcut for 4×4 or higher; use cofactor expansion or row-reduction.
  • Row/column ops help: If you can create a zero, expansion along that row/column gets easier than Sarrus.
  • Signs: The most common mistake is dropping a minus in the “up” group—write the two sums separately, then subtract.

Want a couple of quick practice determinants with answers?

No comments:

Post a Comment