# Linear Algebra

## Inverse by Cofactors

 If $$A\in M_{n\times n}(\mathbb{R})$$ is invertible, then $$(A^{-1})_{ij}=\frac{1}{|A|}C_{ji}$$. $$C_{ji}$$ is known as the adjugate of $$A$$.

The adjugate, adj(A), is the matrix of cofactors,

Example: Determine the adjugate and inverse of $$A=\left[\begin{array}{rrr} 2&4&-1\\0&3&1\\6&-2&5\end{array}\right]$$

Solution: The nine cofactors are

 $$C_{11}=(1)\left|\begin{array}{rr} 3&1\\-2&5\end{array}\right|=17$$ $$C_{12}=(-1)\left|\begin{array}{rr} 0&1\\6&5\end{array}\right|=6$$ $$C_{13}=(1)\left|\begin{array}{rr} 0&3\\6&-2\end{array}\right|=-18$$ $$C_{21}=(-1)\left|\begin{array}{rr} 4&-1\\-2&5\end{array}\right|=-18$$ $$C_{22}=(1)\left|\begin{array}{rr} 2&-1\\6&5\end{array}\right|=16$$ $$C_{23}=(-1)\left|\begin{array}{rr} 2&4\\6&-2\end{array}\right|=28$$ $$C_{31}=(1)\left|\begin{array}{rr} 4&-1\\4&1\end{array}\right|=7$$ $$C_{32}=(-1)\left|\begin{array}{rr} 2&-1\\0&1\end{array}\right|=-2$$ $$C_{33}=(1)\left|\begin{array}{rr} 2&4\\0&3\end{array}\right|=6$$

$adj(A)=\left[\begin{array}{rrr} C_{11}&C_{12}&C_{13}\\C_{21}&C_{22}&C_{23}\\C_{31}&C_{32}&C_{33}\end{array}\right]=\left[\begin{array}{rrr} 17&-18&7\\6&16&-2\\-18&28&6\end{array}\right]$

We can verify by cofactors that the determinant $$|A|=76$$. Therefore, we can calculate the inverse

$A^{-1}=\frac{1}{|A|}adj(A)=\frac{1}{76}\left[\begin{array}{rrr} 17&-18&7\\6&16&-2\\-18&28&6\end{array}\right]$

## Cramer's Rule

 We can apply Cramer's rule to solve a system of n linear equations in n variables, $$A\bar{x}=\bar{b}$$. If $$|A|\neq 0$$ so that $$A$$ is invertible. Let $$N_i$$ be the matrix obtained from $$A$$ by replacing the i-th column of $$A$$ by $$\bar{b}$$. Then the i-th component of $$\bar{x}$$ in the solution of $$A\bar{x}=\bar{b}$$ is $x_i=\frac{|N_i|}{|A|}$

The matrix $$N_i$$ is defined by replacing $$\bar{b}$$ by the column i.

For example, if

$A=\left[\begin{array}{rrr} 3&2&-1\\0&1&3\\-2&4&0\end{array}\right] \qquad \bar{x}=\begin{bmatrix} x_1\\x_2\\x_3\end{bmatrix} \qquad \bar{b}=\begin{bmatrix} 4\\2\\1\end{bmatrix}$

Then in $$N_1$$, $$\bar{b}$$ will replace column 1

$N_1=\left[\begin{array}{rrr} \mathbf{4}&2&-1\\\mathbf{2}&1&3\\\mathbf{1}&4&0\end{array}\right]$

In $$N_2$$, $$\bar{b}$$ will replace column 2

$N_2=\left[\begin{array}{rrr} 3&\mathbf{4}&-1\\0&\mathbf{2}&3\\-2&\mathbf{1}&0\end{array}\right]$

In $$N_3$$, $$\bar{b}$$ will replace column 3

$N_3=\left[\begin{array}{rrr} 3&2&\mathbf{4}\\0&1&\mathbf{2}\\-2&4&\mathbf{1}\end{array}\right]$

Example: Solve the following system of equations using Cramer's Rule

\begin{align} 7x+y-4z&=3\\-6x-4y+z&=0\\4x-y-2z&=6\end{align}

Solution

$A=\left[\begin{array}{rrr} 7&1&-4\\-6&-4&1\\4&-1&-2\end{array}\right] \qquad \bar{b}=\begin{bmatrix}3\\0\\6\end{bmatrix}$

To solve for variable x, we need to find the matrix $$N_x$$ by replacing the x or 1st column with $$\bar{b}$$

$N_x=\left[\begin{array}{rrr} \mathbf{3}&1&-4\\\mathbf{0}&-4&1\\\mathbf{6}&-1&-2\end{array}\right]$

We repeat to find $$N_y$$ and $$N_z$$

$N_y=\left[\begin{array}{rrr} 7&\mathbf{3}&-4\\-6&\mathbf{0}&1\\4&\mathbf{6}&-2\end{array}\right]$

$N_z=\left[\begin{array}{rrr} 7&1&\mathbf{3}\\-6&-4&\mathbf{0}\\4&-1&\mathbf{6}\end{array}\right]$

Now we apply Cramer's Rule

$x=\frac{|N_x|}{|A|} = \frac{-63}{-33}=\frac{21}{11} \qquad y=\frac{|N_y|}{|A|} = \frac{78}{-33}=-\frac{26}{11} \qquad z=\frac{|N_z|}{|A|} = \frac{-66}{-33}=2$

The solutions check out when plugging them back into each equation.