We can readily solve systems with triangular coefficient matrices.
Guiding philosophy: Use a sequence of moves to transform an arbitrary system into a system with an upper triangular coefficient matrix, without changing the solution set.
Think of Gaussian elimination as a game in which you make an ERO at each turn and the goal is to end up with an upper triangular system.
In two steps, we obtain an upper triangular system that we can easily solve using backward substitution.
In general, we may proceed by clearing out one column at a time, from left to right.
\begin{algorithm}
\caption{Gaussian Elimination on $A x = b$}
\begin{algorithmic}
\FOR{$k \gets 1$ to $n-1$}
\FOR{$i \gets k+1$ to $n$}
\STATE {$l_{ik} \gets a_{ik}/a_{kk}$}
\FOR{$j \gets k+1$ to $n$}
\STATE{$a_{ij} \gets a_{ij} - l_{ik}a_{kj}$}
\ENDFOR
\STATE{$b_i \gets b_i - l_{ik}b_k$}
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Gaussian Elimination on $A x = b$}
\begin{algorithmic}
\FOR{$\color{var(--emphColor)}{k \gets 1 \text{ to } n-1}$}
\FOR{$i \gets k+1$ to $n$}
\STATE {$l_{ik} \gets a_{ik}/a_{kk}$}
\FOR{$j \gets k+1$ to $n$}
\STATE{$a_{ij} \gets a_{ij} - l_{ik}a_{kj}$}
\ENDFOR
\STATE{$b_i \gets b_i - l_{ik}b_k$}
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Gaussian Elimination on $A x = b$}
\begin{algorithmic}
\FOR{$k \gets 1 \text{ to } n-1$}
\FOR{$\color{var(--emphColor)}{i \gets k+1 \text{ to } n}$}
\STATE {$l_{ik} \gets a_{ik}/a_{kk}$}
\FOR{$j \gets k+1$ to $n$}
\STATE{$a_{ij} \gets a_{ij} - l_{ik}a_{kj}$}
\ENDFOR
\STATE{$b_i \gets b_i - l_{ik}b_k$}
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
\begin{algorithm}
\caption{Gaussian Elimination on $A x = b$}
\begin{algorithmic}
\FOR{$k \gets 1 \text{ to } n-1$}
\FOR{$i \gets k+1 \text{ to } n$}
\STATE {$l_{ik} \gets a_{ik}/a_{kk}$}
\FOR{$\color{var(--emphColor)}{j \gets k+1 \text{ to } n}$}
\STATE{$a_{ij} \gets a_{ij} - l_{ik}a_{kj}$}
\ENDFOR
\STATE{$b_i \gets b_i - l_{ik}b_k$}
\ENDFOR
\ENDFOR
\end{algorithmic}
\end{algorithm}
Try your hand on the Gaussian elimination warm-up problems on HW2!
The following table counts the number of floating point operations required by our Gaussian elimination pseudocode.