skipnothing/Math for Machine Learning

Dot Product & Norms

Two friends each rate the same three snacks out of ten, and you want one number for how alike their taste runs; multiply the ratings in pairs, add them up, and `a . b` already holds it.

  • The same pair-them-up-multiply-and-add recipe, run three ways, hands you a similarity score, a length, and an angle.
  • The score's sign alone calls it: positive when arrows agree, zero at a right angle, negative when they oppose.
  • Stretch the list to three times its size, its raw score triples, yet the angle-only score never moves.
BUILDS ON
01

Pair, Multiply, Sum

Two arrows sit on the same grid, one reaching to the point three-right and one-up, the other to two-right and two-up. You already have a recipe that turns a row and a column into a single number: from the last topic, you laid two equal-length strips side by side, multiplied them in pairs, and added the results into one running total. Point that exact recipe at these two arrows. Pair the first numbers, three and two, pair the second numbers, one and two, multiply each pair, and add: six plus two is eight. Two arrows in, one plain number out.

That number is the dot product, and the everyday version of it is something you have done at a checkout. A cart holds two apples, three bananas, four clementines; the prices are one, two, and three. The bill is two times one, plus three times two, plus four times three, which is twenty. Quantities in one list, prices in the other, paired and multiplied and summed into a single total. Same machine, different labels. The result is always one lone number, never a new arrow, the summing is what collapses the whole thing down to a scalar.

Move either arrow and the number moves with it. Swing the two arrows so they reach the same way and the total climbs; pull one back toward the origin and the total shrinks. That already hints at what this single number is quietly measuring, not just a total on a bill, but how much two arrows are pulling in the same direction. The next part pins that down by watching one thing only: the sign.

COLLAPSE TWO ARROWS INTO ONE NUMBER

Keep going, sign up to unlock the rest

3 more parts in this topic, plus 19+ more topics in Math for Machine Learning.

Sign up, it's freeSee the full Math for Machine Learning
Linear Algebra0/4#2 Matrix Operations
#4 Eigenvalues & Eigenvectors