01 / 21

Dot Product
& Angles Between Vectors

Discover how the dot product reveals the angle between any two vectors: from perpendicularity to parallelism and everything in between.

Linear Algebra

What Is a Vector?

A vector is a quantity with both magnitude (length) and direction. We write a vector in component form as \(\mathbf{v} = \langle v_1, v_2 \rangle\) in 2D, or \(\mathbf{v} = \langle v_1, v_2, v_3 \rangle\) in 3D.

\(x\)
\(y\)
\(\mathbf{a} = \langle 3, 2 \rangle\)
\(\mathbf{b} = \langle 4, 0.5 \rangle\)
\(O\)
\(\theta\)

What Is the Dot Product?

The dot product (also called the scalar product) takes two vectors and returns a single number. For vectors \(\mathbf{a} = \langle a_1, a_2 \rangle\) and \(\mathbf{b} = \langle b_1, b_2 \rangle\):

In general, for \(n\)-dimensional vectors: \(\mathbf{a} \cdot \mathbf{b} = \displaystyle\sum_{i=1}^{n} a_i b_i\). Multiply corresponding components, then add.

Input
Two vectors of the same dimension
Output
A single scalar (number), not a vector

Why Does It Matter?

The dot product connects algebra (multiplying components) with geometry (angles and projections). It answers fundamental questions:

Angle
Are two vectors pointing in the same direction, opposite, or perpendicular?
Projection
How much of one vector lies along another?
Work
In physics: \(W = \mathbf{F} \cdot \mathbf{d}\) computes work done by a force.

The Geometric Definition

There is a second, equivalent way to define the dot product, using magnitudes and the angle between vectors:

\(\|\mathbf{a}\|\)
\(\|\mathbf{b}\|\)
\(\theta\)

Setting the two definitions equal gives us the angle formula: the bridge between algebra and geometry.

The Angle Formula

To find \(\theta\), take the inverse cosine:

where \(\|\mathbf{a}\| = \sqrt{a_1^2 + a_2^2}\) is the magnitude of \(\mathbf{a}\). The result always satisfies \(0 \leq \theta \leq \pi\) (i.e., \(0^\circ\) to \(180^\circ\)).

Sign Tells the Angle

The sign of \(\mathbf{a} \cdot \mathbf{b}\) immediately reveals the relationship between the vectors:

Positive
\(\theta < 90^\circ\): vectors point roughly the same direction (acute angle)
Zero
\(\theta = 90^\circ\): vectors are perpendicular (orthogonal)
Negative
\(\theta > 90^\circ\): vectors point roughly in opposite directions (obtuse angle)
\(\mathbf{a} \cdot \mathbf{b} > 0\)
Acute
\(\mathbf{a} \cdot \mathbf{b} = 0\)
Perpendicular
\(\mathbf{a} \cdot \mathbf{b} < 0\)
Obtuse

Orthogonality: When \(\mathbf{a} \cdot \mathbf{b} = 0\)

Two non-zero vectors are orthogonal (perpendicular) if and only if their dot product is zero. This is the simplest and most important test in linear algebra.

Example: Let \(\mathbf{a} = \langle 3, 4 \rangle\) and \(\mathbf{b} = \langle -4, 3 \rangle\).

Dot vs Cross Product

Dot Product Cross Product
Notation \(\mathbf{a} \cdot \mathbf{b}\) \(\mathbf{a} \times \mathbf{b}\)
Result type Scalar (number) Vector
Dimensions Any \(n\) 3D only
Measures How aligned How perpendicular
Zero when Perpendicular Parallel
Key formula \(\|\mathbf{a}\|\|\mathbf{b}\|\cos\theta\) \(\|\mathbf{a}\|\|\mathbf{b}\|\sin\theta\;\hat{n}\)

How to Find the Angle

1
Compute the dot product: Multiply corresponding components and add: \(\mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + \cdots\)
2
Find each magnitude: \(\|\mathbf{a}\| = \sqrt{a_1^2 + a_2^2 + \cdots}\) and similarly for \(\mathbf{b}\).
3
Divide: \(\cos\theta = \dfrac{\mathbf{a}\cdot\mathbf{b}}{\|\mathbf{a}\|\,\|\mathbf{b}\|}\)
4
Take inverse cosine: \(\theta = \cos^{-1}(\text{result})\). Use a calculator for the final angle.

Example 1: 2D Vectors

Find the angle between \(\mathbf{a} = \langle 1, 3 \rangle\) and \(\mathbf{b} = \langle 4, 2 \rangle\).

\(x\)
\(y\)
\(\mathbf{a} = \langle 1, 3 \rangle\)
\(\mathbf{b} = \langle 4, 2 \rangle\)
\(\theta\)

Example 2: 3D Vectors

Find the angle between \(\mathbf{u} = \langle 1, 0, -1 \rangle\) and \(\mathbf{v} = \langle 0, 1, 1 \rangle\).

1
Dot product: \(\mathbf{u}\cdot\mathbf{v}=(1)(0)+(0)(1)+(-1)(1)= 0+0-1 =\) \(-1\)
2
Magnitudes: \(\|\mathbf{u}\|=\sqrt{1+0+1}=\sqrt{2}\), \(\|\mathbf{v}\|=\sqrt{0+1+1}=\sqrt{2}\)
3
Divide: \(\cos\theta = \dfrac{-1}{\sqrt{2}\cdot\sqrt{2}} = \dfrac{-1}{2}\)
4
Inverse cosine: \(\theta = \cos^{-1}\!\left(-\tfrac{1}{2}\right) =\) 120°

Example 3: Orthogonal Check

Are \(\mathbf{p} = \langle 2, -5, 1 \rangle\) and \(\mathbf{q} = \langle 3, 1, -1 \rangle\) orthogonal?

Since \(\mathbf{p}\cdot\mathbf{q} = 0\), the vectors are orthogonal. We don't need magnitudes or \(\cos^{-1}\): the zero result is enough.

\(\mathbf{p}\)
\(\mathbf{q}\)
\(90^\circ\)

Key Properties

1
Commutative: \(\mathbf{a}\cdot\mathbf{b} = \mathbf{b}\cdot\mathbf{a}\)
2
Distributive: \(\mathbf{a}\cdot(\mathbf{b}+\mathbf{c}) = \mathbf{a}\cdot\mathbf{b}+\mathbf{a}\cdot\mathbf{c}\)
3
Scalar multiplication: \((k\mathbf{a})\cdot\mathbf{b} = k(\mathbf{a}\cdot\mathbf{b})\)
4
Self-dot: \(\mathbf{a}\cdot\mathbf{a} = \|\mathbf{a}\|^2\) (magnitude squared)
5
Zero vector: \(\mathbf{a}\cdot\mathbf{0} = 0\) for any vector \(\mathbf{a}\)

Common Mistakes

✕ Adding instead of multiplying
The dot product multiplies corresponding components, then sums. Writing \(a_1 + b_1\) instead of \(a_1 \cdot b_1\) is wrong.
✕ Forgetting the square root
The magnitude is \(\sqrt{a_1^2 + a_2^2}\), not \(a_1^2 + a_2^2\). Missing the root gives wrong angles.
✕ Expecting a vector result
The dot product returns a scalar. If your answer is a vector, you likely computed the cross product by mistake.

Summary Table

Condition Dot Product Angle \(\theta\) Meaning
Same direction \(\|\mathbf{a}\|\|\mathbf{b}\|\) \(0^\circ\) Parallel, same way
Acute > 0 \(0^\circ < \theta < 90^\circ\) Somewhat aligned
Perpendicular = 0 \(90^\circ\) Orthogonal
Obtuse < 0 \(90^\circ < \theta < 180^\circ\) Opposing
Opposite direction \(-\|\mathbf{a}\|\|\mathbf{b}\|\) \(180^\circ\) Anti-parallel

Question 1 of 5

What is the dot product of \(\mathbf{a} = \langle 2, -3 \rangle\) and \(\mathbf{b} = \langle 4, 1 \rangle\)?

Question 2 of 5

If \(\mathbf{u}\cdot\mathbf{v} = 0\) and both vectors are non-zero, what is the angle between them?

Question 3 of 5

What is the angle between \(\mathbf{a} = \langle 1, 1 \rangle\) and \(\mathbf{b} = \langle -1, 1 \rangle\)?

Question 4 of 5

The dot product of two vectors is negative. What can you conclude about the angle \(\theta\) between them?

Question 5 of 5

Find the angle between \(\mathbf{u} = \langle 1, 0, 0 \rangle\) and \(\mathbf{v} = \langle 0, 0, 1 \rangle\).