Dot Product and Magnitude
Length, the Dot Product, and the Angle
Scenario
Suppose you score a week of work against a rubric.
The week is three counts: ten hours of reading, twenty of practice, thirty of review. Write that as . The rubric says how much each hour is worth: reading is worth two, practice three, review six. Write that as . How much credit does that week earn, as a single number?
That is the question this lesson answers. Multiply matching slots, then add. First slots: . Second: . Third: . Add them, slowly: , and . The week earns .
A few answers look almost right and are wrong, the way a spam score of looks like a probability until you remember probabilities live in :
- — the first product was dropped, so only was kept.
- — the third product was dropped, so the walk stopped at .
- — someone added the rubric and ignored the week.
- — someone looked at the two arrows, decided they “look aligned,” and wrote cosine without dividing.
Keep every product. The number is .
Instead of starting from “what is a dot product?”, we ask:
- How do two lists become one number?
- What happens if we miss one product?
- How long is each arrow?
- What angle do they make?
- When is there no product at all?
Those two lists are still a vector from Lesson 1: a list of numbers, and an arrow from the origin. Today the two lists become one number. From that number you get the length of an arrow. From the product and the two lengths you get the cosine of the angle between them. Three quantities, one piece of arithmetic.
The clip walks those numbers in the same order: as two lists, then as two arrows; length ; the computed cosine; a right angle; then two lists of different lengths.
Two lists, one number
Take those two lists of the same length:
and .
Each slot of the first list has a partner in the second. Multiply the partners. Then add those products. That sum is the only number the two lists share.
First slots: .
Second slots: .
Third slots: .
Add them, slowly: , and .
Miss the and you quote . Miss the and you quote . The three products have to be there. 260 is not a guess from a picture. It is those three multiplications, added.
The same act has three writings. They are names, not three different operations:
All three equal for this pair.
Order does not matter. is , which is again. Commutative: .
The slots also split across a sum. Distributive: . Pair first, then add — or add first, then pair. Same number.
A second check, same rule
Five slots this time, still matching:
and .
. . . . .
. . . .
Same rule as . Longer lists, still one number. If someone quotes , they added the slots of one list and ignored the other. If they quote , they brought the wrong pair.
Length is the self-dot
The same list is an arrow. Put the tail at the origin. Put the tip at the point whose coordinates are the list. Magnitude is the distance from that tail to that head — the geometric length of the walk.
How do the slots give that length? Walk the axes one at a time. For that is two east and three north. The straight-line distance back to the origin is the hypotenuse:
Pythagoras on the slots is the arrow length. A third slot is one more right-triangle leg, not a new idea. In general:
That sum of squares is the vector dotted with itself. Length is .
This pair, first the short arrow. :
, and .
is a computed tip, not a caption we liked. The arrow that starts at the origin and ends at is seven units long.
The long arrow, :
, so
That is the same number as . You do not measure the drawing with a ruler. You add the squared slots and take the square root.
The angle those two arrows make
Two arrows from the origin make an angle . The product you already have and the two lengths you just computed are enough:
so
Do that division. . Then divided by is the cosine. It is a little less than — the arrows share a direction, but they are not the same ray. Writing because the picture “looks aligned,” or writing because that looks neat, skips the division. The arithmetic is over both lengths. Nothing else.
Three landmarks, so the formula has somewhere to sit:
Right angle. If the arrows meet at , then , so . The slots still multiply and add — the sum just happens to be zero. and : . Perpendicular means the product vanished, not that someone drew a little square.
Same direction. If one arrow is a positive stretch of the other, and . The product equals the product of the lengths.
Opposite. If one arrow is a negative stretch of the other, and .
This pair sits near "same direction," not on it. is close to and is not . That is the whole point of keeping the and the in the sentence.
When there is no product
Addition in Lesson 1 needed a partner for every slot. The dot product needs the same thing.
has three numbers. has four. The first three slots could be multiplied, but the fourth slot of the second list has no partner. There is no honest single number, and no angle to take.
You do not drop the extra slot to force a product. You do not borrow a zero. is undefined. Different-length lists have no dot product.
Figure
The still is two arrows from the origin — the same lists, drawn in the plane they share. The teal sits on that pair. The short tip is . The long arrow keeps going; . Cosine is over both lengths.
Ten times two is twenty. Twenty times three is sixty. Thirty times six is one eighty. The ink arrow is with length , the ember arrow is , and teal is the product .
A short sequence walks the same numbers one idea at a time: two lists as slots, the stack to , the same pair as arrows from the origin, why , the angle as over both lengths, a right-angle pair whose product is , then why three slots times four slots have no product. The SVG above stays the computed truth.
Lab
You just saw matching slots stack to and the short arrow measure . The teal number here is that same product, recomputed from the slots you set.
The six controls are the six slots. Try this: change to and the first product must leave ; the sum must leave . If it does not, the lab is not multiplying.
Teal is the live product and the live cosine, both recomputed from the slots you set. Reset returns to with . Flip the right-angle control: the product becomes because the slots now cancel. Flip the length-mismatch control: a length-3 list and a length-4 list refuse to make a number.
The next lesson takes several arrows and asks which points you can reach by mixing them.
