I want to demonstrate examples of Gaussian elimination/the Gauss-Jordan method as shown below. There are some things that I like about what I have right now.
- Each column is the same width from array to array.
- The notation for row operations is consistent with the textbook that I am using.
- There is a clear break between steps.
- I don't have to do a huge amount of manual tuning.
However, there are also a few things that I would like to change.
- Having to use \\[3pt] instead of just \\ to make sure that the spacing is consistent, and fractions on adjacent lines do not crash into one another.
- In a long example (like the one below), the sequence of steps cannot break across a page, which causes the array to run off the bottom of the page unless I manually insert a break (which may mess up the consistent column widths).
- The hackish way in which the horizontal lines between matrices are obtained.
- I usually prefer to use brackets around my matrices.
- The right border is implemented in a very hackish way.
Any advice on how to implement these changes while maintaining the aspects that I like would be greatly appreciated. I am aware of the gauss
package, but I'm not sure if I can use it to get things in the "like" list.
\documentclass{article}
\begin{document}
\[
\begin{array}{rr@{}|rrrrrrr|l}
& & 2 & 1 & 1 & 3 & 0 & 4 & 1
& \frac{1}{2} R_{1}
\\[3pt]
& & 4 & 2 & 4 & 4 & 1 & 5 & 5
\\[3pt]
& & 2 & 1 & 3 & 1 & 0 & 4 & 3
\\[3pt]
& & 6 & 3 & 4 & 8 & 1 & 9 & 5
\\[3pt]
& & 0 & 0 & 3 & -3 & 0 & 0 & 3
\\[3pt]
& & 8 & 4 & 2 & 14 & 1 & 13 & 3
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & \frac{1}{2} & \frac{3}{2} & 0 & 2 & \frac{1}{2}
\\[3pt]
& & 4 & 2 & 4 & 4 & 1 & 5 & 5
& R_{2} - 4 R_{1}
\\[3pt]
& & 2 & 1 & 3 & 1 & 0 & 4 & 3
& R_{3} - 2 R_{1}
\\[3pt]
& & 6 & 3 & 4 & 8 & 1 & 9 & 5
& R_{4} - 6 R_{1}
\\[3pt]
& & 0 & 0 & 3 & -3 & 0 & 0 & 3
\\[3pt]
& & 8 & 4 & 2 & 14 & 1 & 13 & 3
& R_{6} - 8 R_{1}
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & \frac{1}{2} & \frac{3}{2} & 0 & 2 & \frac{1}{2}
\\[3pt]
& & 0 & 0 & 2 & -2 & 1 & -3 & 3
& \frac{1}{2} R_{2}
\\[3pt]
& & 0 & 0 & 2 & -2 & 0 & 0 & 2
\\[3pt]
& & 0 & 0 & 1 & -1 & 1 & -3 & 2
\\[3pt]
& & 0 & 0 & 3 & -3 & 0 & 0 & 3
\\[3pt]
& & 0 & 0 & -2 & 2 & 1 & -3 & -1
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & \frac{1}{2} & \frac{3}{2} & 0 & 2 & \frac{1}{2}
& R_{1} - \frac{1}{2} R_{2}
\\[3pt]
& & 0 & 0 & 1 & -1 & \frac{1}{2} & -\frac{3}{2} & \frac{3}{2}
\\[3pt]
& & 0 & 0 & 2 & -2 & 0 & 0 & 2
& R_{3} - 2 R_{2}
\\[3pt]
& & 0 & 0 & 1 & -1 & 1 & -3 & 2
& R_{4} - R_{2}
\\[3pt]
& & 0 & 0 & 3 & -3 & 0 & 0 & 3
& R_{5} - 3 R_{2}
\\[3pt]
& & 0 & 0 & -2 & 2 & 1 & -3 & -1
& R_{6} + 2 R_{2}
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & 0 & 2 & -\frac{1}{4} & \frac{11}{4} & -\frac{1}{4}
\\[3pt]
& & 0 & 0 & 1 & -1 & \frac{1}{2} & -\frac{3}{2} & \frac{3}{2}
\\[3pt]
& & 0 & 0 & 0 & 0 & -1 & 3 & -1
& -R_{3}
\\[3pt]
& & 0 & 0 & 0 & 0 & \frac{1}{2} & -\frac{3}{2} & \frac{1}{2}
\\[3pt]
& & 0 & 0 & 0 & 0 & -\frac{3}{2} & \frac{9}{2} & -\frac{3}{2}
\\[3pt]
& & 0 & 0 & 0 & 0 & 2 & -6 & 2
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & 0 & 2 & -\frac{1}{4} & \frac{11}{4} & -\frac{1}{4}
& R_{1} + \frac{1}{4} R_{3}
\\[3pt]
& & 0 & 0 & 1 & -1 & \frac{1}{2} & -\frac{3}{2} & \frac{3}{2}
& R_{2} - \frac{1}{2} R_{3}
\\[3pt]
& & 0 & 0 & 0 & 0 & 1 & -3 & 1
\\[3pt]
& & 0 & 0 & 0 & 0 & \frac{1}{2} & -\frac{3}{2} & \frac{1}{2}
& R_{4} - \frac{1}{2} R_{3}
\\[3pt]
& & 0 & 0 & 0 & 0 & -\frac{3}{2} & \frac{9}{2} & -\frac{3}{2}
& R_{5} + \frac{3}{2} R_{3}
\\[3pt]
& & 0 & 0 & 0 & 0 & 2 & -6 & 2
& R_{6} - 2 R_{3}
\\ \\[-1em] \hline \\[-1em]
%%%%%%%%%%%%%%%%%%%%%%%%%
& & 1 & \frac{1}{2} & 0 & 2 & 0 & 2 & 0
\\[3pt]
& & 0 & 0 & 1 & -1 & 0 & 0 & 1
\\[3pt]
& & 0 & 0 & 0 & 0 & 1 & -3 & 1
\\[3pt]
& & 0 & 0 & 0 & 0 & 0 & 0 & 0
\\[3pt]
& & 0 & 0 & 0 & 0 & 0 & 0 & 0
\\[3pt]
& & 0 & 0 & 0 & 0 & 0 & 0 & 0
\end{array}
\]
\end{document}