How to Do Gaussian Elimination by Hand
Solve a linear system by hand with Gaussian elimination: build the augmented matrix, clear below each pivot, swap on a zero pivot, back-substitute.
How to Do Gaussian Elimination: The Manual Procedure for an Exam
To learn how to do gaussian elimination for an exam, you need exactly three row operations applied in a fixed order until the augmented matrix is in row echelon form (REF). Then you back-substitute. That is the entire procedure. Strang's Introduction to Linear Algebra (ch. 2) defines REF and the three operations: swap two rows, multiply a row by a non‑zero constant, add a multiple of one row to another. The OpenStax and LibreTexts linear algebra texts use the same notation and are free online. The method is O(n³) operations for an n×n matrix, which is why a 5×5 system is the practical limit for hand calculation.
Step 1: Write the Augmented Matrix
Given a system of linear equations, write the coefficients of each variable in a rectangular array. Append the constants as a final column separated by a vertical bar. This [A|b] notation is universal. Each row represents one equation, each column before the bar represents one variable (usually x, y, z in order), and the last column is the right-hand side.
Example: for the system
2x + 3y = 5
4x − y = 1
the augmented matrix is
[ 2 3 | 5 ]
[ 4 −1 | 1 ].
Step 2: Forward Elimination, Choose a Pivot and Clear the Column Below
The pivot is the first non-zero entry in the current row. Start with the top-left entry. If it is zero, swap rows to bring a non-zero entry into that position, this is covered in the next section. Once the pivot is non-zero, use row addition to create zeros below it. For each row below, subtract (entry in pivot column ÷ pivot) times the pivot row from that row.
Move to the second column, second row, and repeat. Continue until the matrix is in row echelon form: each pivot is to the right of the pivot above it, and all entries below each pivot are zero. This is called forward elimination. The number of pivots equals the rank of the matrix (Strang, ch. 2).
Step 3: When the Pivot Is Zero, Swap Rows
A zero pivot stops the algorithm. You must swap the current row with a row below that has a non-zero entry in the pivot column. If no such row exists, the matrix is singular and the system has either no solution or infinite solutions.
Partial pivoting selects the row with the largest absolute value in the pivot column and swaps it into the pivot position (Burden & Faires, Numerical Analysis, section on pivoting strategies). This reduces floating-point error, though for hand calculation any non-zero pivot works.
Example of a zero pivot that forces a swap:
[ 0 2 | 4 ]
[ 1 3 | 5 ]
Swap Row1 and Row2 to obtain
[ 1 3 | 5 ]
[ 0 2 | 4 ].
Step 4: Back Substitution
Once the matrix is in row echelon form, solve from the last row upward. The last row gives the value of the last variable directly (or a relation). Substitute that value into the row above and solve for the next variable, working upward until all variables are determined.
Back substitution propagates round-off errors from the last pivot, so keep fractions in simplest form and avoid decimal approximations until the final answer.
Worked 2×2 Example
Solve:
2x + 3y = 5
4x − y = 1
Augmented matrix:
[ 2 3 | 5 ]
[ 4 −1 | 1 ]
Forward elimination: Pivot is 2 at (1,1). To clear below, replace Row2 with Row2 − 2×Row1.
Row2 new: (4−4) = 0, (−1−6) = −7, (1−10) = −9.
Matrix becomes:
[ 2 3 | 5 ]
[ 0 −7 | −9 ]
Back substitution: From Row2: −7y = −9 → y = 9/7.
Row1: 2x + 3(9/7) = 5 → 2x = 5 − 27/7 = 8/7 → x = 4/7.
Solution: x = 4/7, y = 9/7.
Worked 3×3 Example
Solve:
x + y + z = 6
2x − y + z = 3
3x + 2y − z = 4
Augmented matrix:
[ 1 1 1 | 6 ]
[ 2 −1 1 | 3 ]
[ 3 2 −1 | 4 ]
Forward elimination, first column: Pivot is 1 at (1,1).
Row2 = Row2 − 2×Row1 → [0 −3 −1 | −9]
Row3 = Row3 − 3×Row1 → [0 −1 −4 | −14]
Forward elimination, second column: Pivot is −3 at (2,2). To avoid fractions, use Row3 = 3×Row3 − Row2.
New Row3: [0 0 −11 | −33]
Back substitution:
Row3: −11z = −33 → z = 3
Row2: −3y − z = −9 → −3y = −9 + 3 = −6 → y = 2
Row1: x + y + z = 6 → x = 6 − 2 − 3 = 1
Solution: x = 1, y = 2, z = 3.
Worked Zero-Pivot Example with Row Swap
Solve:
y + 2z = 5
2x + 4y + 6z = 18
x + 3y + z = 7
Augmented matrix:
[ 0 1 2 | 5 ]
[ 2 4 6 | 18 ]
[ 1 3 1 | 7 ]
First pivot is zero at (1,1). Swap Row1 with Row2 (partial pivoting chooses Row2 because 2 has the largest absolute value in column 1).
New matrix:
[ 2 4 6 | 18 ]
[ 0 1 2 | 5 ]
[ 1 3 1 | 7 ]
Forward elimination, first column: Pivot is 2. Clear below: Row3 = Row3 − (1/2)×Row1 → [0 1 −2 | −2]
Second column: Pivot is 1 at (2,2) (non-zero). No swap needed. Clear below: Row3 = Row3 − Row2 → [0 0 −4 | −7]
Back substitution:
Row3: −4z = −7 → z = 7/4
Row2: y + 2(7/4) = 5 → y = 5 − 7/2 = 3/2
Row1: 2x + 4(3/2) + 6(7/4) = 18 → 2x + 6 + 10.5 = 18 → 2x = 1.5 → x = 3/4
Solution: x = 3/4, y = 3/2, z = 7/4.
Checking Your Answer
Substitute the solution into the original equations. If all equations balance, the solution is correct. For the 2×2 example: 2(4/7) + 3(9/7) = 8/7 + 27/7 = 35/7 = 5 ✓; 4(4/7) − 9/7 = 16/7 − 9/7 = 7/7 = 1 ✓.
For larger systems, you can verify by matrix multiplication: compute A·x and compare to b. This is what LAPACK routine dgesv does internally after the LU decomposition with partial pivoting (LAPACK documentation).
Common Mistakes Checklist
- Dividing by a zero pivot, Always check for zero before using a pivot. Swap rows if needed.
- Forgetting the constant column, Every row operation must be applied to the full augmented row, including the constant. Missing the constant is the most common error.
- Sign errors in row addition, When subtracting a multiple of the pivot row, double-check signs. Write the operation explicitly: Rownew = Rowold − (factor)×Rowpivot.
- Mishandling fractions, Keep fractions in simplest form. Rounding early introduces error that propagates through back substitution.
- Misidentifying solution types, A row of zeros on the left with a non-zero constant (0 = c) means no solution. A row of zeros with zero constant means infinite solutions if there are free variables (Strang, ch. 2).
What Most Often Goes Wrong
The single most common failure in Gaussian elimination is applying a row operation to only part of the row, usually the coefficient side but not the constant. Every operation must apply to the entire augmented row. A close second is forgetting that a zero pivot forces a row swap; without it, the algorithm divides by zero. The Nine Chapters on the Mathematical Art (circa 179 CE, Grcar, 2011) describes this method without modern notation, and the same two errors appear in student work today. Keep fractions, swap zeros, and check every row operation against the full row.
Common Questions
When do I stop forward elimination and start back substitution?
Stop when the matrix is in row echelon form: each pivot is to the right of the pivot above it, and all entries below each pivot are zero. This is the visual cue, the matrix has a staircase pattern of non-zero pivots with zeros beneath.
What does a parametric solution look like for a 3×3 system with one free variable?
If a column has no pivot, the corresponding variable is free. For example, if the third column has no pivot, set z = t (a free parameter). Express the basic variables (x and y) in terms of t using back substitution. The solution is written as (x, y, z) = (expression, expression, t).
Can I use Gaussian elimination on a rectangular system, like 2 equations with 3 unknowns?
Yes. The augmented matrix will be 2×4 (2 rows, 3 variable columns plus the constant). Forward elimination proceeds the same way. The system will be underdetermined and will have at least one free variable, giving infinite solutions.
Why does my calculator give a different answer than my textbook?
If the calculator uses decimal approximations and the textbook uses exact fractions, rounding can cause slight differences. For a 5×5 hand-check, use fractions throughout. Scientific calculators that support rational arithmetic avoid this issue.
What is the exact step where partial pivoting changes the answer?
Partial pivoting swaps rows when the pivot is zero or very small. It changes the order of equations but not the solution. The change appears as a row swap step in the elimination output, before the pivot is used to clear below.