Does the Dot Product Commute? Mathematical Properties Explained
What Is the Dot Product?
The dot product (also called the scalar product) takes two vectors and spits out a single number. It's one of the most useful operations in linear algebra and shows up everywhere in physics, computer graphics, and machine learning.
For two vectors a = [a₁, a₂, a₃] and b = [b₁, b₂, b₃], the dot product is:
a · b = a₁b₁ + a₂b₂ + a₃b₃
Simple enough. Now let's answer the real question.
Does the Dot Product Commute?
Yes. The dot product is commutative. This means:
a · b = b · a
The order doesn't matter. Multiply component by component and add them up, and you'll get the same result regardless of which vector comes first.
Example
Let a = [1, 2, 3] and b = [4, 5, 6]
a · b = (1 × 4) + (2 × 5) + (3 × 6) = 4 + 10 + 18 = 32
b · a = (4 × 1) + (5 × 2) + (6 × 3) = 4 + 10 + 18 = 32
Same answer. The operation doesn't care about order.
Other Key Properties of the Dot Product
The dot product has several useful properties you should know:
- Commutative: a · b = b · a
- Distributive: a · (b + c) = a · b + a · c
- Scalar multiplication: (ca) · b = c(a · b) = a · (cb)
- Not associative: (a · b) · c doesn't make sense because a · b gives you a scalar, not a vector
The "not associative" part trips people up. You can't chain dot products together the way you might expect. The result of a · b is a number, and you can't dot a number with another vector.
Dot Product vs. Cross Product
Students often confuse the dot product with the cross product. Here's the difference:
| Property | Dot Product | Cross Product |
|---|---|---|
| Result type | Scalar (number) | Vector |
| Commutative? | Yes | No (a × b = -b × a) |
| Works in | Any dimension | Only 3D (or 7D, theoretically) |
| Geometric meaning | Lengths and angle cosine | Area of parallelogram, perpendicular vector |
The cross product doesn't commute. Switch the order and you get the negative of the original result. This matters a lot in physics when calculating torque or magnetic forces.
The Angle Connection
The dot product has a clean geometric interpretation:
a · b = ||a|| × ||b|| × cos(θ)
Where θ is the angle between the vectors and ||a|| is the magnitude of a.
This is why the dot product is commutative — cosine is an even function, so cos(θ) = cos(-θ). The order doesn't affect the angle.
Special Cases
- If a · b = 0, the vectors are perpendicular (orthogonal)
- If a · b > 0, the angle is acute (< 90°)
- If a · b < 0, the angle is obtuse (> 90°)
Getting Started: How to Calculate a Dot Product
Here's the straightforward process:
Step 1: Write Your Vectors
Get your vectors in component form. Let's use u = [2, 7] and v = [3, 1] (2D example)
Step 2: Multiply Corresponding Components
2 × 3 = 6
7 × 1 = 7
Step 3: Add the Products
6 + 7 = 13
That's it. For 3D vectors, just add one more multiplication term.
Quick Python Check
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
dot = np.dot(a, b) # or a @ b
print(dot) # Output: 32
When Commutativity Breaks Down (Sort Of)
The dot product always commutes for real numbers. But there are related concepts where things get weird:
- Inner products in quantum mechanics can be defined differently for complex vector spaces, where you might use <⟨φ|ψ⟩ instead of the standard dot product
- Matrix multiplication doesn't commute in general, which is why some people confuse matrix products with dot products
For standard Euclidean vectors with real components, commutativity holds without exception.
Why This Matters
Knowing the dot product commutes makes code simpler. You don't need to track which vector goes where. In physics, this symmetry simplifies calculations involving work, power, and projections.
In machine learning, cosine similarity — which relies on the dot product — benefits from this property when measuring how similar two vectors are.
The math just works. Order doesn't matter.