Back to courseLesson 2 of 13

The dot product

What you'll learn

Measure how much two vectors agree — and read angle, projection, and perpendicularity from one number.

How much do two vectors agree? One points mostly east, the other east-north-east — are they allies, strangers, or opponents? The dot product answers with a single number.

Two formulas, one number

The dot product of u = (u₁, u₂) and v = (v₁, v₂) can be computed two ways — and the fact that they always match is the useful part:

uv=u1v1+u2v2=uvcosθu \cdot v = u_1 v_1 + u_2 v_2 = |u|\,|v|\cos\theta

The first face is arithmetic you can do in your head. The second says what that arithmetic means: it measures the angle θ between the vectors.

The shadow picture

θuvu's shadow on v
u·v = |u| |v| cos θ — the shadow's length times |v|. Same direction: big and positive. Perpendicular: zero shadow, zero dot product. Opposed: negative.

Project u onto v's direction — cast its shadow. The shadow's length is |u| cos θ, so the dot product is shadow × |v|: how much of u lies along v, weighted by how long v is.

The sign is a verdict

u · vAngleMeaning
positiveless than 90°pointing broadly the same way
zeroexactly 90°perpendicular — no overlap at all
negativemore than 90°pointing broadly against each other

The zero case gets a name — orthogonal — and it's the most important of the three. Checking perpendicularity now costs one multiplication and one addition: (3, 2) · (−2, 3) = −6 + 6 = 0. No angles, no trig.

Where you've already seen it

Work in physics is a dot product: W = F · d — only the force component along the motion counts, which is exactly what the shadow computes. A similarity score between two data profiles is a dot product. So is every pixel of every neural-network layer. It's the workhorse product of applied math.

Why this matters

Angles, lengths, perpendicularity — the dot product turns all the geometry of the plane into arithmetic. Next: leaving the page entirely, into the third dimension.

Check your understanding

Question 1 of 2

u · v = 0 for two nonzero vectors. What do you know?

Next lesson