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.

Takumi Yamada
· 5 min read
mathlinear-algebravectorsmatricesgraphics

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 is an arrow. A 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 .

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.

A VECTORan arrow from the origin1234123(3, 2)ADDINGwalk one, then the other12345123(3, 2)(4, 1)+ (1, -1)
The numbers say how far the arrow reaches along x and y. Adding (1, -1) to it lands on (4, 1).

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
aba · b > 0roughly the same wayaba · b = 0perpendicularaba · b < 0roughly opposite
The sign of the dot product for three pairs of arrows.

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.

BEFOREx̂ŷM01-10where x̂landswhere ŷlandsAFTER Mx̂ŷ
A quarter turn. Each column of M is where one basis arrow ends up.

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.

MatrixWhat 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
[[2,0],[0,2]]scale by two[[0,-1],[1,0]]rotate 90 degrees[[1,1],[0,1]]shear[[1,0],[0,1]]identity: do nothing
The four matrices from the table. The dashed square is before, and the solid shape is after.

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.

x̂ŷM1001where x̂ landswhere ŷ landsx̂ → (1, 0)ŷ → (0, 1)Shaded square: area 1Drag either tip, or press Tab to reachone and move it with the arrow keys.
try
M = [[1, 0], [0, 1]]
Move either arrow and the whole grid follows. The columns of M are where the arrows land.

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.

ROTATE FIRSTrotatestretchSTRETCH FIRSTstretchrotate
The same two machines in both orders, starting from the same square.

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 on the screen. A (Graphics Processing Unit) is a chip built to do millions of these small multiplications at the same time.

model spaceas the artist drew itworld spacewhere it is in the scenecamera spaceas the camera sees itthe screena pixel position× matrix× matrix× matrix
The chain of matrices that every vertex goes through on its way to the screen.

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 (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 ", 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
  1. 1.The dot product of two arrows is 0. What does that tell you?
  2. 2.A matrix has columns (0, 1) and (−1, 0). Where does it move the vector (3, 2)?
  3. 3.What does R·S mean as two moves?

Who wrote this

Author profile and background

Takumi Yamada

Takumi Yamada

· Backend Engineer

Backend engineer building services, databases, Linux tooling, and NEGEN SYSTEMS. Writing about low-level mechanics, distributed systems, and real-world security.

End of post
NEGEN SYSTEMS
Receipt · post 11 of 31
Written
Jan 6, 2026
Length
1,197 words · 5 min
Built
…
Served by
…
Delivered
…
Over the wire
…
Go's share
…
Next up the stack · L7 Math, AI & vision

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.

9 min read