Kolton Ndoj

The dot product

The dot product measures how much two arrows point the same way: zero means perfectly sideways.

a⋅b=∣a∣∣b∣cos⁡θ=a1b1+a2b2\mathbf a\cdot\mathbf b=|\mathbf a||\mathbf b|\cos\theta=a_1b_1+a_2b_2

What the symbols mean

∣a∣|\mathbf a|
length of vector a
θ\theta
angle between them
a1b1+a2b2a_1b_1+a_2b_2
the same number from coordinates

Why it works — the picture

Shine a light straight down on b and measure the shadow it casts along a. The dot product is the length of a times the length of that shadow. If they point the same way, the shadow is full length; at 90 degrees the shadow vanishes and the dot product is 0. The cosine form and the coordinate form give the same number because both come from the law of cosines.

Graph for The dot product 06.2826-26
Dot product against the angle between them. It crosses zero at 90 and 270 degrees: perpendicular arrows. (drawn with the default slider values — move the sliders live)

Try it yourself

Where it’s used in real life

Computer graphics uses it for lighting (the angle between surface and light), and machine learning for measuring similarity.

Related

Play with it live →

Math · Linear algebra · Stretch