[MMD]
Linear Algebra Basics Chapter 2: Elimination, Row Echelon Form, and Gaussian Elimination
In Chapter 1 we covered the concept of linear equation systems, matrix singularity, and determinants. This post focuses on actually solving those systems — starting from elimination, moving through row echelon forms, Gaussian elimination, and Rank.
This post is based on Week 1 of DeepLearning.AI's Mathematics for Machine Learning and Data Science.
What You'll Learn#
- Solving linear systems with Elimination
- Using Matrix Row Reduction to express the same process in matrix form
- Computing Row Echelon Form (REF) and Reduced Row Echelon Form (RREF)
- Finding Rank and using it to determine how many solutions a system has
Solving a Non-Singular System — Elimination#
Elimination works by combining equations to cancel out variables one at a time.
Example:
If both equations are true, then any sum or difference of them is also true.
Step 1 — Add the two equations:
Step 2 — Substitute :
Verify: ✓, ✓
Core principle: If an equation is true, then any linear combination of it — sums, differences, or scalar multiples — is also true. This is the mathematical foundation of elimination.
Solving Singular Systems#
1 Degree of Freedom — Infinitely Many Solutions#
Subtracting twice equation 1 from equation 2:
This is an identity — always true. Both equations carry the same information, so can be any value and follows along.
This is called 1 degree of freedom — there is one variable we can freely choose.
No Solution — Inconsistent System#
Subtracting twice equation 1 from equation 2:
This is a contradiction. The system has no solution.
Systems with More Variables#
The same principle applies to three-variable systems.
Step 1 — Eliminate from rows 2 and 3 using row 1:
- :
- :
Step 2 — Substitute :
Step 3 — Back substitution:
Solution:
Matrix Row Reduction#
The same process can be expressed using matrices instead of equations.
Apply row operation ():
This form is Row Echelon Form (REF). From here, , then .
Reduced Row Echelon Form (RREF) goes one step further — each variable is fully isolated:
Row Echelon Form of a Singular System#
For a singular system, elimination produces an all-zero row.
The second row is entirely zero, indicating infinitely many solutions (1 degree of freedom).
The 3 Rules of Row Echelon Form#
A matrix is in Row Echelon Form (REF) if:
- Each pivot (diagonal element) is 0 or 1
- Everything below the diagonal is 0
- Everything above the diagonal:
- Can be any value if the pivot is 1
- Must be 0 if the pivot is 0
| REF | RREF | |
|---|---|---|
| Below diagonal | 0 | 0 |
| Above diagonal | free | 0 |
| Diagonal (pivot) | 0 or 1 | 0 or 1 |
Row Operations That Preserve Singularity#
The operations applied to equations can be applied equally to matrix rows. Crucially, these operations do not change the singularity of the matrix.
| Operation | Example | Preserves singularity? |
|---|---|---|
| Swap two rows | ✅ Yes | |
| Add one row to another | ✅ Yes | |
| Multiply a row by a scalar | ✅ Yes | |
| Add a constant to all elements of a row | ❌ No |
Note: Adding a fixed constant to every element of a row is not a valid row operation — it can change the singularity of the matrix.
Matrix Rank#
Rank represents the amount of independent information a matrix contains.
- After converting to REF, the number of non-zero rows equals the rank
- Equivalently: the maximum number of linearly independent rows
Rank and the Number of Solutions#
For an matrix ( variables, equations):
| Rank | Number of solutions | System type |
|---|---|---|
| Exactly 1 | Non-singular | |
| 0 or infinitely many | Singular |
Gaussian Elimination#
Gaussian elimination is a systematic algorithm that applies row operations to an augmented matrix — the coefficient matrix combined with the constants column — to solve a system.
Step-by-Step Example#
Augmented matrix:
Step 1 — , :
Step 2 — :
Row Echelon Form (REF) is now complete.
Step 3 — Back Substitution:
Algorithm summary: Forward elimination builds the REF → Back substitution yields the solution.
Key Concepts Summary#
| Concept | Description |
|---|---|
| Elimination | Add or subtract equations to cancel out variables |
| Row Echelon Form (REF) | Intermediate matrix form with zeros below the diagonal |
| Reduced Row Echelon Form (RREF) | Fully solved form with zeros both above and below the diagonal |
| Rank | Number of non-zero rows = amount of independent information |
| Gaussian Elimination | Systematic method applying row operations to an augmented matrix |
| Degrees of Freedom | Number of freely choosable variables (in a singular system) |
Quiz#
Q1. Solve the following system using elimination.
Show answer
:
Solution:
Q2. Convert the following matrix to Row Echelon Form (REF) and find its rank.
Show answer
:
(swap rows):
There are 2 non-zero rows, so rank = 2 (singular matrix).
Q3. Which of the following operations does NOT preserve the singularity of a matrix?
- Swap two rows
- Add one row to another
- Add 5 to every element in a row
- Multiply a row by 3
Show answer
Option 3 — Adding a fixed constant to all elements of a row is not a valid equation operation and can change the singularity of the matrix.
Options 1, 2, and 4 are all valid row operations that preserve singularity.
Q4. Determine the rank and solution type for the following system.
Show answer
Augmented matrix:
After applying and :
rank = 1, degrees of freedom = 1 → Infinitely many solutions (singular system)
All three equations carry the same information.
In the next post, we'll cover vector operations (addition, subtraction, dot product, norm), linear transformations, matrix multiplication, matrix inverses, and how all of this connects to neural networks (perceptrons).
// Related Posts
Probability & Statistics in Practice: Inference Problems from the ML Trenches
From probability fundamentals and Bayes' theorem to distributions, MLE/MAP, confidence intervals, and hypothesis testing — a collection of practice problems grounded in real ML and data analysis scenarios.
Probability & Statistics Coding Assignments: Building ML Statistical Tools in Python
Bayesian updates, distribution simulation, CLT verification, MLE/MAP implementation, confidence intervals, hypothesis testing, and a full A/B test pipeline — implementing probability & statistics chapters 1–4 in code.
ML Probability & Statistics Chapter 4: Confidence Intervals and Hypothesis Testing
A complete guide to confidence intervals, the t-distribution, hypothesis testing fundamentals (null/alternative hypotheses, p-values, rejection regions, statistical power), various t-tests, and A/B testing.