Lists That Agree
Lists That Agree
Scenario
Amber studio keeps glaze recipes as ordered lists of four knobs: kaolin, feldspar, silica, and a colorant. Two recipes sit on the bench this morning.
The house white:
The guest celadon:
The minus on the house white is not a typo. The second slot is feldspar relative to a baseline: this batch is short one part feldspar. If you drop the minus you are mixing a different glaze, and the rest of the arithmetic will lie to you politely.
The question is not "what is a vector?" The question is: when do these two recipes agree, and how much of the house white is already living along the celadon?
Those two measurements — agreement, and "the piece of one list that lives along another" — are the whole of gradient descent in miniature. A loss will later be a hill over a list of weights. A gradient will be a second list. The inner product of those two lists is how much the hill agrees with a walk you are considering. If you cannot see that agreement in four slots, you will not see it in .
A few answers look almost right and are wrong:
- — you dropped the minus on ’s feldspar ().
- — you added slots inside each recipe first and then combined them (). Agreement needs partner slots multiplied.
- — you added the recipes. That is a third glaze, not a number that says how they agree.
- — you dropped every sign (). Agreement respects directions.
Keep the minus. Multiply partners. Add those products. The agreement is .
The walk is live on the media Worker (176.4 s, cover at 66 s): a narrated plate of the four partner products and their sum. It is served from the SuperLearn media Worker; there is no second copy in the app bundle.
A list is an order, not a pile
The brackets on are doing work. They say the first slot is kaolin, always. Swap the first two slots and you have : a glaze that is short kaolin and heavy feldspar. Same digits, different object. In the rest of this course a weight vector is the same kind of object. The 17th coordinate of a linear layer is not "a number we happen to have." It is that direction in parameter space.
You can add two lists only when every slot has a partner:
That third glaze is a mix: three parts house kaolin plus one part guest kaolin, and so on. Scaling is the other primitive: is the same recipe, halved. Those two acts — add, and scale — are the linear algebra this course needs. We will not rebuild all of linear algebra here; we need just enough to read a gradient.
The length of a list is not the count of its slots. The Euclidean length is how far the arrow sits from the origin:
A long list is a strong recipe, or a steep slope, depending on what the list is. Length does not know about agreement: two long lists can point opposite ways.
Agreement is multiply-then-add
The dot product (or inner product) of two lists and of equal length is the sum of their coordinate-wise products:
For our glaze recipes:
When , the recipes lean in the same direction. When , they oppose each other. When , they are orthogonal: neither recipe has anything to say about the other.
Notice that length squared is self-agreement:
The piece of one recipe that lives along another
Suppose you want to express the house white as a piece that points along the celadon , plus a leftover residual :
We require that the leftover shares zero agreement with , meaning . Substitute :
For the Amber studio numbers:
The projection of onto is therefore:
Now verify the residual. The leftover glaze is:
Take its dot product with :
The residual really is orthogonal to . The leftover glaze shares nothing with celadon.
Two lengths are worth keeping, because they are the triangle in the figure below. The piece along has length
and the leftover has length . Those two are square to each other, so together they rebuild the house white: . A right triangle whose legs are measured, not sketched.
Cosine: agreement without scale
If you double the guest recipe to , the dot product doubles: . But the recipes do not point any more or less in the same direction than they did before.
The cosine normalizes by list lengths so size cannot fake alignment:
Because is close to , the house white and guest celadon are nearly perpendicular. Put the number back through the inverse cosine and the angle is — six tenths of a degree short of a right angle.
Worked example table
Every intermediate value computed on the home numbers:
| Slot | Knob | |||||
|---|---|---|---|---|---|---|
| 1 | kaolin | 3 | 1 | 3 | 9 | 1 |
| 2 | feldspar | −1 | 2 | −2 | 1 | 4 |
| 3 | silica | 2 | −1 | −2 | 4 | 1 |
| 4 | colorant | 0.5 | 4 | 2 | 0.25 | 16 |
| sum | 1 | 14.25 | 22 |
Summary: , , , , , .
Interactive workbench
Use the lab below to inspect how slot pairings affect agreement. Flip the feldspar sign to see the agreement jump from 1 to 5, shuffle slots to see how order alters the dot product, or scale to confirm that the projection foot and cosine remain stable.
OPT-P1-AGREE
OPT-P1-ANATOMY
Try it: Transfer example
Work this example by hand before revealing the solution:
Given two lists:
Find , the projection scale of onto , the residual , and verify .
Reveal solution
- Inner product:
- Length of :
- Projection scale:
- Residual:
- Orthogonality check:
- Cosine:
Runnable code verification
Run this in Python to check the arithmetic:
import numpy as np
a = np.array([3, -1, 2, 0.5])
b = np.array([1, 2, -1, 4])
print(a @ b, a @ a, b @ b) # 1.0 14.25 22.0
# Projection scale and residual
c = (a @ b) / (b @ b)
r = a - c * b
print(np.round(r * 22, 6), r @ b) # [65. -24. 45. 7.] ~0 (2.2e-16)
print(round((a @ b) / np.sqrt((a @ a) * (b @ b)), 4)) # 0.0565
Why does r @ b print 2.2e-16 instead of exactly 0? Standard 64-bit IEEE floating-point arithmetic has finite precision; is zero to the printer's patience.
Failure modes to watch for
- Adding slots inside each list: Adding kaolin to silica gives and , which has nothing to do with agreement.
- Dropping a minus: If you treat feldspar as , the dot product becomes . That is a different glaze.
- Mismatched list lengths: You cannot compute the inner product of a 4-slot recipe with a 3-slot recipe. Unmatched slots have no partner.
- Confusing length with agreement: A vector can be huge while sharing zero agreement with another vector.
- Treating the residual as parallel to : By construction, is strictly orthogonal to . It holds the variation that cannot explain.
Why this is the language of a loss
A loss is a hill over a list of parameters . In Chapter P3, we will meet the gradient , which is a second list of the exact same length. The directional derivative — how fast the loss climbs as you walk in direction — is nothing other than the inner product .
In deep neural networks, weights and gradients contain billions of numbers. But the geometry is identical: multiplying partner slots and adding them up to determine how much two directions agree.
The desk problem at the end uses different lists. Do not reuse or as a quiz answer; work the desk lists by hand.
Next: P2 The Price of a Nudge — what happens when we tweak a single knob by a tiny amount.
What this page claims
| Claim | Status |
|---|---|
| Amber studio glaze recipes, house white and guest celadon | ILLUSTRATION: a teaching scenario, not a measured batch |
| , , , , , | COMPUTED: numpy on the page's own arrays; the same asserts run in tools/opt-p1-narration/manim/p1_lists_that_agree.py and opt-p1-agree.test.ts |
Still opt_p1_agree | ILLUSTRATION: a teaching diagram served from the media Worker |
| Lesson video | shipped: Worker mp4 + cover (about 176.4 s walk, HTTP 200) |
| Agreement is the directional derivative of a loss | PUBLISHED: standard textbook description, not proved on this page |
