# How does Cramer's rule work?

I know Cramer's rule works for 3 linear equations. I know all steps to get solutions. But I don't know why (how) Cramer's rule gives us solutions?

Why do we get $x=\frac{\Delta_1}\Delta$ and $y$ and $z$ in the same way?

I want to know how these steps give us solutions?

• Just read the proof here en.wikipedia.org/wiki/Cramer%27s_rule#Proof Sep 26, 2016 at 1:29
• @JosePaternina it's out of my reach can you explain it in simplest manner?. Sep 26, 2016 at 1:32
• Well, for the general case (even for the case of $3$ inear equations) the proof is like in wikipedia. Try to do it for the case of $2$ linear equations with $2$ variables. Take $ax+by=r_1$ and $cx+dy=r_2$. Multiply first equation by $d$ and the second equation by $b$, you get $dax+dby=dr_1$ and $bcx+bdy=br_2$. If you substract these equations, you get $(da-bc)x=dr_1-br_2$, so $x=\frac{dr_1-br_2}{da-bc}=\frac{\Delta_1}{\Delta}$ (do you see why?). Sep 26, 2016 at 1:40
• Did you mean to write linear equations rather than polynomial equations? Sep 27, 2016 at 3:12

It's actually simple; I explain it here in two variables, but the principle is the same.

Say you have an equation $$\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix}x\\y\end{pmatrix}=\begin{pmatrix}p\\q \end{pmatrix}$$

Now you can see that the following holds

$$\begin{pmatrix}a&b\\c&d\end{pmatrix}\begin{pmatrix}x&0\\y&1\end{pmatrix}=\begin{pmatrix}p&b\\q &d\end{pmatrix}$$

Finally just take the determinant of this last equation; $\det$ is multiplicative so you get $$\Delta x=\Delta_1$$

• This is nice, I'd never seen this proof before. Sep 26, 2016 at 1:51
• @Wojowu Sorry, I came up with it on my own. Sep 26, 2016 at 12:47
• I suspect it does exist somewhere in a book. Sep 26, 2016 at 12:59
• This is cute! :D Just to give other people an idea on how this generalizes, for the three-variable case, we need the matrices $$\begin{pmatrix}x & 0 & 0 \\y & 1 & 0 \\z & 0 & 1\end{pmatrix},\begin{pmatrix}x & 0 & 1\\y & 0 & 0\\z & 1 & 0\end{pmatrix}, \begin{pmatrix}x & 1 & 0\\y & 0 & 1\\z & 0 & 0\end{pmatrix}$$ and note which columns of the appropriately-dimensioned identity matrix are being used to construct these matrices. Oct 9, 2016 at 6:45
• Thats one way but actually much more transparent is \begin{pmatrix}x & 0 & 0 \\y & 1 & 0 \\z & 0 & 1\end{pmatrix},\begin{pmatrix}1& x & 0\\0& y & 0\\0 & z & 1\end{pmatrix}, \begin{pmatrix}1 & 0 & x\\0& 1& y\\0 & 0 & z\end{pmatrix} Oct 9, 2016 at 13:19

Cramer's rule is very easy to discover because if you solve the linear system of equations \begin{align*} a_{11} x_1 + a_{12} x_2 + a_{13} x_3 &= b_1 \\ a_{21} x_1 + a_{22} x_2 + a_{23} x_3 &= b_2 \\ a_{31} x_1 + a_{32} x_2 + a_{33} x_3 &= b_3 \\ \end{align*} by hand, just using a standard high school approach of eliminating variables, then out pops Cramer's rule! In my opinion, this is the most likely way that a mathematician would discover the determinant in the first place, and Cramer's rule is discovered simultaneously.

I remember thinking that it must be quite difficult to prove Cramer's rule for an $n \times n$ matrix, but it turns out to be surprisingly easy (once you take the right approach). We'll prove it below.

The most useful way of looking at the determinant, in my opinion, is this: the function $M \mapsto \det M$ is an alternating multilinear function of the columns of $M$ which satisfies $\det(I) = 1$. This characterization of the determinant gives us a quick, simple proof of Cramer's rule.

For simplicity, I'll assume $A$ is a $3 \times 3$ matrix with columns $a_1, a_2, a_3$. Suppose that $$b = Ax = x_1 a_1 + x_2 a_2 + x_3 a_3.$$ Then \begin{align*} \begin{vmatrix} b & a_2 & a_3 \end{vmatrix} &= \begin{vmatrix} x_1 a_1 + x_2 a_2 + x_3 a_3 & a_2 & a_3 \end{vmatrix} \\ &= x_1 \begin{vmatrix} a_1 & a_2 & a_3 \end{vmatrix} + x_2 \begin{vmatrix} a_2 & a_2 & a_3 \end{vmatrix} + x_3 \begin{vmatrix} a_3 & a_2 & a_3 \end{vmatrix} \\ &= x_1 \det A. \end{align*} If $\det A \neq 0$, it follows that $$x_1 = \frac{\begin{vmatrix} b & a_2 & a_3 \end{vmatrix}}{\det A}.$$

I learned this proof in section 4.4, problem 16 ("Quick proof of Cramer's rule") in Gilbert Strang's book Linear Algebra and its Applications.

• Why det(x_1a_1 + x_2a_2 + x_3a_3 , a_2 , a_3) = det(x_1a_1 , a_2 , a_3) + det(x_2a_2 , a_2 , a_3) + det(x_3a_3 , a_2 , a_3) = x_1det(a_1 , a_2 , a_3) + x_2det(a_2, a_2, a_3) + x_3det(a_3, a_2, a_3) ? Jul 29, 2020 at 10:52
• Why det(a_2 a_2 a_3) = 0 ? Why det(a+b c d) = det(a c d) + det(b c d) ? Jul 29, 2020 at 10:52
• @kevin Those facts follow from the assumption that the determinant is an alternating multilinear function of the columns of $M$ (which satisfies $det(I) = 1$). This fundamental characterization of the determinant is often the best way or the easiest way to think about the determinant, in my opinion. Jul 29, 2020 at 14:24

Here is a very simple solution that only uses some properties of determinants. Consider the following system:

$$\left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right.$$ Assume $\Delta\neq0$, then, \require{action}\begin{align} \Delta_1& \mathtip{=\left| \matrix{d_1 & b_1 & c_1 \\ d_2 & b_2 & c_2 \\ d_3 & b_3 & c_3}\right|}{\text{by definition of }\Delta_1} \\& \\ &\mathtip{=\left| \matrix{(a_1x+b_1y+c_1z) & b_1 & c_1 \\ (a_2x+b_2y+c_2z) & b_2 & c_2 \\ (a_3x+b_3y+c_3z) & b_3 & c_3}\right|}{\text{by the system of equations}} \\& \\ &\mathtip{=\left| \matrix{(a_1x+b_1y+c_1z)-(b_1y+c_1z) & b_1 & c_1 \\ (a_2x+b_2y+c_2z)-(b_2y+c_2z) & b_2 & c_2 \\ (a_3x+b_3y+c_3z)-(b_3y+c_3z) & b_3 & c_3}\right|}{\text{If a multiple of one column is added to another column, the value of the determinant is not changed.}} \\ & \\ &\mathtip{=\left| \matrix{a_1x & b_1 & c_1 \\ a_2x & b_2 & c_2 \\ a_3x & b_3 & c_3}\right|}{\text{Simplifying}} \\& \\ &\mathtip{= x\left| \matrix{a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3}\right|}{\text{If each entry in a given row is multiplied by k, then the value of the determinant is multiplied by k.}} \\& \\ &\mathtip{= x\Delta}{\text{by definition of }\Delta} \end{align} Thus $x=\dfrac{\Delta_1}{\Delta}$. The proof is due to D. E. Whitford and M. S. Klamkin. (“On an Elementary Derivation of Cramer's Rule”, American Mathematical Monthly, vol. 60 (1953), pp.186–7).

• I didn't get that 3rd step for $\Delta_1$ Sep 26, 2016 at 13:04
• It seems to me it also uses that a solution exists when the determinant is non-zero.
– quid
Sep 26, 2016 at 13:42
• @Ramanujan If a multiple of one column is added to another column, the value of the determinant is not changed. Sep 26, 2016 at 15:37

This is another way to look at it. $Ax = b$ where A is invertible. First we define the following matrix:

$$I_i(x) = [e_1\,\,e_2\,\, e_{i-1}\,\,x\,\,e_{i+1}\,\, ...\,\, e_n]$$ By the defenition of matrix multiplication: $$AI_i(x) = [Ae_1\,\,Ae_2\,\, Ae_{i-1}\,\,Ax\,\,Ae_{i+1}\,\, ...\,\, Ae_n]$$ $$AI_i(x) = A_i(b)$$ $$det\,AI_i(x) = det\,A_i(b)$$

The determinant of the product of two matrices is the product of the determinants, so:

$$det\,A \,\cdot\, det\,I_i(x) = det\,A_i(b)$$

Let's now look at $det\,I_i(x)$, note that the determinants are the same because you can get rid of all the $x_j$ where $j\ne i$ by row reduction. Also $x$ is in the $i^{th}$ column: $$det\,I_i(x) = det \begin{bmatrix} 1 & x_1 & \cdots & 0 \\ 0 & x_2 & 0 & 0 \\ \vdots & \vdots & \ddots & 0 \\ 0 & x_n & 0 & 1 \\ \end{bmatrix} = det \begin{bmatrix} 1 & 0 & \cdots & 0 \\ 0 & x_i & 0 & 0 \\ \vdots & \vdots & \ddots & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} = 1 \cdot 1 \cdot\cdot\cdot 1\cdot x_i \cdot 1\cdot\cdot\cdot1=x_i$$

$det\,I_i(x)$ is simply $x_i$, So we can say that: $$x_i = \frac{det\,A_i(b)}{det\,A}$$

• This is essentially the same as Rene's answer, but this is a bit more explicit. Oct 14, 2016 at 10:26

I encountered a proof of Cramer's rule with $$2$$ unknowns in my textbook. It involves application of the method of elimination.

Consider $$a_1x+b_1y+c_1=0 \tag1a_2x+b_2y+c_2=0 \tag2$$

Define $$\Delta_1=\left|\begin{matrix}c_1 & b_1 \\ c_2 & b_2\end{matrix}\right|, \Delta_2=\left|\begin{matrix}a_1 & c_1 \\ a_2 & c_2\end{matrix}\right|, \Delta=\left|\begin{matrix}a_1 & b_1 \\ a_2 & b_2\end{matrix}\right|$$.

1. Multiplying equation $$(1)$$ by $$b_2$$
2. Multiplying equation $$(2)$$ by $$b_1$$
3. Subtracting equations

\begin{align}b_2(a_1x+b_1y+c_1=0) \\-b_1(a_2x+b_2y+c_2=0) \end{align}\\ \rule{10cm}{0.5pt}\\ x(a_1b_2-a_2b_1)+(b_2c_1-b_1c_2)=0 \implies x=\dfrac{\Delta_1}{\Delta}

1. Multiplying equation $$(1)$$ by $$a_2$$
2. Multiplying equation $$(2)$$ by $$a_1$$
3. Subtracting equations

\begin{align} a_2(a_1x+b_1y+c_1=0) \\ -a_1(a_2x+b_2y+c_2=0)\end{align} \\\rule{10cm}{0.5pt} \\ y(a_2b_1-a_1b_2)+(a_2c_1-a_1c_2)=0\implies y=\dfrac{\Delta_2}{\Delta}

Note that this is valid provided $$\Delta=(a_1b_2-a_2b_1)\ne0$$.

Given a linear system $\rm A x = b$, where $\mathrm A \in \mathbb R^{n \times n}$ is invertible and $\mathrm b \in \mathbb R^n$, let $\rm \bar{x} := A^{-1} b$ denote the (unique) solution. Replacing the $k$-th column of matrix $\rm A$ (denoted by $\mathrm a_k$) with $\rm b$ and computing the determinant of this new matrix using the matrix determinant lemma,

\begin{aligned} \det \left( \mathrm A + (\mathrm b - \mathrm a_k) \mathrm e_k^\top \right) &= \det (\mathrm A) \cdot \left( 1 + \mathrm e_k^\top \mathrm A^{-1} (\mathrm b - \mathrm a_k) \right)\\ &= \det (\mathrm A) \cdot \left( 1 + \mathrm e_k^\top \mathrm A^{-1} \mathrm b - \mathrm e_k^\top \mathrm A^{-1} \mathrm a_k \right)\\ &= \det (\mathrm A) \cdot \left( 1 + \mathrm e_k^\top \mathrm{\bar{x}} - \mathrm e_k^\top \mathrm e_k \right)\\ &= \det (\mathrm A) \cdot \bar{x}_k\end{aligned}

and, thus, we obtain Cramer's rule

$$\bar{x}_k = \frac{\det \left( \mathrm A + (\mathrm b - \mathrm a_k) \mathrm e_k^\top \right)}{\det (\mathrm A)}$$

Let $$A$$ be an $$n \times n$$ invertible matrix, and $$b \in \mathbb{R}^{n}$$. We're looking for the $$x \in \mathbb{R}^n$$ such that $$Ax = b$$.

Let's write columns of $$A$$ as $$A_1, \ldots, A_n$$ (since $$A$$ is invertible, these form a basis of $$\mathbb{R}^n$$). Now $$Ax = b$$ becomes $$x_1 A_1 + \ldots + x_n A_n = b$$. Notice $$x_k$$ is that scalar $$t$$ such that $$b - t A_k$$ lies in the span of $$\{ A_i : i \neq k \}$$ [ We can visualise this for $$n \leq 3$$ ].

So $$\det(A_1, \ldots, b - x_k A_k, \ldots, A_n) = 0$$, from which $$x_k = \frac{\det(A_1, \, \ldots \, , \, b \, , \, \ldots \, , A_n)}{\det(A_1, \, \ldots \, , A_n)}$$ [ Here the $$b$$ in numerator appears in $$k^{th}$$ position ].

Here is a more geometric proof, which I'll illustrate for case of a two variable system.

$$c_1 = a_1 x + b_1 y$$

$$c_2 = a_2 x + b_2 y$$

The above is equivalent to:

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

To solve for $$x$$ , cross product both sides with $$\begin{bmatrix} b_1 \\ b_2 \\ 0\end{bmatrix}$$ :

$$\begin{bmatrix} c_1 \\ c_2 \\ 0\end{bmatrix} \times \begin{bmatrix} b_1 \\ b_2 \\ 0\end{bmatrix}=x\begin{bmatrix} a_1 \\ a_2 \\ 0\end{bmatrix} \times \begin{bmatrix} b_1 \\ b_2 \\ 0\end{bmatrix}$$

After this equate the 3rd component of third entry in each column vector and do some algebra:

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

Done.