Separate direction from length
A raw dot product depends on both angle and vector lengths. Cosine similarity divides by both lengths, leaving only the cosine of the angle. For unit vectors, dot product and cosine similarity are equal. A zero vector has no direction, so its cosine similarity is undefined.
That distinction matters for embeddings: normalised vectors compare direction, while unnormalised dot products also reward magnitude. A neuron computes a related expression, w · x + b. Matrix multiplication is a collection of row–column dot products; see matrix multiplication and vector norms.
Projection is a dot product too
The scalar projection of b onto a is (a · b)/‖a‖. It is the signed length of b along a; multiply by the unit direction a/‖a‖ to get the projection vector. If a is zero, this projection is undefined.
Interpret the value, not just the arithmetic
For a=(3,4) and b=(1,2), the dot product is 11. Their lengths are 5 and √5, so cos θ=11/(5√5)≈0.984: the vectors point in similar directions. If the dot product is zero and neither vector is zero, they are perpendicular. Scaling either vector scales the dot product, so comparing raw dot products across unequal lengths can be misleading. Normalise first when direction alone is the question.
The scalar projection of b onto a is (a·b)/‖a‖; the projected vector is that scalar times the unit vector a/‖a‖. This signed length is negative when b points partly opposite a. A weighted sum such as w·x is also a dot product, but it is not automatically a similarity score: the weights define what counts as a useful direction. In data applications, feature scaling and embedding normalisation affect its meaning. See vector norms for lengths and projections for the closest-point interpretation.
Try this above
Rotate one vector through a right angle. The dot product should pass through zero, change sign, and reach its largest magnitude when the vectors align or oppose.
The dot product is bilinear: a·(b+c)=a·b+a·c and (ca)·b=c(a·b). These rules let a matrix-vector product be interpreted row by row as dot products. They also make the dot product a way to test orthogonality: a·b=0 means perpendicular in the usual Euclidean geometry, including cases where one vector is zero. If a=0, the algebraic dot product is defined but the angle and cosine similarity are not, because a zero vector has no direction.