## Cramer's rule

Consider the system $$Ax = b$$ where $$A$$ is $$n\times n$$ and invertible. Cramer's rule says that the unique solution is given by $x_i = \frac{\det(B_i)}{\det(A)},~ i =1,\ldots, n,$ where $$B_i$$ is obtained from $$A$$ by replacing column $$i$$ with $$b$$.

For example, suppose that $$A = \begin{bmatrix} 1 & 2 \\ 2 & 3 \end{bmatrix}$$ and $$b = \begin{bmatrix} 4 \\ 5\end{bmatrix}$$. Then the unique solution is given by $x_1 = \frac{\left|\begin{matrix} 4 & 2 \\5 & 3\end{matrix}\right|} {\left|\begin{matrix} 1 & 2 \\2 & 3\end{matrix}\right|} = \frac{ 2}{-1} = -2,$ $x_2 = \frac{\left|\begin{matrix} 1 & 4 \\2 & 5\end{matrix}\right|} {\left|\begin{matrix} 1 & 2 \\2 & 3\end{matrix}\right|} = \frac{ -3}{-1} = 3.$

## Formula for the inverse matrix

We now obtain a formula for the inverse of an invertible matrix $$A$$ in terms of cofactors. Observe that $$AB = I_n$$ can be written as the following $$n$$ equations: $$AB_j = e_j$$ where $$B_j$$ denotes the $$j$$th column of $$B$$ and $$e_j$$ denotes the $$j$$th column of $$I_n$$.

By Cramer's rule, we get that $B_{i,j} = \frac{\det(M_i)}{\det(A)}$ where $$M_i$$ denotes the matrix obtained from $$A$$ by replacing column $$i$$ with $$e_j$$.

Since column $$i$$ of $$M_i$$ is $$e_j$$, expanding $$\det(M_i)$$ along column $$i$$, we get $$\det(M_i) = (-1)^{j+i}A(j \mid i) = C_{j,i}$$. (Beware of the indexing!)

Hence, $$B_{i,j}$$ is given by $$\displaystyle\frac{C_{j,i}}{\det(A)}$$. So a formula for $$A^{-1}$$ is $$\displaystyle\frac{1}{\det(A)} \begin{bmatrix} C_{1,1} & C_{2,1} & \cdots & C_{n,1} \\ C_{1,2} & C_{2,2} & \cdots & C_{n,2} \\ \vdots & \vdots & \ddots & \vdots \\ C_{1,n} & C_{2,n} & \cdots & C_{n,n}\end{bmatrix}.$$

## Exercises

1. Let $$A = \begin{bmatrix} 1 & -1 \\ -2 & 1\end{bmatrix}$$ Let $$b = \begin{bmatrix} -1 \\ -1\end{bmatrix}$$ Solve the system $$Ax = b$$ using Cramer's rule.

2. Let $$A\in \mathbb{Z}^{n\times n}$$. Let $$b\in \mathbb{Z}^n$$. Prove that if $$\lvert\det(A)\rvert = 1$$, then the solution to $$Ax = b$$ has only integer entries.