Neural Sync Active
Gaussian Elimination: Solving Linear Systems
Registry Synced
Gaussian Elimination: Solving Linear Systems
3868 words
19 min read
Reading compass
Now · 🎯 Learning Objectives
Gaussian Elimination: Solving Linear Systems
🎯 Learning Objectives
After this topic you will be able to:
- Identify row echelon form (REF) and reduced row echelon form (RREF)
- Perform the three elementary row operations
- Carry out Gaussian elimination to transform any matrix to REF
- Carry out Gauss-Jordan elimination to transform any matrix to RREF
- Determine whether a linear system has zero, one, or infinitely many solutions
- Express solution sets in parametric form using free variables
- Compute the rank of a matrix from its RREF
📋 Prerequisites
- Matrices Introduction (Week 1) — matrix notation, matrix-vector multiplication
- Determinants (Week 1) — testing invertibility
- Vectors Introduction (Week 1) — column vectors and linear combinations
- Gaussian elimination is the master algorithm of linear algebra — it underlies finding bases, ranks, null spaces, and inverses
1. The Problem: Solving Ax=b
1.1 Intuition: From Messy to Clean
Imagine you have a system of equations. The equations are messy — coefficients everywhere. We want to transform them into something clean where the solution is obvious.
Row operations are like legal algebraic moves (swap equations, multiply an equation by a non-zero constant, add a multiple of one equation to another). They don't change the solution set.
We systematically apply these moves until the system is in a form we can read the answer from directly.
(Diagram)
2. Row Echelon Form (REF)
2.1 Definition
A matrix is in row echelon form if:
- All non-zero rows are above any zero rows
- The leading (first non-zero) entry of each row is to the right of the leading entry in the row above
- All entries below a leading entry are zero The leading entry (or pivot) is the first non-zero element in a row. In REF, pivots are typically normalised to 1 for convenience (though the definition doesn't require it).
2.2 Examples
✓ REF (correct):
✗ Not REF (violation):
2.3 Reduced Row Echelon Form (RREF)
100200010720A matrix is in RREF if it is in REF and additionally:
- The leading entry in each non-zero row is 1
- Each leading 1 is the only non-zero entry in its column ✓ RREF (correct):
3. Elementary Row Operations
There are exactly three operations that preserve the solution set:
| Operation | Notation | Example | Effect |
|---|---|---|---|
| Swap | Ri↔Rj | Swap rows 1 and 2 | Changes order |
| Scale | Ri→cRi , c=0 | Multiply row 2 by 31 | Simplifies entries |
| Add multiple | Ri→Ri+cRj | R2→R2−2R1 | Eliminates entries |
Key insight: Adding a multiple of one row to another preserves the determinant. Swapping flips its sign. Scaling scales the determinant by c.
4. Gaussian Elimination Algorithm
4.1 Forward Elimination (to REF)
Given an m×n matrix A:
- Start with the leftmost non-zero column (pivot column)
- Find a pivot: select a non-zero entry in this column. If none exists, move to the next column
- Swap (if needed): bring the pivot row to the top
- Scale (optional): make the pivot 1
- Eliminate below: use row operations to create zeros below the pivot
- Repeat: ignore the pivot row and repeat steps 1-5 on the remaining submatrix
>⎩⎨⎧x+2y+z=82x+4y−z=−13x+2y−2z=−1>Example 1: Gaussian elimination (3 equations, 3 unknowns)Solve:
>1232421−1−28−1−1>Augmented matrix:
>R2→R2−2R1,R3→R3−3R1>Step 1: Already have pivot (1,1)=1.Step 2: Eliminate column 1 below pivot:
>10020−41−3−58−17−25>
>1002−401−5−38−25−17>Step 3: Next pivot is in column 2. Row 2 has a 0 in column 2, so swap R2↔R3:
>R2→−41R2,R3→−31R3>Step 4: Scale pivots (optional but helpful):
>10021014518425317>
Step 5: Back substitution. From row 3: z=317.From row 2: y+45z=425⇒y=425−45⋅317=1275−85=−1210=−65From row 1: x+2y+z=8⇒x=8−2(−65)−317=8+35−317=324+35−317=312=4Solution: x=4, y=−65, z=317.
4.2 Gauss-Jordan Elimination (to RREF)
Instead of stopping at REF and back-substituting, we continue eliminating above each pivot to get RREF:
- Perform forward elimination (to REF)
- Scale each row so pivots are 1
- Eliminate upward: for each pivot, use row operations to create zeros above it
>10021014518425317>Example 2: Gauss-Jordan (same system)Start from REF:
>R2→R2−45R3,R1→R1−R3>Step 1: Eliminate above pivot in column 3:
>10021000137−65317>
>R1→R1−2R2>Step 2: Eliminate above pivot in column 2:
>1000100014−65317>
Solution is now read directly from the RREF: x=4,y=−65,z=317.
5. Three Cases for Solution Sets
A linear system can have:
| Case | Condition | RREF Pattern | Example in R2 |
|---|---|---|---|
| Unique solution | rank = number of variables | Every column (except last) has a pivot | Two intersecting lines |
| No solution | A row like $[0;0;\dots;0; | ;c] with c \neq 0$ | Inconsistent row |
| Infinitely many solutions | rank < number of variables | At least one column without a pivot (free variable) | Two coincident lines |
Rank = number of non-zero rows (pivots) in RREF.
5.1 Case 1: Unique Solution (already seen in Example 1)
5.2 Case 2: No Solution (Inconsistent)
>{x+y=22x+2y=5>Example 3: Inconsistent system
>[121225]R2→R2−2R1[101021]>Augmented matrix and row reduction:
Row 2 says 0x+0y=1, which is impossible. No solution.
5.3 Case 3: Infinitely Many Solutions
>{x+2y−z=12x+4y−2z=2>Example 4: Infinitely many solutions
>[1224−1−212]R2→R2−2R1[1020−1010]>Augmented matrix:
>[1020−1010]>RREF:
>xyz=100+y−210+z101>Columns 1 and 3 have pivots? Actually column 2 has no pivot (free variable). Column 1 has pivot. Column 3 has no pivot.Wait — let me re-check. We have pivots in column 1 only. So columns 2 and 3 are free.Solution: x=1−2y+z, where y,z are free variables (can be any real number).In parametric vector form:
6. Rank of a Matrix
rank(A)=number of pivotsDefinition (Rank). The rank of a matrix A is the number of non-zero rows in its RREF (equivalently, the number of pivots).
Properties:
- rank(A)≤min(m,n) for Am×n
- rank(A)=rank(AT)
- rank(A)=dim(column space of A)
- rank(AB)≤min(rank(A),rank(B))
>A=123246369R2−2R1,R3−3R1100200300>Example 5: Finding rank
Rank = 1 (only one pivot).
7. Homogeneous Systems (Ax=0)
Definition (Homogeneous). A system Ax=0 (all right-hand sides are zero) is homogeneous. Key facts:
- Always has at least the trivial solution x=0
- Has non-trivial solutions iff there is at least one free variable (i.e., rank < number of columns)
- The solution set is a vector space (the null space of A)
>{x+2y−z=02x+4y+z=0>Example 6: Homogeneous system
>[1224−11]R2−2R1[1020−13]31R2[1020−11]>
>R1+R2[102001]>
>xyz=y−210>Pivots in columns 1 and 3. Column 2 is free.x=−2y, z=0, y free.Solution:
.
8. Algorithm Summary
(Diagram)
9. Edge Cases & Gotchas
| Situation | What Happens |
|---|---|
| Pivot is zero | Need to swap with a row below; if none, move to next column |
| All-zero row in coefficient matrix | Either redundant (consistent) or impossible (inconsistent depending on RHS) |
| Free variables | Indicate infinitely many solutions; parameterise them |
| **Rectangular matrix m<n ** | Always have free variables (more unknowns than equations) |
| Numerical precision | Floating-point arithmetic can create near-zero pivots; use partial pivoting |
10. Common Pitfalls
❌ Pitfall 1: Arithmetic errors in elimination
Track every operation carefully. Use fractions or rational arithmetic. Double-check that Ri→Ri+cRj (adding c times row j to row i) leaves row j unchanged.
❌ Pitfall 2: Forgetting to apply operations to the RHS
When working with the augmented matrix, every row operation affects both the coefficient matrix and the right-hand side.
❌ Pitfall 3: Misidentifying free variables after Gauss-Jordan
In RREF, a column without a pivot (except the last column) corresponds to a free variable. The pivot columns are basic variables.
❌ Pitfall 4: Thinking REF requires pivots to be 1
REF does not require leading entries to be 1 (RREF does). Many textbooks normalise to 1 during forward elimination for convenience.
11. Formula Summary Table
| Concept | Description |
|---|---|
| REF | Each pivot right of previous pivot; zeros below pivots |
| RREF | REF + pivots are 1 + zeros above and below |
| Elementary row ops | Swap, scale ( c=0 ), add multiple of another row |
| Rank | Number of pivots (non-zero rows in RREF) |
| Free variables | Columns without pivots (≠ last column) |
| Homogeneous system | Ax=0 ; always at least trivial solution |
| Inconsistent system | Row of $[0;\dots;0; |
12. 📝 Practice Questions
>{x+y=32x−y=0>Q1: Simple elimination (unique solution)Solve using Gaussian elimination:
>[121−130]R2−2R1[101−33−6]>Strategy: Augmented matrix → REF → back substitute.Solution:
>{x+2y=52x+4y=9>From R2: −3y=−6⇒y=2. From R1: x+2=3⇒x=1.Solution: x=1, y=2. Q2: Inconsistent systemSolve:
>[122459]R2−2R1[10205−1]>Strategy: Check for inconsistency.Solution:
>{x+y−2z=12x+2y−4z=2>Row 2: 0x+0y=−1 — impossible. No solution. Q3: Infinitely many solutionsSolve:
>[1212−2−412]R2−2R1[1010−2010]>Solution:
>xyz=100+y−110+z201>Pivot in column 1 (basic variable x). y,z are free.x=1−y+2z, y,z∈R.Parametric form:
>⎩⎨⎧x+2y+z=02x−y+z=3x−y+z=1>. Q4: Gauss-Jordan eliminationSolve using Gauss-Jordan:
>1212−1−1111031>Solution:
>1002−5−31−10031>R2→R2−2R1, R3→R3−R1:
>10021−315100−531>R2→−51R2:
>100210151530−53−54>R3→R3+3R2:
>10021015110−53−34>R3→35R3:
>10021000134−31−34>Eliminate above: R1→R1−R3, R2→R2−51R3:
>1000100012−31−34>R1→R1−2R2:
>⎩⎨⎧x+2y−z=02x+3y+z=03x+5y+0z=0>Solution: x=2, y=−31, z=−34. Q5: Homogeneous system with free variablesFind all solutions to:
>123235−110000R2−2R1,R3−3R11002−1−1−133000>Solution:
>1002−10−130000>R3→R3−R2:
>1000105−30000>R2→−R2, R1→R1−2R2:
>xyz=z−531>Pivots in columns 1, 2. z is free. x=−5z, y=3z.Solution:
>A=121241360123>, z∈R. Q6: Rank from RREFFind the rank of
>121241360123R2−2R1,R3−R110020−130−3102>.Solution:
>1002−103−30120>Swap R2↔R3:
>{x1+2x2+x3−x4=12x1+4x2+2x3−2x4=2>Rank = 2 (two pivots). Q7: Parameterising solution setSolve and parameterise:
>[122412−1−212]R2−2R1[102010−1010]>Solution:
>x1x2x3x4=1000+x2−2100+x3−1010+x41001>Pivot in column 1. x1 basic; x2,x3,x4 free.x1=1−2x2−x3+x4, x2,x3,x4∈R.Parametric:
>{x+y=12x+ky=3>. Q8: System with parametersFor what value(s) of k does the system have (a) unique solution, (b) no solution, (c) infinitely many solutions?
>[121k13]R2−2R1[101k−211]>Solution:
>⎩⎨⎧x1+x2=10x2−x3=5x1+x3=15>
- If k=2, unique solution (y=k−21, x=1−k−21).
- If k=2, row 2 says 0x+0y=1 — no solution.
- Infinitely many solutions are impossible here (2 equations, 2 unknowns, RHS not all zero). Q9: Rank of transpose
If A is 3×4 with rank 2, what is the rank of AT?Solution: rank(AT)=rank(A)=2. Q10: Application — network flowA network has nodes A, B, C with flow equations:
>1011100−1110515R3−R110011−10−111055>Does a unique flow exist?Solution:
>R3→R3+R2:1001100−1010510>
Row 3 says 0=10 — impossible. No solution exists (the equations are inconsistent).Wait — let me recheck. The sum of equations 1 and 2 minus equation 3: (x1+x2)+(x2−x3)−(x1+x3)=10+5−15⇒2x2−2x3=0⇒x2=x3. Then eq 2: x2−x3=0=5. Indeed inconsistent.
🔗 Cross-References
- Next topic: Cramer's Rule — solving systems using determinants
- Week 3 (Vector Spaces): The solution set of Ax=0 is a vector space
- Week 4 (Basis & Dimension): Gaussian elimination finds bases for vector spaces
- Week 5 (Rank-Nullity): Rank from elimination feeds into the rank-nullity theorem
- BSCS2004 (ML Foundations): Solving normal equations in linear regression uses Gaussian elimination Join Discord Previous1.3 DeterminantsNext2.2 Cramer's Rule & Inverses