# 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 – Jose Paternina Sep 26 '16 at 1:29
• @JosePaternina it's out of my reach can you explain it in simplest manner?. – Fawad Sep 26 '16 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?). – Jose Paternina Sep 26 '16 at 1:40
• Did you mean to write linear equations rather than polynomial equations? – Martin Sleziak Sep 27 '16 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. – littleO Sep 26 '16 at 1:51
• I am impressed. Do you have any source or a reference for this proof? – Wojowu Sep 26 '16 at 10:51
• @Wojowu Sorry, I came up with it on my own. – Rene Schipperus Sep 26 '16 at 12:47
• I suspect it does exist somewhere in a book. – Rene Schipperus Sep 26 '16 at 12:59
• 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} – Rene Schipperus Oct 9 '16 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.

• There was an attempted edit, but sorry, the edit did not quite match my style. I want to make the answer as short and to-the-point as possible. It was a judgment call in this case. – littleO Nov 29 '19 at 4:02

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$ – Fawad Sep 26 '16 at 13:04
• It seems to me it also uses that a solution exists when the determinant is non-zero. – quid Sep 26 '16 at 13:42
• @Ramanujan If a multiple of one column is added to another column, the value of the determinant is not changed. – Workaholic Sep 26 '16 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. – J. M. is a poor mathematician Oct 14 '16 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)}$$