Given the matrix
$$ A=\left(\begin{array}{crc} 1 & 1 & 3\\ 3 & 0 & 1\\ 1 & -2 & 1 \end{array}\right) $$Find the inverse of $A$ by Gauss-Jordan method.
As in Gauss Elimination, Gauss-Jordan performs the following row reduction operations
And also
The method is similar to Gauss but the zeros are made above and below the pivot.
Now the objective is to go from any system to an equivalent diagonal system (non-zero elements only on the diagonal), which gives us the solution directly. For example, the equivalent diagonal system
And the solution is direct $$ x = 0 \quad y = 1 \quad z = -1 $$
To solve a single system, the Gaussian method is more efficient from the point of view of the number of operations. But when we solve several systems simultaneously with the same coefficient matrix, Gauss-Jordan can be more efficient. This is the case for the computation of the inverse matrix.
The inverse matrix of an $n\times n$ matrix $A$, if it exists, is a $n\times n$ matrix that we will call $A^{-1}$ that verifies
That is
By the definition of the product of matrices, we can write
That is, the columns of the inverse matrix are the solutions of these $n$ linear systems that share the same matrix of coefficients. Therefore, if we solve all these systems simultaneously and write the augmented matrix
And we perform row operations so that the equivalent matrix is the diagonal identity matrix. The solutions will be the columns of the inverse matrix.
We can summarize the process as
We write the matrix $\left[A|I\right]$. As the pivot is $\mathbf{{\color{red}1}}$ we left it as it is. We make zeros below the pivot in the first column.
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} {\mathbf{{\color{red}1}}} & 1 & 3 & 1 & 0 & 0\\ \mathbf{\color{blue}3} & 0 & 1 & 0 & 1 & 0\\ \mathbf{\color{ForestGreen}1} & -2 & 1 & 0 & 0 & 1 \end{array}\right) \begin{array}{rrl} r_{1}\\ r_{2} & = & r_{2}-\mathbf{\color{blue}3}r_{1}\\ r_3 & = & r_{3}-\mathbf{\color{ForestGreen}1}r_{1} \end{array} $$Now the pivot is $\mathbf{{\color{red}{-3}}}$ and to convert it into $1$ we divide its row by it.
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} 1 & \mathbf{\color{blue}1} & 3 & 1 & 0 & 0\\ 0 & \mathbf{\color{red}{-3}} & -8 & -3 & 1 & 0\\ 0 & \mathbf{\color{ForestGreen}{-3}} & -2 & -1 & 0 & 1 \end{array}\right) \begin{array}{rrl} & &\\ r_{2} & = & r_{2}/(\mathbf{\color{red}{-3}})\\ & & \end{array} $$We make zeros above and below the pivot $\mathbf{{\color{red}{1}}}$.
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} 1 & \mathbf{\color{blue}1} & 3 & 1 & 0 & 0\\ 0 & \mathbf{\color{red}{1}} & 8/3 & 1 & -1/3 & 0\\ 0 & \mathbf{\color{ForestGreen}{-3}} & -2 & -1 & 0 & 1 \end{array}\right) \begin{array}{rrl} r_{1} & = & r_{1}-\mathbf{\color{blue}1}r_{2}\\ r_{2}\\ r_3 & = & r_{3}-(\mathbf{\color{ForestGreen}{-3}})r_{2} \end{array} $$Now the pivot is $\mathbf{{\color{red}{6}}}$ and to convert it to $1$ we divide its row by its value.
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} 1 & 0 & \mathbf{\color{blue}{1/3}} & 0 & 1/3 & 0\\ 0 & 1 & \mathbf{\color{ForestGreen}{8/3}} & 1 & -1/3 & 0\\ 0 & 0 & \mathbf{\color{red}6} & 2 & -1 & 1 \end{array}\right) \begin{array}{rrl} & &\\ & &\\ r_{3} & = & r_{3}/(\mathbf{\color{red}{6}}) \end{array} $$We make zeros above the pivot $\mathbf{{\color{red}{1}}}$.
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} 1 & 0 & \mathbf{\color{blue}{1/3}} & 0 & 1/3 & 0\\ 0 & 1 & \mathbf{\color{ForestGreen}{8/3}} & 1 & -1/3 & 0\\ 0 & 0 & \mathbf{\color{red}1} & 1/3 & -1/6 & 1/6 \end{array}\right) \begin{array}{rrl} r_{1} & = & r_{1}-(\mathbf{\color{blue}{1/3}})\,r_{3}\\ r_{2}& = & r_{2}-(\mathbf{\color{ForestGreen}{8/3}})\,r_{3}\\ r_3 \end{array} $$And we already have the identity matrix $I$ on the left
$$ \begin{array}{c} r_{1}\\ r_{2}\\ r_{3} \end{array}\left(\begin{array}{rrr|rrr} 1 & 0 & 0 & -1/9 & 7/18 & -1/18\\ 0 & 1 & 0 & 1/9 & 1/9 & -4/9\\ 0 & 0 & 1 & 1/3 & -1/6 & 1/6 \end{array}\right) $$Since we already have the matrix $I$ on the left, the matrix on the right will be $A^{-1}$.
$$ A^{-1} = \left(\begin{array}{rrr} -1/9 & 7/18 & -1/18\\ 1/9 & 1/9 & -4/9\\ 1/3 & -1/6 & 1/6 \end{array}\right) $$