Read this as a study guide instead

Dot products

Projecting one vector onto another; the number behind similarity and angle.

a . b = 2 projection 0.4

The same ideas, as prose

These are the exact fragments the model serves — also available as an ordered study guide.

One number from two vectors

Take any two vectors and there is an operation that takes them in and hands back a single number, not another vector — a genuine change of category, and that alone is worth pausing on. That number is the dot product, and it measures something specific: how much the two vectors point the same way.

You can compute it two ways that always agree. Multiply matching components and add the results — like measuring how much of one push acts along the direction of another push, distilled into a single number — or, for the same two vectors, multiply their lengths together and scale by the cosine of the angle between them. Both routes land on the same number, one built from raw coordinates, the other built from geometry, and the fact that they always match is most of what makes the dot product worth having.

The rest of this concept works through what that number tells you: whether two vectors lean the same way or fight each other, how to read a right angle straight off it, and how to use it to measure how much of one vector lies along the direction of another.

Multiply and add — the component formula

The plainest way to compute a dot product works straight from coordinates. Line the two vectors' matching components up, multiply each pair, and add the products together. For vectors (3, 4) and (2, -1) that is 3*2 + 4*(-1), which comes out to 2.

Nothing about that recipe cares how many components a vector has. Two vectors in a plane have two components to multiply and add; two vectors in ordinary 3D space have three; two vectors describing a hundred numeric measurements have a hundred, and the same multiply-then-sum rule still produces one number. The dot product does not get more complicated as dimension grows — it gets longer to write out, and a computer does not mind that at all.

This component recipe is also the one a computer actually runs. Whatever geometric picture the dot product paints, the arithmetic underneath it is nothing more exotic than multiplication and addition, done once per matching pair of components.

The angle hiding inside the number

the angle between two vectors sharing a tail shared tail vector a vector b theta a . b = |a| |b| cos(theta) -- theta is this angle, measured tail to tail
Two vectors drawn from a shared tail point have an angle theta between them, the same theta that appears in a dot b equals the length of a times the length of b times cosine of theta.

The component formula gives no hint that angle is involved, yet it is: the same dot product also equals the product of the two vectors' lengths, scaled by the cosine of the angle between them. Written out, a . b = |a| |b| cos(theta), where theta is the angle you would measure if you drew both vectors starting from the same point.

That equivalence is not a coincidence bolted on afterward. Set the two vectors tail to tail and the triangle they form obeys the law of cosines, the rule relating a triangle's third side to its other two sides and the angle between them. Expand that relationship using the component formula's own rules — multiplying out sums, swapping the order of a multiplication — and the cosine formula falls straight out. Algebra and geometry are describing the identical number.

The payoff is that the angle's cosine can be recovered whenever both formulas are available: divide the dot product by the product of the two lengths and the result is cos(theta) on its own, a direct handle on how two vectors are angled relative to each other without ever measuring an angle with a protractor.

Positive, negative, or zero

the sign of a . b follows the angle between a and b acute angle a . b is positive right angle a . b is zero obtuse angle a . b is negative
An acute angle between two vectors gives a positive dot product, a right angle gives a dot product of zero, and an obtuse angle gives a negative dot product.

Because cos(theta) is the only piece of |a| |b| cos(theta) that can turn negative, the sign of a dot product is entirely a statement about the angle between the two vectors — like a meter reading how much two directions agree, disagree, or are simply indifferent to each other. Lengths are never negative, so whatever sign the dot product carries, cosine put it there.

An acute angle, anything less than a right angle, has a positive cosine, so vectors leaning toward the same general direction produce a positive dot product. An obtuse angle, anything more than a right angle, has a negative cosine, so vectors leaning apart, more than ninety degrees apart, produce a negative one. A right angle sits exactly at the hinge: cosine of ninety degrees is zero, so the dot product of two perpendicular vectors is zero no matter how long either vector is.

That last case is worth naming on its own: two nonzero vectors are orthogonal, the formal word for perpendicular, exactly when their dot product is zero. It is a clean test with no protractor involved — compute the number, and a zero settles the question of a right angle immediately, in any dimension the component formula reaches.

Projecting one vector onto another

b's shadow on a's line is the scalar projection vector a vector b foot of the perpendicular scalar projection of b onto a
Vector b drops a perpendicular onto vector a's line; the segment from a's tail to the foot of that perpendicular is the scalar projection of b onto a.

Stand one vector up and let a second vector cast a shadow onto it — like the shadow one pole casts on another when the light shines straight down onto the second pole's direction — and the length of that shadow is the scalar projection, a single number built from the dot product. Take the dot product of the two vectors and divide by the length of the vector being projected onto, and the result is exactly how far along that direction the second vector reaches.

Turn that length back into a vector — scale it so it actually points along the first vector rather than just measuring a distance along it — and the result is the vector projection: the closest point on the first vector's line to the tip of the second vector. It is what is left of one vector once every part of it that runs sideways to the other has been thrown away.

The sign carries meaning here too. A positive scalar projection lands ahead of the first vector's tail, in the direction the vector already points; a negative one lands behind it, meaning the second vector actually leans backward relative to the first. Either way, projection is how a dot product turns how aligned two vectors are into how far one of them reaches in the other's direction, a distinction that shows up anywhere one quantity needs to be measured along a specific direction rather than in the abstract.

A vector dotted with itself, and the algebra rules

Dot a vector with itself and the angle between it and itself is zero, so cosine drops out entirely and |a| |a| cos(0) collapses to |a| |a|, the vector's length multiplied by itself. That means v . v equals the square of v's length, and taking a square root of that number recovers the length directly — a dot product quietly doubles as a way to measure how long a vector is.

The dot product also behaves the way ordinary multiplication does in the algebra already trusted for numbers. It does not care about order: a . b and b . a are the same number. It distributes over addition: dotting a vector with a sum of two other vectors gives the same answer as dotting it with each one separately and adding the results. And a scalar multiplying one of the vectors can be pulled out front rather than applied first — scaling a vector before or after the dot product changes the answer by the same factor either way.

None of that is a coincidence to memorize piece by piece. Every one of those rules follows directly from the component formula, multiplying and adding numbers, which has always obeyed exactly these rules.

Where this number keeps showing up

A dot product answers one question so cheaply that it turns up wherever how aligned two directions are needs a fast numeric answer instead of a geometric argument. A steering system deciding whether it is facing a target computes the dot product between its current heading and the direction toward that target: a positive number means it is broadly facing the right way, a negative one means it needs to turn around before it needs to turn at all.

The same trick generalizes past physical direction. Any list of numbers can be treated as a vector, and a dot product between two such lists still measures how aligned they are — the same arithmetic that later scores similarity between embeddings, without needing anything more than multiply and add.

That reach, from steering an object in physical space to comparing two lists of numbers for how alike they are, is not two different ideas that happen to share a formula. It is one operation, multiply matching entries and add, read for whatever the coordinates happen to represent.