Vector Dot Product & Projection

⚡ Key Takeaways

The dot product combines two vectors into a single number (scalar) measuring how much they point in the same direction: a⃗⋅b⃗=∣a⃗∣∣b⃗∣cos⁡θ\vec{a}\cdot\vec{b}=|\vec{a}||\vec{b}|\cos\theta. Projection uses it to find the "shadow" one vector casts on another. Used everywhere in physics (work, flux), computer graphics, and machine learning. Foundational since the late 1800s (Gibbs, Heaviside).

💡 The Core Insight

The dot product answers one question: "How much do these two vectors agree in direction?" When they point the same way, it is large and positive; when perpendicular, it is exactly zero; when opposed, it is negative. This single number unlocks angles, perpendicularity tests, work in physics, and the decomposition of any vector into useful directions.

Formal Statement

DefinitionDot Product — Two Equivalent Definitions

For vectors a⃗\vec{a} and b⃗\vec{b} in R2\mathbb{R}^2 or R3\mathbb{R}^3, the dot product is a scalar defined geometrically by:

1
a⃗⋅b⃗=∣a⃗∣ ∣b⃗∣cos⁡θ\quad \vec{a}\cdot\vec{b} = |\vec{a}|\,|\vec{b}|\cos\theta

Derivation hint: This is the definition; θ\theta is the angle between the two vectors when placed tail-to-tail, with 0≤θ≤π0 \le \theta \le \pi. Equivalently, in component form (with a⃗=⟨a1,a2,a3⟩\vec{a}=\langle a_1,a_2,a_3\rangle, b⃗=⟨b1,b2,b3⟩\vec{b}=\langle b_1,b_2,b_3\rangle):

2
a⃗⋅b⃗=a1b1+a2b2+a3b3\quad \vec{a}\cdot\vec{b} = a_1 b_1 + a_2 b_2 + a_3 b_3

Derivation hint: Expand a⃗⋅b⃗\vec{a}\cdot\vec{b} using distributivity over the standard basis i^,j^,k^\hat{i},\hat{j},\hat{k} and the facts i^⋅i^=1\hat{i}\cdot\hat{i}=1, i^⋅j^=0\hat{i}\cdot\hat{j}=0, etc.

Symbols: ∣a⃗∣|\vec{a}| is the magnitude (length) of a⃗\vec{a}; θ\theta is the angle between them; a1,a2,a3a_1,a_2,a_3 are the scalar components of a⃗\vec{a}.

DefinitionMagnitude from the Dot Product

The length of a vector is the square root of its dot product with itself:

3
∣a⃗∣=a⃗⋅a⃗=a12+a22+a32\quad |\vec{a}| = \sqrt{\vec{a}\cdot\vec{a}} = \sqrt{a_1^2 + a_2^2 + a_3^2}

Derivation hint: Set b⃗=a⃗\vec{b}=\vec{a} in equation [1]; since θ=0\theta=0, cos⁡θ=1\cos\theta=1, giving a⃗⋅a⃗=∣a⃗∣2\vec{a}\cdot\vec{a}=|\vec{a}|^2.

DefinitionAngle Between Vectors

Solving equation [1] for cos⁡θ\cos\theta gives a formula for the angle:

4
cos⁡θ=a⃗⋅b⃗∣a⃗∣ ∣b⃗∣\quad \cos\theta = \frac{\vec{a}\cdot\vec{b}}{|\vec{a}|\,|\vec{b}|}

Derivation hint: Divide both sides of [1] by ∣a⃗∣∣b⃗∣|\vec{a}||\vec{b}| (valid for nonzero vectors).

DefinitionScalar and Vector Projection

The scalar projection of b⃗\vec{b} onto a⃗\vec{a} (the signed length of b⃗\vec{b}'s shadow along a⃗\vec{a}) is:

5
compa⃗b⃗=a⃗⋅b⃗∣a⃗∣\quad \text{comp}_{\vec{a}}\vec{b} = \frac{\vec{a}\cdot\vec{b}}{|\vec{a}|}

Derivation hint: From [1], a⃗⋅b⃗=∣a⃗∣∣b⃗∣cos⁡θ\vec{a}\cdot\vec{b}=|\vec{a}||\vec{b}|\cos\theta; the shadow length is ∣b⃗∣cos⁡θ|\vec{b}|\cos\theta, so divide by ∣a⃗∣|\vec{a}|. The vector projection of b⃗\vec{b} onto a⃗\vec{a} (the shadow as an actual vector) is:

6
proja⃗b⃗=(a⃗⋅b⃗∣a⃗∣2)a⃗=(a⃗⋅b⃗a⃗⋅a⃗)a⃗\quad \text{proj}_{\vec{a}}\vec{b} = \left(\frac{\vec{a}\cdot\vec{b}}{|\vec{a}|^2}\right)\vec{a} = \left(\frac{\vec{a}\cdot\vec{b}}{\vec{a}\cdot\vec{a}}\right)\vec{a}

Derivation hint: Multiply the scalar projection [5] by the unit vector a^=a⃗/∣a⃗∣\hat{a}=\vec{a}/|\vec{a}| to give it the direction of a⃗\vec{a}.

TheoremAlgebraic Properties

For vectors a⃗,b⃗,c⃗\vec{a},\vec{b},\vec{c} and scalar kk:

7
a⃗⋅b⃗=b⃗⋅a⃗(commutative)\quad \vec{a}\cdot\vec{b}=\vec{b}\cdot\vec{a} \quad\text{(commutative)}

Derivation hint: Component products aibi=biaia_ib_i=b_ia_i commute in [2].

8
a⃗⋅(b⃗+c⃗)=a⃗⋅b⃗+a⃗⋅c⃗(distributive)\quad \vec{a}\cdot(\vec{b}+\vec{c})=\vec{a}\cdot\vec{b}+\vec{a}\cdot\vec{c} \quad\text{(distributive)}

Derivation hint: Expand using [2] and the distributivity of ordinary multiplication.

9
(ka⃗)⋅b⃗=k(a⃗⋅b⃗)(scalar)\quad (k\vec{a})\cdot\vec{b}=k(\vec{a}\cdot\vec{b}) \quad\text{(scalar)}

Derivation hint: Factor kk from each term kaibika_i b_i in [2].

TheoremPerpendicularity Test

Two nonzero vectors are orthogonal (perpendicular) if and only if their dot product is zero:

10
a⃗⊥b⃗  ⟺  a⃗⋅b⃗=0\quad \vec{a}\perp\vec{b} \iff \vec{a}\cdot\vec{b}=0

Derivation hint: In [1], with nonzero magnitudes, a⃗⋅b⃗=0\vec{a}\cdot\vec{b}=0 forces cos⁡θ=0\cos\theta=0, i.e. θ=90∘\theta=90^\circ.

Why It Holds / Derivation

ProofEquivalence of the Geometric and Algebraic Definitions

We show ∣a⃗∣∣b⃗∣cos⁡θ=a1b1+a2b2+a3b3|\vec{a}||\vec{b}|\cos\theta = a_1b_1+a_2b_2+a_3b_3 using the Law of Cosines.

Step 1. Place a⃗\vec{a} and b⃗\vec{b} tail-to-tail. The vector from the tip of a⃗\vec{a} to the tip of b⃗\vec{b} is b⃗−a⃗\vec{b}-\vec{a}. These three vectors form a triangle with sides ∣a⃗∣|\vec{a}|, ∣b⃗∣|\vec{b}|, and ∣b⃗−a⃗∣|\vec{b}-\vec{a}|, with angle θ\theta between the first two.

Step 2. Apply the Law of Cosines to that triangle:

11
∣b⃗−a⃗∣2=∣a⃗∣2+∣b⃗∣2−2∣a⃗∣∣b⃗∣cos⁡θ\quad |\vec{b}-\vec{a}|^2 = |\vec{a}|^2 + |\vec{b}|^2 - 2|\vec{a}||\vec{b}|\cos\theta

Derivation hint: Standard Law of Cosines with the included angle θ\theta.

Step 3. Expand the left side using components. With b⃗−a⃗=⟨b1−a1, b2−a2, b3−a3⟩\vec{b}-\vec{a}=\langle b_1-a_1,\,b_2-a_2,\,b_3-a_3\rangle:

12
∣b⃗−a⃗∣2=∑i(bi−ai)2=∑ibi2−2∑iaibi+∑iai2\quad |\vec{b}-\vec{a}|^2 = \sum_i (b_i-a_i)^2 = \sum_i b_i^2 - 2\sum_i a_ib_i + \sum_i a_i^2

Derivation hint: Expand each squared binomial (bi−ai)2=bi2−2aibi+ai2(b_i-a_i)^2 = b_i^2 - 2a_ib_i + a_i^2 and sum.

Step 4. Recognize ∑iai2=∣a⃗∣2\sum_i a_i^2 = |\vec{a}|^2 and ∑ibi2=∣b⃗∣2\sum_i b_i^2 = |\vec{b}|^2. Substitute [12] into [11]:

∣a⃗∣2+∣b⃗∣2−2∑iaibi=∣a⃗∣2+∣b⃗∣2−2∣a⃗∣∣b⃗∣cos⁡θ|\vec{a}|^2 + |\vec{b}|^2 - 2\sum_i a_ib_i = |\vec{a}|^2+|\vec{b}|^2 - 2|\vec{a}||\vec{b}|\cos\theta

Step 5. Cancel ∣a⃗∣2+∣b⃗∣2|\vec{a}|^2+|\vec{b}|^2 from both sides and divide by −2-2:

∑iaibi=∣a⃗∣∣b⃗∣cos⁡θ\sum_i a_ib_i = |\vec{a}||\vec{b}|\cos\theta

This is exactly equations [2] = [1]. ■\blacksquare

∎
mathematician · Josiah Willard Gibbs | 1839–1903

The American physicist and mathematician Gibbs, professor at Yale, developed modern vector analysis in the 1880s as a streamlined alternative to Hamilton's quaternions. In his lecture notes (later published as Vector Analysis, 1901, co-authored with E. B. Wilson) he introduced the now-standard dot and cross product notation. Working independently, the British engineer Oliver Heaviside reached very similar formulations. Their notation triumphed because it cleanly separated the two natural products of vectors — the scalar dot product and the vector cross product — into distinct, physically meaningful operations.

Building Intuition

🧠 Intuition

Think of the dot product as measuring shadow length times length. If the sun is directly above the direction of a⃗\vec{a}, then b⃗\vec{b} casts a shadow onto the line of a⃗\vec{a}. The length of that shadow is ∣b⃗∣cos⁡θ|\vec{b}|\cos\theta. Multiply by ∣a⃗∣|\vec{a}| and you get the dot product. Three signposts make the sign intuitive:

  • Same general direction (θ<90∘\theta < 90^\circ): shadow points along a⃗\vec{a}, dot product positive.
  • Perpendicular (θ=90∘\theta = 90^\circ): no shadow, dot product zero.
  • Opposing directions (θ>90∘\theta > 90^\circ): shadow points backward, dot product negative.

Equation [3], ∣a⃗∣=a⃗⋅a⃗|\vec{a}|=\sqrt{\vec{a}\cdot\vec{a}}, reveals that the dot product secretly contains the Pythagorean theorem — distance is just a dot product in disguise.

Figure
Vector projection of b onto a: the shadow of b along the direction of a
vector a vector b proj a b θ

Worked Examples

ExampleAngle Between Two Vectors

Given: a⃗=⟨3,4⟩\vec{a}=\langle 3,4\rangle and b⃗=⟨5,12⟩\vec{b}=\langle 5,12\rangle. Find the angle θ\theta between them.

Step 1 — Dot product (eq [2]):

a⃗⋅b⃗=(3)(5)+(4)(12)=15+48=63\vec{a}\cdot\vec{b}=(3)(5)+(4)(12)=15+48=63

Step 2 — Magnitudes (eq [3]):

∣a⃗∣=32+42=25=5,∣b⃗∣=52+122=169=13|\vec{a}|=\sqrt{3^2+4^2}=\sqrt{25}=5,\qquad |\vec{b}|=\sqrt{5^2+12^2}=\sqrt{169}=13

Step 3 — Cosine (eq [4]):

cos⁡θ=63(5)(13)=6365≈0.9692\cos\theta=\frac{63}{(5)(13)}=\frac{63}{65}\approx 0.9692

Step 4 — Angle:

θ=cos⁡−1(0.9692)≈14.25∘\theta=\cos^{-1}(0.9692)\approx 14.25^\circ
θ≈14.3∘\boxed{\theta \approx 14.3^\circ}
ExampleWork Done by a Force

Given: A constant force F⃗=⟨12,5⟩\vec{F}=\langle 12, 5\rangle newtons acts on an object as it moves through displacement d⃗=⟨8,0⟩\vec{d}=\langle 8, 0\rangle metres. Find the work done.

Step 1 — Work is the dot product of force and displacement:

W=F⃗⋅d⃗W=\vec{F}\cdot\vec{d}

Step 2 — Compute (eq [2]):

W=(12)(8)+(5)(0)=96+0=96W=(12)(8)+(5)(0)=96+0=96

Step 3 — Interpret: Only the force component along the displacement (the xx-direction) does work; the 5 N5\,\text{N} vertical component is perpendicular to motion and does none.

W=96 J (joules)\boxed{W = 96\ \text{J (joules)}}
ExampleVector Projection

Given: Project b⃗=⟨4,3⟩\vec{b}=\langle 4,3\rangle onto a⃗=⟨2,0⟩\vec{a}=\langle 2,0\rangle.

Step 1 — Numerator (eq [2]): a⃗⋅b⃗=(2)(4)+(0)(3)=8\vec{a}\cdot\vec{b}=(2)(4)+(0)(3)=8.

Step 2 — Denominator: a⃗⋅a⃗=22+02=4\vec{a}\cdot\vec{a}=2^2+0^2=4.

Step 3 — Vector projection (eq [6]):

proja⃗b⃗=84⟨2,0⟩=2⟨2,0⟩=⟨4,0⟩\text{proj}_{\vec{a}}\vec{b}=\frac{8}{4}\langle 2,0\rangle = 2\langle 2,0\rangle=\langle 4,0\rangle
proja⃗b⃗=⟨4,0⟩\boxed{\text{proj}_{\vec{a}}\vec{b}=\langle 4, 0\rangle}

The shadow of b⃗\vec{b} on the xx-axis has length 4 — exactly the xx-component of b⃗\vec{b}, as expected.

Common Misconceptions

⚠️ The Dot Product Is Not a Vector

The result of a dot product is always a scalar (a single number), never a vector. Writing "a⃗⋅b⃗=⟨…⟩\vec{a}\cdot\vec{b}=\langle\ldots\rangle" is wrong. Do not confuse the dot product with the cross product, which yields a vector. Also note: there is no "vector division," and expressions like 1a⃗\frac{1}{\vec{a}} are meaningless.

⚠️ Projection of b onto a ≠ Projection of a onto b

While the dot product is commutative (a⃗⋅b⃗=b⃗⋅a⃗\vec{a}\cdot\vec{b}=\vec{b}\cdot\vec{a}), projection is not symmetric. The scalar projection a⃗⋅b⃗∣a⃗∣\frac{\vec{a}\cdot\vec{b}}{|\vec{a}|} divides by ∣a⃗∣|\vec{a}|, whereas projecting the other way divides by ∣b⃗∣|\vec{b}|. They are generally different lengths in different directions.

CounterexampleZero Dot Product Does Not Mean a Vector Is Zero

One might think a⃗⋅b⃗=0\vec{a}\cdot\vec{b}=0 implies one of the vectors is zero (as with ordinary numbers, where xy=0xy=0 forces x=0x=0 or y=0y=0). False. Take a⃗=⟨1,0⟩\vec{a}=\langle 1,0\rangle and b⃗=⟨0,1⟩\vec{b}=\langle 0,1\rangle. Then a⃗⋅b⃗=(1)(0)+(0)(1)=0\vec{a}\cdot\vec{b}=(1)(0)+(0)(1)=0, yet both vectors are nonzero. The dot product vanishes simply because they are perpendicular — the "zero-product property" does not transfer to vectors.

Connections

connection

The dot product sits at the centre of a web of related ideas. It is one of two fundamental products of vectors; the other, the Cross Product, produces a perpendicular vector and measures area rather than alignment. The angle formula [4] depends on the Law of Cosines, and the magnitude formula [3] is a restatement of the Pythagorean Theorem in vector form. Projection generalizes to the Gram-Schmidt Process for building orthogonal bases, and the abstract version of the dot product is the Inner Product Space, which underlies advanced linear algebra and quantum mechanics. The concept of Orthogonality — defined by a zero dot product — is one of the most reused ideas in all of mathematics.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1799–1828: Caspar Wessel, Jean-Robert Argand, and Carl Friedrich Gauss develop the geometric representation of complex numbers, an early hint of 2D vector arithmetic.
- 1843: William Rowan Hamilton discovers quaternions; their multiplication contains, hidden inside, both the dot and cross products of 3D vectors.
- 1844: Hermann Grassmann publishes Die lineale Ausdehnungslehre, introducing an abstract "inner product" decades ahead of its time but in nearly unreadable form.
- 1853: Augustin-Louis Cauchy and others formalize inequalities (the Cauchy–Schwarz inequality) that govern dot products.
- 1881: J. Willard Gibbs prints private lecture notes at Yale introducing clean dot and cross product notation.
- 1880s: Oliver Heaviside independently develops vector analysis to reformulate Maxwell's electromagnetism.
- 1901: Gibbs and Edwin Bishop Wilson publish Vector Analysis, cementing the modern notation a⃗⋅b⃗\vec{a}\cdot\vec{b}.
- Early 1900s: David Hilbert and others generalize the dot product to infinite-dimensional inner product spaces, foundational to functional analysis and quantum mechanics.

Subtleties & Limits

open-problem

The dot product as taught here lives comfortably in Euclidean space, but its generalizations raise deep questions. In special relativity, the relevant "inner product" (the Minkowski metric) uses a minus sign — a⃗⋅b⃗=−a0b0+a1b1+a2b2+a3b3\vec{a}\cdot\vec{b}=-a_0b_0+a_1b_1+a_2b_2+a_3b_3 — so a nonzero vector can have zero length (a "null" or light-like vector), breaking the comforting rule that ∣a⃗∣=a⃗⋅a⃗|\vec{a}|=\sqrt{\vec{a}\cdot\vec{a}} is always positive. More abstractly, which spaces admit an inner product compatible with their structure, and how inner products interact with curvature (in Riemannian geometry), remains an active area where the simple high-school dot product becomes a varying field of metrics. Even the question of how to best define "angle" and "projection" in high-dimensional data spaces — where intuition fails and most random vectors are nearly orthogonal — drives ongoing research in data science.

See Also

Cross Product · Inner Product Space · Orthogonality · Law of Cosines · Vectors and Components · Cosine Similarity · Gram-Schmidt Process