I used to treat linear algebra as a checklist: learn the definition, memorize the formula, move on. That passed quizzes, but when I started reading ML papers and implementing models, the notation still felt disconnected from anything real.
What changed it was 3Blue1Brown’s Essence of Linear Algebra.
What is linear algebra, really?
Linear algebra is the math of lists of numbers and machines that update those lists in a predictable way. A vector can be an arrow on a plane, but in machine learning it is more often a description of something: a house might be $x=[1200,3]$ for square feet and bedrooms, and a token might be a list of 768 learned features. A matrix is the machine: feed it a vector, get another vector out.
Grant Sanderson’s series made one picture stick for me. A matrix is not a grid of symbols, it is a transformation of space that stretches, rotates, or shears every input direction. Once I held that image, eigenvalues, determinants, and change of basis stopped being separate pieces of notation and became consequences of the same idea.
flowchart LR
V["Input vector x"] --> M["Matrix A"]
M --> O["Output vector Ax"]
O --> D["Dot products measure alignment"]
O --> E["Eigenvectors = directions that only scale"]
The rest of this post walks one small $2\times2$ example from start to finish: vectors, matrix multiply, dot product, determinant, eigenvalue, with every arithmetic step written out. Later I show where these ideas appear in models like the ones I am building in AL-1.
What is a vector?
A vector is an ordered list of numbers. In two dimensions I write
The first entry is how far I move along the horizontal axis, and the second is how far along the vertical axis. I can read the same object as an arrow from the origin to the point $(4,5)$, or as a list of features. Both views describe the same data: geometry gives me intuition, lists give me code.
How does a matrix transform a vector?
A matrix packages several output directions at once. I use the same matrix throughout this post:
Row 1 says: “to build the first output coordinate, take $2$ times the first input plus $1$ times the second.” Row 2 says: “take $0$ times the first input plus $3$ times the second.” Applying $A$ to $x=[4,5]^T$ means computing each output entry separately.
First output coordinate:
Second output coordinate:
So the transformed vector is
Geometrically, the point $(4,5)$ lands at $(13,15)$. I can also read the same calculation in column language: the columns of $A$ are where the basis vectors $\hat{\imath}=[1,0]^T$ and $\hat{\jmath}=[0,1]^T$ get sent. The input $[4,5]^T$ says “take 4 copies of the first column plus 5 copies of the second”:
Neural-network layers usually use the row view (weighted sums into each neuron), while animations usually use the column view (where the basis arrows go). It is the same multiplication drawn two ways.
I drew the grid under the identity and under $A$. Under $A$, the grid deforms, $\hat{\imath}$ and $\hat{\jmath}$ end on the columns of $A$, and $x$ ends at $(13,15)$.
Identity: the grid is unchanged and $x$ stays at $(4,5)$.
$A$: $\hat{\imath}$ and $\hat{\jmath}$ land on the columns of $A$, and $x$ goes to $(13,15)$.
One complete example: vectors through eigenvalues
I want one thread of numbers to follow without switching examples. I keep $A=\begin{bmatrix}2&1\\0&3\end{bmatrix}$ and $x=\begin{bmatrix}4\\5\end{bmatrix}$ from above, then ask what else this matrix tells me.
Matrix multiply (recap)
Dot product on two directions from the same setup
Take the first column of $A$ as vector $a$ and a separate direction $b$:
The dot product multiplies matching entries and adds:
Length of $a$:
Length of $b$:
The geometric formula $a\cdot b = |a||b|\cos\theta$ gives:
A large positive dot product means the vectors point roughly the same way, zero means perpendicular, and a negative value means they face opposite directions. That is why dot products score similarity in search, recommendations, embeddings, and transformer attention.
I tried two values of $b$. The first, $b=[3,4]$, gives $a\cdot b=6$ and $\cos\theta=0.6$. Because the second entry of $a$ is 0, changing $b_2$ rescales $|b|$ and moves the angle, but leaves $a\cdot b$ at 6. The second choice is $b=[3,1]$.
$b = [3, 4]$: $\|b\| = 5.00$ and $\cos\theta = 0.60$.
$b = [3, 1]$: $\|b\| = 3.16$ and $\cos\theta = 0.95$.
Determinant: how much area scales
Before looking at inverses and eigenvalues, I check whether $A$ squashes space. For a $2\times2$ matrix,
A unit square becomes a parallelogram with six times the area. If $\det(A)=0$, some direction collapses to a line or point, information is lost, and no inverse can undo that.
I set the bottom-right entry $d$ of $A$ to 3 and then to 0. The shaded shape is where the unit square lands. At $d=3$ the determinant is 6, and at $d=0$ the plane flattens onto a line.
$d = 3$: the unit square becomes a parallelogram of area 6.
$d = 0$: the plane flattens onto a line, so the area is 0.
Eigenvalues: which directions only get stretched
An eigenvector $v$ is a direction that $A$ does not rotate. $A$ only scales it by some number $\lambda$:
I find $\lambda$ by solving $\det(A - \lambda I)=0$.
Set the determinant to zero:
So one eigenvalue is
and the other is
Eigenvector for $\lambda_1 = 2$. Solve $(A - 2I)v = 0$:
The first row gives
Pick $v_1 = 1$:
Check:
Eigenvector for $\lambda_2 = 3$. Solve $(A - 3I)v = 0$:
The first row gives
Pick $v_1 = 1$:
Check:
I drew a unit vector $v$ next to $Av$, at $45^\circ$ and at $90^\circ$. They point the same way only at $0^\circ$ (the $\lambda_1=2$ eigenvector $[1,0]$) and $45^\circ$ (the $\lambda_2=3$ eigenvector $[1,1]$), and at $45^\circ$ the length ratio is 3.
$45^\circ$: $Av$ points the same way as $v$ and is 3 times as long.
$90^\circ$: $Av$ turns away from $v$, with $\cos = 0.949$ between them.
That is the full chain on one matrix: input vector, multiply, dot product for alignment, determinant for area scaling, eigenpairs for preserved directions. When I apply $A$ many times, an eigenvector direction grows or shrinks by $\lambda^k$. That is why eigenvalues matter for stability, PCA, and exploding or vanishing signals in deep networks.
How do dot products measure alignment?
The thread above already computed $a\cdot b=6$. The new idea here is projection: how much of one vector lies along another. I use a different pair with the same mechanics, $a=[2,1]$ and $b=[3,4]$:
Projection of $b$ onto $a$:
Least-squares regression is the same picture in higher dimensions. When no exact solution exists, I project the target onto the space of predictions the model can produce.
How does matrix multiplication compose transformations?
If matrix $B$ acts on $x$ first and matrix $A$ acts on the result, the combined effect is $ABx$: the rightmost matrix hits $x$ first. Order matters. Rotating then stretching is generally not the same as stretching then rotating, so $AB \neq BA$ in most cases.
Shapes encode the contract. If $B$ is $3\times2$ and $x$ is $2\times1$, then
A matrix $A$ that multiplies that result must have three columns. Dimension matching is not bookkeeping for its own sake: the output space of one map must equal the input space of the next.
For a small composition with the same $A$, let
(swap the two coordinates). Entry $(AB)_{11}$:
Entry $(AB)_{12}$:
Entry $(AB)_{21}$:
Entry $(AB)_{22}$:
So
Applying this to $x=[4,5]^T$ means swapping first ($Bx=[5,4]^T$), then applying $A$. The two steps become one matrix product.
What do determinants and inverses tell you?
I already found $\det(A)=6$. When $\det(A)\neq 0$, an inverse exists that undoes the transformation. For this $A$:
Solving $Ax=b$ is $x = A^{-1}b$ in principle. In real code I call a numerical solver instead of forming the inverse explicitly, because it is faster and more stable, but the picture is the same: run the transformation backward.
What is a change of basis?
A basis is the coordinate language I use to describe vectors. The physical arrow does not move when I change basis; only the numbers describing it change. If the columns of $P$ are new basis vectors expressed in the old coordinates, then
and
Fourier transforms pick a frequency basis, PCA picks variance-aligned axes, and token embeddings learn a coordinate system where semantic relationships become geometry later layers can exploit.
Where does machine learning use linear algebra?
Each of these uses an idea from the example above:
- Dense layers are $y = Wx + b$. Each row of $W$ is a dot product against the input, which is the row view of matrix multiply.
- Embedding tables store one vector per token ID.
- Attention scores query–key alignment with dot products and computes all pairs at once with matrix multiplication.
- Convolutions apply the same small linear map to every local patch.
- Regression and PCA rely on projection and on eigenvectors of covariance matrices.
- Backpropagation threads Jacobians through the graph. A Jacobian is a local linear approximation of how small input changes affect outputs, which is why I check gradients with numerical checking before trusting a new
backward()implementation.
The AL-1 build path I am following assumes all of this is second nature: autograd → gradient checker → BPE → embeddings → positional encoding → attention. Linear algebra underlies every step.
Who should watch the 3Blue1Brown series?
If you are heading into machine learning, computer vision, or any field heavy with matrix notation, and the symbols still feel opaque, the playlist is worth the time. You need patience and a willingness to pause when an animation does not land on the first pass.
I still rewatch individual chapters when a course introduces something abstract (SVD, change of basis, dual spaces). That is faster than rereading a textbook from zero. The animations gave me a picture for $Ax=b$ and for weight matrices in PyTorch, and the pencil work, one $2\times2$ example at a time, made the symbols trustworthy. If you are in the position I was in, watch the full Essence of Linear Algebra playlist, work through a tiny matrix by hand, and then build something that multiplies matrices. That combination is what made it click for me.
Support the writing
If this post helped, a coffee keeps the deep dives coming.
Buy me a coffee