Systems of Linear Equations
Linear Algebra
A system of linear equations is a collection of equations in which each unknown appears only to the first power and is never multiplied by another unknown. A familiar example is 2x + 3y = 7 and x - y = 1. The word *linear* means each equation traces out a flat object: a line in two dimensions, a pla
A linear system has either 0, 1, or infinitely many solutions.
Without a solid grasp of linear systems, regression becomes a black box: you can call .fit(X, y) but you cannot diagnose rank deficiency, multicollinearity, or ill-conditioning when the optimizer misbehaves.
A system of linear equations is a collection of equations in which each unknown appears only to the first power and is never multiplied by another unknown. A familiar example is and . The word *linear* means each equation traces out a flat object: a line in two dimensions, a plane in three, and a Hyperplaneⓘ in higher dimensions.
Why do machine learners care? Because fitting a linear model is literally solving a system. Given training examples , the least-squares regression problem asks for a weight Vectorⓘ such that , where is a Matrixⓘ stacking the feature vectors as rows. When is square and invertible the system has a unique solution; when it is not (the common case in ML), we fall back on approximation via the *normal equations* — still a linear system.
Every linear system has one of three possible outcomes: a unique solution, no solution, or infinitely many solutions. Geometrically in 2D, two lines can meet at a single point (unique), be parallel and never meet (none), or coincide entirely (infinite). This trichotomy generalizes perfectly to higher dimensions and is the reason we care about concepts like rank and consistency later on.
A compact way to write a linear system is , where is the coefficient matrix, is the vector of unknowns, and is the constants vector. This notation is not just shorthand — it reveals structure. Many properties of the solution set (existence, uniqueness) can be read off from alone, before we ever start solving. That is the power of moving from equations to matrices.
Every line in 2D can be written in slope-intercept form . Drag the sliders below to see how changing the slope and the intercept rotates and shifts the line. When you have *two* such lines, their linear system asks where they cross.
Worked example — a unique solution: Solve and . From the second equation, . Substituting and isolating :
Solving for y
Solve $2x + 3y = 7$ and $x - y = 1$ — every move you'd make on paper
- 1Pick the simpler equation and isolate one variable.
- 2Solve for in terms of — substitution-ready.
- 3Substitute into the first equation; one variable left.
- 4Distribute the 2 across the parentheses.
- 5Combine like terms and move constants to the right.
- 6Divide both sides by 5 — first coordinate solved.
- 7Back-substitute into to get the second coordinate.
Now do it yourself. Each input below should be algebraically equivalent to the line above it — type your simplification and press Enter. The system checks equivalence symbolically (and numerically when symbolic simplification is ambiguous), so any valid intermediate form is accepted.
Try the derivation
Type each step. Equivalent rearrangements are all accepted.
So . The unique intersection point is — check: ✓ and ✓.
Worked example — no solution (parallel lines): Consider and . Divide the second by 2:
Why these are parallel
But the first equation says . These cannot both hold, so the system is inconsistent — geometrically two parallel lines that never meet.
ML connection — normal equations: For the regression system with , there are 100 equations but only 5 unknowns — usually no exact solution exists. The normal equations are a *square* linear system whose unique solution (when has full column rank) is the least-squares fit.
Solving a system by hand usually means Gaussian elimination: repeated row operations that simplify into an upper-triangular form, followed by back-substitution. We will formalize this in the next lesson. The key takeaway for now: a linear system is a geometric intersection problem, a matrix equation, and a solvable algorithmic puzzle — three viewpoints on the same object.
Exercises
Put your understanding to the test. Score + streak + speed all count.
Confirm you've got it
3 quick questions. Get 2 right to mark this lesson complete.