# 10 Cramer's Method

Gabriel Cramer was a Swiss mathematician who lived in the first half of the 18th century. In 1750 he published his method for solving sets of linear equations which is in common use today.

## 10.1 Simultaneous Equations in Two Variables

If we have two simultaneous equations $a_1x+b_1y=c_1$ and $a_2x+b_2y=c_2$ we could write them in matrix form like this

 $\begin{bmatrix}a_1 & b_1 \\[0.3em]a_2 & b_2\end{bmatrix}$ $\begin{bmatrix}x \\[0.3em] y \end{bmatrix}$ $=$ $\begin{bmatrix} c_1 \\[0.3em] c_2 \end{bmatrix}$ or more succinctly $A$ $X$ $=$ $C$

The determinant of the matrix of coefficients, $D$, is given by $D=a_1b_2-b_1a_2$

$D=a_1b_2-b_1a_2$

To find the value of $x$ we first calculate $D$, the determinant of the matrix of coefficients. If $D$ is non-zero, we replace column containing the $x$ coefficients in $A$ with the column vector $C$. We call this determinant $D_x$ and it is given by $D_x=c_1b_2-b_1c_2$.

$D_x=c_1b_2-b_1c_2$

To find $y$ we replace column containing the $y$ coefficients in $A$ with the column vector $C$. We call this determinant $D_y$ and it is given by $D_y=a_1c_2-c_1a_2$.

$D_y=a_1c_2-c_1a_2$

Finally, to find $x$ and $y$ we divide the respective determinants, $x=D_x/D$ and $y=D_y/D$

$x=\dfrac{Dx}{D}=\dfrac{\begin{vmatrix} c_1 & b_1 \\[0.3em] c_2 & b_2 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 \\[0.3em] a_2 & b_2 \end{vmatrix}}$ and $y=\dfrac{D_y}{D}=\dfrac{\begin{vmatrix} a_1 & c_1 \\[0.3em] a_2 & c_2 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 \\[0.3em] a_2 & b_2 \end{vmatrix}}$

Example 10.1: Solve the following simultaneous equations using Cramer's method.

$-5x+y$
$=$
$13$
$2x+4y$
$=$
$8$

The matrix form of the equation looks like this:

$\begin{vmatrix}-5 & 1 \\[0.3em]2 & 4\end{vmatrix} \begin{vmatrix}x \\[0.3em]y \end{vmatrix}$
$=$
$\begin{vmatrix}13 \\[0.3em]8 \end{vmatrix}$

so we can write

$D$
$=$
$\begin{vmatrix}-5 &1 \\[0.3em]2 & 4\end{vmatrix}=-5 \times 4 - 1 \times 2=-22$
$D_x$
$=$
$\begin{vmatrix}13 &1 \\[0.3em]8 & 4\end{vmatrix}=13 \times 4 - 1 \times 8=44$
So $x$
$=$
$\dfrac{D_x}{D}=\dfrac{44}{-22}=-2$

For $y$ we can write

$D_y$
$=$
$\begin{vmatrix}-5 &13 \\[0.3em]2 & 8\end{vmatrix}=-5 \times 8 - 13 \times 2=-66$
So $y$
$=$
$\dfrac{D_y}{D}=\dfrac{-66}{-22}=3$

Giving us $x=-2$ and $y=3$

Sanity Check
Put $x=-1$ and $y=3$ into one of the original equations.

If we use the first equation we get $-5 \times(-2)+3 = 10 + 3 = 13$
so our answers are probably right.

## 10.2 Simultaneous Equations in Three Variables

We can extend Cramer's method to three dimensions by adding a third variable. If we have the following equations $a_1x+b_1y+c_1z=d_1$, $a_2x+b_2y+c_2z=d_2$ and $a_3x+b_3y+c_3z=d_2$ we could write them in matrix form like this:

 $\begin{bmatrix} a_1 & b_1 & c_1 \\[0.3em] a_2 & b_2 & c_2 \\[0.3em] a_3 & b_3 & c_3 \end{bmatrix}$ $\begin{bmatrix} x \\[0.3em] y \\[0.3em] z \end{bmatrix}$ $=$ $\begin{bmatrix} d_1 \\[0.3em] d_2 \\[0.3em] d_3 \end{bmatrix}$ $A$ $X$ $=$ $D$

The determinant of the matrix of coefficients is given by $|A|=a_1(b_2 c_3-c_2b_3)-b_1(a_2c_3-c_2a_3)+c1(a_2b_3-b_2a_3)$

Using Cramer's method we can write

$x=\dfrac{\begin{vmatrix} d_1 & b_1 & c_1 \\[0.3em] d_2 & b_2 & c_2 \\[0.3em] d_3 & b_3 & c_3 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 & c_1 \\[0.3em] a_2 & b_2 & c_2 \\[0.3em] a_3 & b_3 & c_3 \end{vmatrix}}$, $y=\dfrac{\begin{vmatrix} a_1 & d_1 & c_1 \\[0.3em] a_2 & d_2 & c_2 \\[0.3em] a_3 & d_3 & c_3 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 & c_1 \\[0.3em] a_2 & b_2 & c_2 \\[0.3em] a_3 & b_3 & c_3 \end{vmatrix}}$ and $z=\dfrac{\begin{vmatrix} a_1 & b_1 & d_1 \\[0.3em] a_2 & b_2 & d_2 \\[0.3em] a_3 & b_3 & d_3 \end{vmatrix}}{\begin{vmatrix} a_1 & b_1 & c_1 \\[0.3em] a_2 & b_2 & c_2 \\[0.3em] a_3 & b_3 & c_3 \end{vmatrix}}$

Example 10.2: Solve the following simultaneous equations using Cramer's method.

$5x-4y-z$
$=$
$19$
$−3x+5y+5z$
$=$
$1$
$5x+y+3z$
$=$
$25$

The matrix form of the equation looks like this:

$\begin{bmatrix}5&-4&-1\\[0.3em]-3&5&5\\[0.3em]5&1&3\end{bmatrix}\begin{bmatrix}x\\[0.3em]y\\[0.3em]z\end{bmatrix}$
$=$
$\begin{bmatrix}19\\[0.3em]1\\[0.3em]25\end{bmatrix}$
so we can write $D$
$=$
$\begin{vmatrix}5&-4&-1\\[0.3em]-3&5&5\\[0.3em]5&1&3\end{vmatrix}$

$=$
$5(5\times3-5\times1)$
$-(-4)(-3\times3-5\times5)$
$-1(-3\times1-5\times5)$

$D$
$=$
$-58$
and $D_x$
$=$
$\begin{vmatrix}19&-4&-1\\[0.3em]1&5&5\\[0.3em]25&1&3\end{vmatrix}$

$=$
$19(5\times3-5\times1)$
$-(-4)(1\times3-5\times25)$
$-1(1\times1-5\times25)$

$D_x$
$=$
$-174$
and $D_y$
$=$
$\begin{vmatrix}5&19&-1\\[0.3em]-3&1&5\\[0.3em]5&25&3\end{vmatrix}$

$=$
$5(1\times3-5\times25)$
$-19(-3\times3-5\times5)$
$-1(-3\times25-1\times5)$

$D_y$
$=$
$116$
and finally $D_z$
$=$
$\begin{vmatrix}5&-4&19\\[0.3em]-3&5&1\\[0.3em]5&1&25\end{vmatrix}$

$=$
$5(5\times25-1\times1)$
$-(-4)(-3\times25-1\times5)$
$+19(-3\times1-5\times5)$

$D_z$
$=$
$-232$

so $x=\dfrac{-174}{-58}=3$, $y=\dfrac{116}{-58}=-2$ and $z=\dfrac{-232}{-58}=4$

Sanity Check
Put $x=3$, $y=-2$ and $z=4$ into one of the original equations.

If we use the first equation we get $5 \times 3-4\times(-2)-4 = 15+8-4 = 19$
so our answers are probably right.