Digital Garden
Maths
Linear Algebra
Matrix Inverse

Matrix inverse

Left and Right Inverse

Inverse via Cofactor Matrix

Inverse via Gaussian Elimination

The gaussian elimination method can be extended to calculate the inverse of a matrix. Because the inverse of a matrix is only defined for square matrices, this algorithm only works for square matrices such as 2×22 \times 2 matrices, 3×33 \times 3 matrices, ARn×n\boldsymbol{A} \in \mathbb{R}^{n \times n}.

Just like when solving a system of linear equations, we first transform the matrix into an augmented matrix. However, instead of having the constants on the right side of the vertical line we add the identity matrix I\boldsymbol{I} of the same size as the matrix on the right side of the vertical line.

Example

Given the matrix:

A=[242493237]\boldsymbol{A} = \begin{bmatrix} 2 & 4 & -2 \\ 4 & 9 & -3 \\ -2 & -3 & 7 \end{bmatrix}

We can calculate the inverse of A\boldsymbol{A} by transforming it into the following augmented matrix:

[AI]=[242100493010237001][\boldsymbol{A}|\boldsymbol{I}] =\left[\begin{array}{ccc|ccc} 2 & 4 & -2 & 1 & 0 & 0 \\ 4 & 9 & -3 & 0 & 1 & 0 \\ -2 & -3 & 7 & 0 & 0 & 1 \end{array}\right]

The goal of the algorithm is now to transform the left side of the augmented matrix into the identity matrix I\boldsymbol{I}. We are still only allowed to perform the same operations as before:

  • Swapping two rows
  • Multiplying a row by a nonzero number
  • Adding a multiple of one row to another row, the multiple can also be negative resulting in subtracting a multiple of one row from another row.

Important it is important that when we perform an operation on the left side of the augmented matrix, we also perform the same operation on the right side!

By then transforming the left hand side firts into row echelon form and then into reduced row echelon form and then lastly performing back substitution we should get on the left hand side the identity matrix I\boldsymbol{I} and on the right hand side the inverse of the matrix A\boldsymbol{A} so that we have:

[IA1][\boldsymbol{I}|\boldsymbol{A}^{-1}]

Which fullfills the definition of the inverse of a matrix:

AA1=I\boldsymbol{A} \boldsymbol{A}^{-1} = \boldsymbol{I}
Example [AI]=[242100493010237001]R1=12R1[1211200493010237001]R2=R24R1[1211200011210237001]R3=R3+2R1[1211200011210015101]R3=R3R2[1211200011210004311]R3=14R3[1211200011210001341414]R2=R2R3[12112000101145414001341414]R1=R1+R3[1205414140101145414001341414]R1=R12R2[100274114340101145414001341414]\begin{align} [\boldsymbol{A}|\boldsymbol{I}]= \left[\begin{array}{ccc|ccc} 2 & 4 & -2 & 1 & 0 & 0 \\ 4 & 9 & -3 & 0 & 1 & 0 \\ -2 & -3 & 7 & 0 & 0 & 1 \end{array}\right] & \rightarrow R_1 = \frac{1}{2}R_1 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 4 & 9 & -3 & 0 & 1 & 0 \\ -2 & -3 & 7 & 0 & 0 & 1 \end{array}\right] & \rightarrow R_2 = R_2 - 4R_1 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 0 & 1 & 1 & -2 & 1 & 0 \\ -2 & -3 & 7 & 0 & 0 & 1 \end{array}\right] & \rightarrow R_3 = R_3 + 2R_1 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 0 & 1 & 1 & -2 & 1 & 0 \\ 0 & 1 & 5 & 1 & 0 & 1 \end{array}\right] & \rightarrow R_3 = R_3 - R_2 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 0 & 1 & 1 & -2 & 1 & 0 \\ 0 & 0 & 4 & 3 & -1 & 1 \end{array}\right] & \rightarrow R_3 = \frac{1}{4}R_3 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 0 & 1 & 1 & -2 & 1 & 0 \\ 0 & 0 & 1 & \frac{3}{4} & -\frac{1}{4} & \frac{1}{4} \end{array}\right] & \rightarrow R_2 = R_2 - R_3 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & -1 & \frac{1}{2} & 0 & 0 \\ 0 & 1 & 0 & -\frac{11}{4} & \frac{5}{4} & -\frac{1}{4} \\ 0 & 0 & 1 & \frac{3}{4} & -\frac{1}{4} & \frac{1}{4} \end{array}\right] & \rightarrow R_1 = R_1 + R_3 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 2 & 0 & \frac{5}{4} & -\frac{1}{4} & \frac{1}{4} \\ 0 & 1 & 0 & -\frac{11}{4} & \frac{5}{4} & -\frac{1}{4} \\ 0 & 0 & 1 & \frac{3}{4} & -\frac{1}{4} & \frac{1}{4} \end{array}\right] & \rightarrow R_1 = R_1 - 2R_2 \\ \rightarrow \left[\begin{array}{ccc|ccc} 1 & 0 & 0 & \frac{27}{4} & -\frac{11}{4} & \frac{3}{4} \\ 0 & 1 & 0 & -\frac{11}{4} & \frac{5}{4} & -\frac{1}{4} \\ 0 & 0 & 1 & \frac{3}{4} & -\frac{1}{4} & \frac{1}{4} \end{array}\right] \end{align}

This gives us the inverse of the matrix A\boldsymbol{A}:

A1=[274114341145414341414]=14[271131151311]=[6.752.750.752.751.250.250.750.250.25]\boldsymbol{A}^{-1} = \begin{bmatrix} \frac{27}{4} & -\frac{11}{4} & \frac{3}{4} \\ -\frac{11}{4} & \frac{5}{4} & -\frac{1}{4} \\ \frac{3}{4} & -\frac{1}{4} & \frac{1}{4} \end{bmatrix} = \frac{1}{4} \begin{bmatrix} 27 & -11 & 3 \\ -11 & 5 & -1 \\ 3 & -1 & 1 \end{bmatrix} = \begin{bmatrix} 6.75 & -2.75 & 0.75 \\ -2.75 & 1.25 & -0.25 \\ 0.75 & -0.25 & 0.25 \end{bmatrix}

Inverse via Determinant

Inverse via Eigenvalues

Inverse via SVD