Solving Two Equations in Two Unknowns
Intuition
Two linear equations are two lines in the plane; the solution is where they cross. If the lines are parallel they never cross (no solution) or coincide (infinitely many). The determinant tells you which case you are in.
Precise explanation
System with , :
If , Cramer's rule gives
Each numerator is the determinant of with one column replaced by the right-hand side.
Floating-point care: with real-world numbers, "zero" is rarely exactly 0.0. Treat the matrix as singular when .
Worked example
, : ; ; . Check: ✓.
Common mistakes
- Swapping and in the determinant.
- Testing
det == 0exactly with floats. - Forgetting to verify: substitute back and check the residual.
Why this matters
Linear systems are solved inside least squares (ML-09), ridge regression (ML-20) and Newton's method. Recognising near-singular systems explains why ML adds regularisation.
References
- Mathematics for Machine Learning — Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong (Cambridge University Press) (
S009)