A Gentle Introduction to Linear Algebra
Vectors, matrices, and the few ideas that make most of machine learning feel less mysterious than it sounds.
Linear algebra is the language machines speak when they learn. Almost every model, from a simple regression to a transformer, is a long chain of matrix products underneath. The good news is that the core ideas are small and visual.
Vectors are arrows
A vector is an ordered list of numbers, but it helps to picture it as an arrow from the origin. In two dimensions, the vector points to the coordinate .
Its length is the Euclidean norm:
The dot product measures alignment
The dot product of two vectors and is a single number:
When the vectors point the same way, the dot product is large and positive. When they are perpendicular, it is zero. When they oppose each other, it is negative. A remarkable amount of "similarity" in software — search ranking, recommendations, embedding distance — is just this one idea wearing different clothes.
Matrices transform space
A matrix is a function that takes a vector and returns another vector. Multiplying a vector by a matrix rotates, scales, or shears the space it lives in. A matrix looks like:
Applying it to a vector gives a new vector:
Eigenvectors are the directions that don't bend
For most vectors, applying a matrix changes their direction. Eigenvectors are the exceptions: they only get stretched. The stretch factor is the eigenvalue :
This is more useful than it sounds. Principal component analysis, PageRank, and the spectral clustering behind a lot of data tooling all reduce to finding eigenvectors.
A worked example
Project a vector onto a direction . The projection is:
That single line is the foundation of least-squares regression, which is the foundation of a remarkable amount of statistics.
Where to go next
- Work through the visual series first — intuition before proofs.
- Implement a dot product, then a matrix multiply, in the language you already use.
- Pick one idea above and use it on real data this week.
You do not need to memorize proofs. You need to know what a matrix does to a vector, and the rest follows.
Mathematics rewards patience. Spend an afternoon with a pencil and a matrix, and the abstraction stops being abstract.
Comments(5)
The concentric radius tip alone was worth the read. I’ve been matching outer and inner radii for years without realizing why it felt off.
outer = inner + padding— that’s the whole rule.Same — once you see it, you can’t unsee the mismatch on nested cards.
Exactly. Glad this landed.
Also useful with Typeset measure caps — nesting and measure fight each other if you’re not careful.
Clear writing on a topic that usually gets hand-waved. Would love a follow-up on how this plays with nested dialogs.