Linear Algebra
6.110 min read

The Dot Product

The dot product of two vectors u,vRm\mathbf{u}, \mathbf{v} \in \mathbb{R}^m is the sum of their entry-wise products: uv=u1v1+u2v2++umvm\mathbf{u} \cdot \mathbf{v} = u_1 v_1 + u_2 v_2 + \cdots + u_m v_m. The result is a single real number — not a vector.

Using matrix notation, the dot product is simply a matrix product: uv=utv\mathbf{u} \cdot \mathbf{v} = \mathbf{u}^t \mathbf{v}. This is one pass of the "two-finger rule" — exactly as we compute any matrix-vector product, but the output is 1×11 \times 1.

The dot product captures how much two vectors "agree in direction." When both vectors point the same way, the dot product is large and positive. When they point in opposite directions, it is large and negative. When they are perpendicular, it is exactly zero.

Formal View

Definition 6.1 — Dot Product
Let u,vRm\mathbf{u}, \mathbf{v} \in \mathbb{R}^m. Their dot product is
uv:=i=1muivi=utv.\mathbf{u} \cdot \mathbf{v} := \sum_{i=1}^m u_i v_i = \mathbf{u}^t \mathbf{v}.
Theorem 6.2 — Properties of the Dot Product
For all u,v,wRm\mathbf{u}, \mathbf{v}, \mathbf{w} \in \mathbb{R}^m and cRc \in \mathbb{R}:\begin{enumerate} \item (u+v)w=uw+vw(\mathbf{u} + \mathbf{v}) \cdot \mathbf{w} = \mathbf{u} \cdot \mathbf{w} + \mathbf{v} \cdot \mathbf{w} \item (cu)v=c(uv)(c\mathbf{u}) \cdot \mathbf{v} = c(\mathbf{u} \cdot \mathbf{v}) \item uv=vu\mathbf{u} \cdot \mathbf{v} = \mathbf{v} \cdot \mathbf{u} (commutativity) \item uu0\mathbf{u} \cdot \mathbf{u} \geq 0, with equality iff u=0\mathbf{u} = \mathbf{0} (positivity) \end{enumerate}

Commutativity also gives linearity in the second argument: u(v+cw)=uv+c(uw)\mathbf{u} \cdot (\mathbf{v} + c\mathbf{w}) = \mathbf{u} \cdot \mathbf{v} + c(\mathbf{u} \cdot \mathbf{w}).

Interactive Visualization

Dot Product and Angle

Why This Matters

The dot product is the foundation of all geometric concepts in linear algebra — length, angle, and projection all derive from it.

  • Recommendation systems compute dot products between user and item vectors to score how well a movie matches a viewer's preferences
  • In physics, work done by a force F\mathbf{F} along displacement d\mathbf{d} is the dot product Fd\mathbf{F} \cdot \mathbf{d}
  • Cosine similarity — the backbone of search engines and NLP embeddings — is a normalized dot product
  • Convolutional neural networks compute dot products between filter weights and input patches at every position

Quiz

Question 1

Compute uv\mathbf{u} \cdot \mathbf{v} for u=(1,2,3)\mathbf{u} = (1, -2, 3) and v=(4,0,1)\mathbf{v} = (4, 0, -1).

Question 2

The dot product is commutative: uv=vu\mathbf{u} \cdot \mathbf{v} = \mathbf{v} \cdot \mathbf{u} for all vectors.

Question 3

If vv=0\mathbf{v} \cdot \mathbf{v} = 0, what can you conclude?

Common Mistakes

  • Treating the dot product as a vector operation — uv\mathbf{u} \cdot \mathbf{v} is a scalar, not a vector.
  • Confusing utv\mathbf{u}^t \mathbf{v} (a scalar) with uvt\mathbf{u} \mathbf{v}^t (an m×mm \times m outer product matrix).
  • Assuming uv>0\mathbf{u} \cdot \mathbf{v} > 0 means u\mathbf{u} and v\mathbf{v} point in the same direction — they just point within 90° of each other.