
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
A short tour of Part 1: eight modules, 53 short lessons, and the one idea behind all of them, that every AI model runs on vectors and matrices. You will see how each lesson is built (watch the idea move, check it by hand, run it in NumPy, see it in real AI) and how the notebooks, demo videos, interactive tools and quizzes fit in. School algebra is all the background you need.
Where to find each module's notebook and the seven interactive tools, and a simple order for using them with the lessons. It takes about two minutes to read.
A walk through all seven interactive pages that come with Part 1: the norm explorer, linear combination dials, cosine dial, projection explorer, transformation playground, hyperplane classifier and elimination stepper. For each one you see what to drag, what to read off the screen and the matching line of NumPy. The pages are free, need no sign-up and open in any browser. ## Section 2: Why Linear Algebra Runs AI
A matrix is a machine that moves a picture. You will see a grid of points as a grid of arrows, watch a matrix move every arrow at once, and compute the result with four numbers. The lesson ends with two places where this is happening in AI right now.
Houses, colours, pictures and even words can all be written as a short list of numbers called a vector. You will learn to write a vector, draw it and use it in Python, and see why AI depends on choosing those numbers well. It sets up everything in Module 2.
Follow along as the Module 1 notebook is typed line by line: a house as a vector, counting from zero, a colour and an 8 by 8 image as vectors, a layer as a matrix, a batch of houses, and a speed test with two 1000 by 1000 matrices. A few mistakes are made on purpose so you can see how to fix them. The video starts with three ways to get the notebook running on your own computer.
The three basic moves of vector algebra: adding two vectors with the triangle and parallelogram laws, scaling a vector, and subtracting one from another. A delivery rider on a city grid and a small shop's weekly sales are the running examples, and you meet the zero vector and the ones vector. The lesson ends with the gradient step w = w - 0.1 g, which runs millions of times while a model trains.
Three ways to measure how big a vector is: the straight-line L2 norm, the city-block L1 norm and the largest-slot L-infinity norm. You will compute each one by hand and in NumPy, see the circle, diamond and square they draw, and turn a vector into a unit vector that keeps only its direction. The norm explorer tool goes with this lesson.
A linear combination scales some vectors and adds the results. You will see it with arrows on a grid, mix colours the way your screen does, and use it to plan production and blend forecasts. It is also the first step towards seeing what every layer of a neural network computes. The linear combination dials tool goes with this lesson.
Multiplying a matrix by a vector is the one operation that almost every AI model repeats, billions of times. You will see one row of weights turn a house into a price, how a whole matrix makes several predictions at once, and the shape rule that says when a multiplication is allowed. The lesson finishes with why GPUs are fast at it and how it becomes one layer of a neural network.
Adding, scaling, norms and matrix times vector work the same way whatever the number of elements. You will meet a business vector with six dimensions, an AI vector with 768, and three ways to picture a vector that has too many dimensions to draw.
In 2013 researchers at Google showed that words turned into vectors can be added and subtracted: king minus man plus woman lands near queen. You will do the whole calculation by hand with six toy words, see why the nearest word can be one you started with, and learn where the method works and where it does not. It uses only the tools from Module 2.
How does a ride-hailing app find a nearby driver among thousands in a few seconds? You will build the answer from vectors and norms: cut the city into hexagon cells with Uber's open-source H3 system, search a cell and its neighbours, and see why hexagons have one neighbour distance where squares have two. The lesson also shows why the closest driver in a straight line is not always the right one.
Type along with the Module 2 notebook: adding vectors, two weeks of kiosk sales, the three norms and their unit circles, linear combinations, matrix times vector for houses, six dimensions, and short versions of the word2vec and hexagon-grid case studies. A few mistakes are made on purpose, with the fixes.
Two free interactive pages for this module, the norm explorer and the linear combination dials. Open them next to lessons 2.2 and 2.3 and try the suggestion for each below. Each page also shows the matching NumPy line.
The dot product is the operation behind almost every similarity score in AI. You will compute it in two steps, multiply the pairs and add, see four small tricks it can do, from picking out one number to finding an average, and meet two everyday uses: reading the mood of a review and recommending products.
A dot product can be positive, zero or negative. What decides which? You will see the formula that links the dot product to the angle between two vectors, why it is true, and what its sign tells you. The lesson also covers right angles in any number of dimensions, where Pythagoras comes back.
Divide the dot product by the two lengths and only the angle is left. That is cosine similarity, a dial that runs from -1 to +1. You will see what scores above zero, at zero and below zero mean, and how similarity and dissimilarity matrices compare every pair in a dataset at once. The cosine dial tool goes with this lesson.
How much of one vector points along another? You will cast the shadow of b onto the line of a, compute the scalar and vector projection, and check that the part left over meets a at a right angle. The lesson ends with uses from physics and sales reports to removing bias from AI models. The projection explorer tool goes with this lesson.
The distance between two vectors is the length of their difference, in the three flavours you already know. You will build a distance matrix for every pair at once, find a nearest neighbour, and use it to predict what someone will like. The lesson also shows why, for unit vectors, distance and cosine similarity tell the same story.
The cross product takes two 3D vectors and gives a third that stands at a right angle to both, with a length equal to the area they span. You will compute it step by step, use the right-hand rule, and see how robots and 3D graphics use it to find which way a surface faces.
Most real data comes with no labels. k-means finds groups using only distance, with two simple steps repeated: assign each point to its nearest centre, then move each centre to the average of its group. You will watch a real run settle, see why it always does, and see where it hides inside vector databases.
You type 'cheap flights to Paris' and the page you want is called 'budget airfare to France', with no words in common. You will see how an embedding turns text into a vector, then use unit vectors and the dot product to rank pages by meaning, first with three-number toy vectors and then with the real thing.
Companies hold billions of embeddings, so comparing a question with every one of them is too slow. You will follow a vector database from storing normalised vectors, through k-means clusters that narrow the search, to a fast top-k answer, using ideas from tools such as FAISS, Milvus and pgvector. You will also see how this feeds retrieval for chatbots.
Type along with the Module 3 notebook: the dot product on lists and arrays, angles, cosine similarity as a function, a similarity matrix for four articles, projections, nearest neighbours for five viewers, and a small search by meaning. A few mistakes are made on purpose, with the fixes.
Two free interactive pages for this module, the cosine dial and the projection explorer. Open them next to lessons 3.3 and 3.4 and try the suggestion for each below. Each page also shows the matching NumPy line.
A matrix is a rectangular grid of numbers, and almost every dataset a model trains on is one. You will read a matrix's shape, name any entry in notation and in NumPy, stack houses into a matrix, and see how a batch of sentences and a colour photo become a matrix and a stack of matrices, called a tensor.
Square matrices and their main diagonal, what it means for two matrices to be equal, and the special ones with names: zero, identity, diagonal and triangular. For each one you will see the NumPy that builds it and where it lives in AI, from skip connections to the mask inside GPT.
Flip a matrix across its diagonal and you get its transpose. Matrices that look the same when flipped are symmetric, those that flip into their own negative are antisymmetric, and those that are mostly zeros are sparse. The lesson ends with one map of every matrix type from this module and where each one appears in AI.
Adding, subtracting and scaling whole tables entry by entry, and the rules these follow. You will work with two months of sales for two shop branches, then see why this simple arithmetic is at the heart of how neural networks learn, including averaging the weights of several models.
Multiplying two matrices one entry at a time: row times column. You will learn when two matrices can be multiplied, use the shape rule, see why AB and BA usually differ, and count the cost of a product. The lesson ends with why every neural network is a chain of these products.
The transpose rules, including the one with a twist: (AB)^T = B^T A^T. Then two products that appear everywhere, A^T A and A A^T, why both are symmetric, and why they lead to the singular value decomposition. You will see them in linear regression, in kernel matrices and in the attention scores Q K^T.
The Hadamard product multiplies two matrices entry by entry, which is very different from the matrix product. You will use it to mask part of a picture, learn the broadcasting rules, and see why A * B and A @ B are different operations in NumPy. In AI it is the dropout mask, the causal mask and the gates of an LSTM.
The Frobenius norm measures the size of a whole matrix with one number: square every entry, add them up and take the square root. You will see that it is a vector length in disguise, use it to measure the distance between two matrices such as two images, and meet three uses in AI: weight decay, gradient clipping and compression.
How does a language model know that 'it' means the animal in one sentence and the street in another? You will build attention from the matrix tools of this module: queries, keys and values from three matrix products, scores from Q K^T, scaling, a mask, softmax and a weighted blend. A three-word example is worked with real numbers, and then you read the formula from the original transformer paper.
Type along with the Module 4 notebook: the house matrix and its shape, the causal mask used in GPT, shop tables, matrix multiplication with prices and costs, why order matters, the transpose rule, Hadamard masking, the Frobenius norm, and the attention example with the words the, cat and sat. A few mistakes are made on purpose, with the fixes.
From here, matrices start moving things. You will feed the unit square into a matrix, learn the trick for reading any matrix by its columns, and see what the word linear guarantees: straight lines stay straight and the origin stays put. The transformation playground tool goes with this lesson.
Scaling, rotation, reflection, shear and the squash are the five basic moves of a 2 by 2 matrix. For each one you will see its matrix and what it does to the unit square and to both grids. Data augmentation for vision models is built from exactly these matrices.
The determinant is the area of the transformed unit square, ad - bc, with a sign attached. You will see what a negative sign means (a flip) and what zero means (everything squashed flat), and why this works for any shape. In AI it shows up in normalising flows and in spotting layers that lose information.
Chain two or three transformations and you get a single matrix, read from right to left. You will see why the order matters and check that determinants multiply. The stacked layers of a neural network are exactly this chain.
Moving a picture the obvious way leaves holes. You will see the fix every image library uses: for each new pixel, ask where it came from using the inverse matrix, and blend neighbouring pixels when the answer lands between them. This is what runs underneath data augmentation.
A slide is not a linear transformation, because a matrix can never move the origin. Add one extra coordinate, a 1, and slides become matrices too. You will use the trick to rotate a picture around its own centre, and see why every neural network layer W x + b is affine.
A convolution slides a small filter along a signal, multiplying and adding. You will write the same thing as a matrix, a large sparse one with shared weights, and see why that is the heart of every convolutional neural network.
Seven well-known image filters, each one just nine numbers: identity, box blur, Gaussian, sharpen, Sobel, outline and emboss. You will see what each does to a real photo, learn the kernel-sum rule that separates filters that keep brightness from those that find edges, and build a pencil sketch. The first layer of a trained convolutional network learns edge and colour-blob detectors much like these.
Real photos have colour channels, and real networks use many filters at once. You will see the two ways to filter a colour image, work out the output size with padding and stride, count parameters, and learn four properties of convolution that make it so useful and so fast.
Not every map keeps grid lines straight. This preview shows a curved map, zooms in until it looks like a matrix, and names that matrix the Jacobian. You will see what its determinant says about local area change, and why it matters for backpropagation and normalising flows. The full treatment comes later in the course.
Two tangled ribbons of red and blue points cannot be split by one straight line, yet a tiny neural network separates them. You will see that each layer is a matrix, a slide and a bend, and that stacking layers bends space until a line is enough. The idea comes from a well-known 2014 essay by Chris Olah, and every move in it is one you learned in this module.
Type along with the Module 5 notebook: the unit square as a corner matrix, the grid before and after, determinants, transforming an image backwards, a convolution as a matrix, a gallery of image filters, and one layer of a neural network bending space. A few mistakes are made on purpose, with the fixes.
One free interactive page for this module, the transformation playground. Open it next to lessons 5.1 to 5.4 and try the suggestions below. The page also shows the matching NumPy line.
So far matrices have moved things. Now we ask where something started if we know where it landed. You will turn a pile of equations into one line, Ax = b, look at the row picture and the column picture, and see linear regression as one big system of equations.
A system of equations can have one solution, none, or infinitely many. You will see how the determinant tells you which before you solve anything, and what changes when there are more equations than unknowns or fewer, which is the situation machine learning always faces.
Gaussian elimination by hand on a 3 by 3 system: clear one column at a time until you reach the staircase called row echelon form, then solve from the bottom up. You will see what happens when a row turns into all zeros, and meet the word rank. The elimination stepper tool goes with this lesson.
One line of NumPy solves a system, but it can fail loudly or quietly. You will learn when to use solve, inverse and least squares, the three traps (a singular matrix, a nearly singular one and floating point), and a short checklist to run before you trust an answer.
One equation, w dot x + b = 0, splits space into two sides. You will see what w means, how the score tells you which side a point is on, and how to compute its distance from the line, plane or hyperplane. Support vector machines, the perceptron and logistic regression all predict with this score. The hyperplane classifier tool goes with this lesson.
A CT scanner fires X-rays through the body from many angles and works out what each tiny piece of the slice must look like. You will shrink the problem to a four-pixel slice, see that every beam is one linear equation, and solve the system. It is an Ax = b problem, and the lesson shows the idea used to solve far larger ones.
Type along with the Module 6 notebook: a line through two points as Ax = b, regression as a system, one solution, none or many, elimination, the singular and nearly singular traps, floating point, least squares, hyperplanes, and the CT scanner case study with Kaczmarz's method. A few mistakes are made on purpose, with the fixes.
One free interactive page for this module, the hyperplane classifier. Open it next to lesson 6.5 and try the suggestion below. The page also shows the matching NumPy line.
In Module 6 we swapped, scaled and subtracted rows, so why are those moves allowed? You will see the three row operations one at a time, why each keeps the solutions exactly the same, and that every row operation is secretly a matrix. This turns elimination into matrix multiplication and leads to the LU factorisation NumPy uses. The elimination stepper tool goes with this lesson.
The exact rules that make a matrix a staircase, called row echelon form, and a step-by-step routine that gets any matrix there, even a rectangular one. You will count pivots to find the rank, and see what rank says about real data using a house table in which one column is the sum of two others.
Reduced row echelon form adds two rules to the staircase: every pivot is 1, and each pivot is the only nonzero number in its column. You will read the solution straight off it with no back substitution, see why it is unique, and learn why SymPy has rref while NumPy does not.
Columns without a pivot give free variables. You will write every solution at once as a point plus a free direction, a line or a plane, and use the count rank + free variables = unknowns. A one-line test tells you before solving whether a system has none, one or infinitely many solutions.
Row reduction breaks on real data: a tiny rounding crumb looks like a pivot and gives the wrong rank. You will see why, meet singular values as a sturdier tool, and learn to read the effective rank of a real dataset so you can spot duplicate or derived features before they hurt a model.
A real medical dataset with ten columns: 442 patients with diabetes. Does it really have ten features? You will find the hidden recipe inside the blood tests, see rank say ten while the singular values tell a different story, and watch the damage it does to a regression's weights. The lesson ends with the NumPy check to run before training on any table.
Type along with the Module 7 notebook: row operations and elementary matrices, row echelon form and rank, RREF, free variables, the rounding crumb, and the 442-patient diabetes dataset that ships with scikit-learn, where the singular values reveal a hidden recipe. A few mistakes are made on purpose, with the fixes.
One free interactive page for this module, the elimination stepper. Open it next to lessons 7.1 to 7.3 and try the suggestion below. The page also shows the matching NumPy line.
The span of a set of vectors is every combination you can make from them. You will see the span of one, two and three vectors as a line, a plane or more, and test whether a target vector lies inside a span with a tool you already have. A linear layer can only produce outputs in the span of its weight matrix's columns.
A set of vectors is linearly dependent when one of them is a combination of the others. You will meet the two equivalent definitions, spot dependence in 2D and 3D, and use a test that always works and also finds the hidden recipe. Redundant features and the one-hot dummy variable trap are the AI examples.
Real data is rarely exactly dependent. It is almost dependent, and that is where trouble hides. You will compare three tools: the determinant and why it can fool you, rank, which works for any shape, and the condition number, which catches near dependence. It is the multicollinearity check to run before any regression.
Type along with the Module 8 notebook: span as a rank test, two vectors that fill the plane, linear dependence, the one-hot dummy variable trap, the determinant trap, a table with almost dependent columns, and the condition number showing how a near-copy swings regression weights. A few mistakes are made on purpose, with the fixes.
This is linear algebra for machine learning, AI and data science, taught visually. Every AI model you use, from chatbots to image generators, runs on vectors and matrices, multiplied billions of times a second. Most of us were taught that as a wall of symbols. This course teaches it the other way round. You watch every idea move first, check it by hand once with small numbers, run it in one line of Python with NumPy, and then see where it shows up in real AI and deep learning.
Part 1 has 8 modules and 53 short lessons, each under 15 minutes. It also has 8 case studies, a notebook and a demo video for every module, 7 free interactive tools and a quiz at the end of each module. You need school algebra and nothing else.
What is in Part 1
How it works
Every lesson follows one recipe: watch the idea animated, check it by hand, run it in NumPy, and see it in real AI. Each module ends with a notebook walkthrough where the code is typed live, mistakes included, plus exercise and solution notebooks to try yourself. The interactive tools open in any browser, so you can drag a matrix and watch the grid bend.
This is Part 1 of Applied Linear Algebra. Part 2 continues with subspaces, eigenvalues and beyond.