The Dot Product
So far, combining vectors gave back another vector. The dot product is
different: it takes two vectors and returns a single number (a scalar). Multiply
matching components and add:
\vec{u} \cdot \vec{v} = u_x v_x + u_y v_y.
For example
\begin{bmatrix} 3 \\ 2 \end{bmatrix} \cdot \begin{bmatrix} 4 \\ 1 \end{bmatrix} = 3\cdot4 + 2\cdot1 = 14.
That's the entire definition. It looks almost too plain to matter — yet this little number
secretly measures how much two vectors point the same way, and it powers everything
from neural networks
to the geometry of angles.
Multiply and add
Set the two vectors below. The panel shows each component product and their sum — the dot
product. Notice the sign: when the arrows roughly agree it's positive, when they roughly oppose
it's negative, and somewhere in between it passes through zero.
The rules it obeys
The dot product is commutative
(\vec{u}\cdot\vec{v} = \vec{v}\cdot\vec{u}) and
distributes over addition
(\vec{u}\cdot(\vec{v}+\vec{w}) = \vec{u}\cdot\vec{v} + \vec{u}\cdot\vec{w}).
One special case is worth memorizing: a vector dotted with itself gives its length
squared,
\vec{v} \cdot \vec{v} = v_x^2 + v_y^2 = \lVert \vec{v} \rVert^2.
So the dot product already knows about
length —
and in the next lesson we'll see it knows about angle too.