\documentclass[svgnames]{report}
\usepackage{pas-exos}
\usepackage{amsmath}
\usepackage{arydshln,fancybox}
%\usetikzlibrary{matrix}
\begin{document}
\chapter*{Gaussian elimination method}

Let the matrix :

\[ A=\begin{pmatrix}
2 & 0 & 1\\
-1 & 2 & 1\\
2 & 1 & -1
\end{pmatrix} = \left(a_{i,j}\right)
\]

We have to find the reverse of the matrix $A$. For this, we will use the Gauss method. this method is to append the identity matrix to $A$ :

\[
\left(\begin{array}{ccc:ccc}
2 & 0 & 1 & 1 & 0 & 0\\
-1 & 2 & 1 & 0 & 1 & 0\\
2 & 1 & -1 & 0 & 0 & 1
\end{array}\right)
\]

The objective is to obtain the identity matrix on the left.

\section*{Step 1 : we transform $\pmb{a_{1,1}}$ in \og 1 \fg}

For this, we divide the first line of $A$ by \og 2 \fg :

\renewcommand{\arraystretch}{1.5}

\[
\left(\begin{array}{ccc:ccc}
1 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0\\
-1 & 2 & 1 & 0 & 1 & 0\\
2 & 1 & -1 & 0 & 0 & 1
\end{array}\right)
\begin{array}{ll}
L_1 \leftarrow \frac{1}{2}L_1 & \color{red}\text{we indicate here the operation we perform on the line 1}
\\
\phantom{0} & 
\\
\phantom{0}&
\end{array}
\]

\section*{Step 2 : we transform $\pmb{a_{2,1}}$ and $\pmb{a_{3,1}}$ in \og 0 \fg}

For this, we set the first line as pivot and, from line we want to transform, we add $k$ times the pivot line.

\[
\left(\begin{array}{ccc:ccc}
1 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0\\
0 & 2 & \frac{3}{2} & \frac{1}{2} & 1 & 0\\
0 & 1 & -2 & -1 & 0 & 1
\end{array}\right)
\begin{array}{ll}
\phantom{0} & 
\\
L_2 \leftarrow L_2+L_1 & \color{red}\text{we add 1 times }L_1\text{ to } L_2\text{ to annulate } a_{2,1}
\\
L_3 \leftarrow L_3-2L_1 & \color{red}\text{we add }-2\text{ times }L_1\text{ to } L_3\text{ to annulate } a_{3,1}
\end{array}
\]

\section*{Step 3 : we transform $\pmb{a_{2,2}}$ in \og 1 \fg}

For this, we do like at \og Step 1 \fg{} : we divide the second line by \og 2 \fg.
\[
\left(\begin{array}{ccc:ccc}
1 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0\\
0 & 1 & \frac{3}{4} & \frac{1}{4} & \frac{1}{2} & 0\\
0 & 1 & -2 & -1 & 0 & 1
\end{array}\right)
\begin{array}{ll}
\phantom{0} & 
\\
L_2 \leftarrow \frac{1}{2}L_2 & \color{red}\text{we divide all numbers by \og 2 \fg}
\\
& 
\end{array}
\]

\section*{Step 4 : we transform $\pmb{a_{2,3}}$ in \og 0 \fg}

For this, we set the second line as pivot and, from the third line, we subtract the pivot line :
\[
\left(\begin{array}{ccc:ccc}
1 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0\\
0 & 1 & \frac{3}{4} & \frac{1}{4} & \frac{1}{2} & 0\\
0 & 0 & -\frac{11}{4} & -\frac{5}{4} & -\frac{1}{2} & 1
\end{array}\right)
\begin{array}{ll}
\phantom{0} & 
\\
& 
\\
L_3 \leftarrow L_3-L_2 & 
\end{array}
\]

\section*{Step 5 : we transform $\pmb{a_{3,3}}$ in \og 1 \fg}

For this, we divide the third line by $-\frac{11}{4}$ :

\[
\left(\begin{array}{ccc:ccc}
1 & 0 & \frac{1}{2} & \frac{1}{2} & 0 & 0\\
0 & 1 & \frac{3}{4} & \frac{1}{4} & \frac{1}{2} & 0\\
0 & 0 & 1 & \frac{5}{11} & \frac{2}{11} & -\frac{4}{11}
\end{array}\right)
\begin{array}{ll}
\phantom{0} & 
\\
& 
\\
L_3 \leftarrow -\frac{4}{11}L_3 & 
\end{array}
\]

\section*{Step 6 : we transform $\pmb{a_{3,2}}$ and $\pmb{a_{3,1}}$ in \og 0 \fg}

For this, we set the third line as pivot and, from the lines we want to transform, we add $k$ times the pivot line :

\[
\left(\begin{array}{ccc:ccc}
1 & 0 & 0 & \frac{3}{11} & -\frac{1}{11} & \frac{2}{11} \\
0 & 1 & 0 & -\frac{1}{11} & \frac{4}{11} & \frac{3}{11}\\
0 & 0 & 1 & \frac{5}{11} & \frac{2}{11} & -\frac{4}{11}
\end{array}\right)
\begin{array}{l}
L_1 \leftarrow L_1-\frac{1}{2}L_3
\\
L_2 \leftarrow L_2-\frac{3}{4}L_3
\\
\phantom{0}
\end{array}
\]

Here, $a_{2,1}$ is equal to \og 0 \fg ; therefore, we don't have to change this number and we obtain the identity matrix on the left.

If this number was not equal to \og 0 \fg, we should have to take the second line like pivot and subtract at the first line $a_{2,1}$ times of the pivot line to obtain $a_{2,1}=0$.

\medskip

We obtained the reverse of the matrix $A$ on the right :

\begin{center}
\color{blue!70!black} 
\shadowbox{
$A^{-1}=\dfrac{1}{11}\begin{pmatrix}3 & -1 & 2\\
-1 & 4 & 3\\
5 & 2 & -4
\end{pmatrix}$
}
\end{center}
\end{document}