The Maths You Actually NeedLesson 15 of 76

Module 2 · Matrices, and what a layer really does

The best fit, and what “best” was defined to mean

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 6 of 9 in this chapter

This chapter’s goalMultiply two matrices by hand and predict the output shape of any chain of layers, explain what the rank of a weight matrix costs and buys, and use singular values to justify replacing a 4096x4096 matrix with two thin ones and to state what that replacement gives up.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
Three blocks of cells joined by arrows: a narrow column, a large square grid and a single tall bar.
A column of values entering a grid of weights and leaving as a shorter column, in that order: the shape change is what a layer does, and the grid’s rank decides whether two small matrices could stand in for it.

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

The problem with no exact answer

You have 500 houses, four features each, and one price. You want X w = y, where X is 500×4 and w is the four coefficients you are looking for. There are 500 equations and 4 unknowns. Unless the data is astonishingly obliging, no w satisfies all 500. There is no exact answer.

So you settle for the closest one, and the definition of “closest” is a choice. Least squares chooses to minimise the sum of squared residuals:

Text
minimise  ||X w - y||^2  =  sum over rows of (prediction - actual)^2

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘The best fit, and what “best” was defined to mean’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/least-squares-and-the-normal-equations (Accessed: 29 November 2026).