Dot Product

4 min read#linear-algebra

A single number, built from two vectors, that encodes the angle between them and how much one casts onto the other.

Contents

Dot Product

The dot product of two vectors multiplies them into a single number that measures how much they point the same way. Two equivalent formulas define it:

\vec a \cdot \vec b = a_x b_x + a_y b_y = \lVert \vec a\rVert\,\lVert \vec b\rVert \cos\theta.
(1)

The left form is pure arithmetic — multiply matching components and add. The right form reveals the geometry: it is the product of the two lengths times the cosine of the angle \theta between them. Setting the two equal lets you recover an angle from coordinates, which is the seed of nearly all geometry done with numbers.

Projection

The dot product is the engine of projection — dropping one vector's shadow onto another's direction. The component of \vec a along a unit vector \hat b is just \vec a \cdot \hat b, and the projected vector is

\operatorname{proj}_{\vec b}\,\vec a = \frac{\vec a \cdot \vec b}{\vec b \cdot \vec b}\,\vec b.

Drag the tip of \vec a below and watch its shadow slide along \vec b. The projection is longest when the vectors align and shrinks to nothing when they are perpendicular.

Drag to move vector a (blue). Its projection onto b (amber) is shown as the green shadow; the dashed line is the perpendicular dropped from a's tip.

Orthogonality

See also