Linear Algebra 101: Vectors, Matrices, and Why Programmers Should Care
A vector is an arrow, a matrix moves arrows, and multiplying matrices means moving arrows one step after another. This is the picture that textbooks often leave out.
Linear algebra is usually taught as rows, columns, and rules for moving numbers around.
Underneath the notation, though, it's one of the most visual parts of mathematics. A vector is an arrow. A matrix is a way of moving arrows. Multiplying two matrices means doing one move and then the other.
With that picture in mind, you can see what the formulas are doing, including the linear algebra inside graphics engines and neural networks.
Vectors: arrows, not lists
A vector is written as a list of numbers, such as (3, 2). Picture it as an arrow that starts at the origin, the point (0, 0), and goes 3 steps along x and 2 steps along y.
Two operations are the base of everything that follows.
Addition puts arrows end to end. Adding (3, 2) and (1, -1) gives (4, 1). You walk along the first arrow, then along the second.
Scaling stretches an arrow. Doubling (3, 2) gives (6, 4), an arrow in the same direction but twice as long. Multiplying by a negative number turns it around.
Anything you can add and scale like this behaves like a vector. Points on a screen, colours written as red, green and blue amounts, sound samples, and the 4096 numbers inside one layer of a neural network all count. That's why one subject covers all of them.
The dot product: how aligned are two arrows?
The dot product of two vectors multiplies their matching numbers and adds up the results.
a · b = a₁b₁ + a₂b₂ (3,2)·(1,4) = 3+8 = 11
The arithmetic is the small part. What the result means is the useful part.
a · b > 0 arrows point roughly the same way
a · b = 0 perpendicular, no overlap at all
a · b < 0 roughly opposite directions
In geometry terms, the dot product equals the length of one arrow, times the length of the other, times the cosine of the angle between them. So it measures how long the arrows are and how much they point the same way.
That one number is used in a lot of software. Lighting in games asks how directly a surface faces the light. A recommendation system asks how similar two people's tastes are, with each taste written as a vector. A search engine asks how close a question is to a document. All of them compute dot products.
Matrices: machines that transform space
Here is the idea that makes the rest of linear algebra easier. A 2 by 2 matrix isn't only a grid of numbers. It works like a machine: every point of the plane goes in, and comes out moved to a new place. The columns of the matrix tell you exactly how.
The columns of a matrix are where the basis arrows land.
The basis arrows are the two arrows of length 1, one pointing along x and one pointing along y. Here is the matrix that turns everything by 90 degrees.
Every other point follows. To move the vector (3, 2), take 3 of wherever the x arrow went, plus 2 of wherever the y arrow went.
M·v = 3·(0,1) + 2·(-1,0) = (-2, 3)
That's matrix multiplication. It's a mix of the matrix's columns, weighted by the numbers in the vector. You don't need to memorize it as a rule about rows and columns.
Here are some common matrices and what they do.
| Matrix | What it does to the plane |
|---|---|
[[2,0],[0,2]] | Scale everything by two |
[[0,-1],[1,0]] | Rotate 90 degrees counterclockwise |
[[1,1],[0,1]] | Shear, sliding the top sideways, like italics |
[[1,0],[0,1]] | Identity, meaning do nothing |
You can try this yourself. Drag the tips of the two arrows below, or press a button to load one of the matrices from the table. The faint grid is the plane before, and the accent grid is the same plane after the matrix has moved it. Watch the numbers in M: its columns are always exactly where the two arrows end.
Matrix multiplication: composing machines
If a matrix moves arrows, then multiplying two matrices gives one matrix that does both moves, one after the other. R·S means do S first, then R. You read it from right to left, the same way as f(g(x)), where g runs first.
This explains two things that are usually taught as rules to memorize.
Why the row and column rule looks strange. It works out where the columns of one matrix end up after the other matrix moves them. The rule follows from doing one move after another.
Why the order matters. Turning a shape and then stretching it sideways gives a different result from stretching it sideways and then turning it. The order of the moves matters, so the order of the matrices matters.
The inverse of a matrix is the matrix that undoes it. It turns back what was turned, or shrinks back what was stretched.
Some matrices squash the whole plane onto a line. They lose information, so they can't be undone. The determinant of a matrix says how much it scales areas, and for these matrices it's zero. That's also exactly when a system of equations stops having one single answer.
Where you are already using it
Graphics. In every frame of a 3D game, each corner point of every shape is multiplied by a chain of matrices. They take it from the model's own coordinates, to its place in the world, to the camera's view, and finally to a pixel on the screen. A GPU (Graphics Processing Unit) is a chip built to do millions of these small multiplications at the same time.
Neural networks. One layer of a neural network multiplies its input by a matrix and then applies a non-linear function, which bends the result. Training means adjusting the numbers in those matrices a little at a time. When you read that a model has 175 billion parameters, it means its matrices contain 175 billion numbers.
Systems of equations. Solving one means finding which arrow the matrix moves onto a given result. There is exactly one answer when the matrix doesn't squash the plane.
Rotations. Robots, aircraft, and your phone turning its screen sideways all use matrices to track which way something is facing.
The Bottom Line
I care about this for the same reason I care about what a CPU (Central Processing Unit) does with my code. Tools hide the details, but when something stops working, knowing what is underneath helps.
When a shader, a small program that runs on the GPU, draws something wrong, the question is which matrix ran, and in which order. When a machine learning paper says it "projects the embedding", it means it multiplies a vector by a matrix.
Arrows, matrices that move arrows, and one move after another. With that picture, a formula full of small numbers below the letters becomes geometry you can imagine.
Once this picture feels comfortable, the next topic worth learning is eigenvectors: the arrows whose direction a matrix doesn't change.
Check yourself
3 questions · nothing is saved- Written
- Jan 6, 2026
- Length
- 1,197 words · 5 min
- Built
- …
- Served by
- …
- Delivered
- …
- Over the wire
- …
- Go's share
- …
AI 101: It's All Just Curve Fitting
Modern AI is one idea done at a huge scale: guess a function, measure how wrong it is, adjust it to be less wrong, and repeat. Neural networks, gradient descent, embeddings and transformers: the main ideas in one post.
