LINEAR ALGEBRA / 5. LINEAR SYSTEMS
Systems of Linear Equations
Ax = b — solving the core problem of linear algebra
EXPLANATION
A system of linear equations is represented as Ax = b: • A → coefficient matrix (m×n) • x → unknown vector (n×1) • b → right-hand side vector (m×1) Three possible situations: 1. Unique solution → det(A) ≠ 0, A is invertible. x = A⁻¹b 2. No solution → inconsistent (parallel lines in 2D) 3. Infinite solutions → underdetermined (a line, plane of solutions) Gaussian Elimination: the standard algorithm. Row operations that don't change the solution: • Swap two rows • Multiply a row by a scalar • Add a multiple of one row to another Augmented matrix [A|b] → row reduce to [I|x] The inverse A⁻¹: • AA⁻¹ = I • Exists only when det(A) ≠ 0 • For linear systems: x = A⁻¹b — but computing A⁻¹ is expensive! • In practice: use np.linalg.solve(A, b) — more stable than A⁻¹ @ b In ML: normal equation for linear regression: θ = (XᵀX)⁻¹Xᵀy — the closed-form solution to least squares.
DIAGRAM
System: 2x + y = 5
x - y = 1
Matrix form: [[2, 1], [x] [5]
[1,-1]] ×[y] = [1]
Augmented matrix → row reduce:
[2 1 | 5] [1 0 | 2]
[1 -1 | 1] →→→ [0 1 | 1]
Solution: x=2, y=1
Geometric interpretation (2D):
Each equation = a line
Solution = intersection of lines
2x+y=5: ─────╲
x-y=1: ─────╱
Intersection: (2,1) ← unique solutionCODE