Dot Product (A·B) Explained- Definition, Formula, and Geometric Meaning
What Is the Dot Product?
The dot product (also called the scalar product or inner product) is an operation that takes two vectors of the same dimension and returns a single number. It's written as A · B and pronounced "A dot B."
Unlike vector addition, which gives you another vector, the dot product collapses everything into one value. That value can be positive, negative, or zero depending on the angle between the two vectors.
The Formula
Component Form
If you have two vectors in 3D space:
A = (a₁, a₂, a₃) and B = (b₁, b₂, b₃)
Then the dot product is:
A · B = a₁b₁ + a₂b₂ + a₃b₃
For 2D vectors it's the same idea — just two terms instead of three. You multiply matching components and add them up. That's it.
Geometric Form
The dot product also has a geometric interpretation:
A · B = |A| |B| cos(θ)
Where |A| and |B| are the magnitudes (lengths) of the vectors, and θ is the angle between them. This form is useful when you know the angle but not the individual components.
Geometric Meaning
The dot product tells you how much one vector points in the same direction as another.
- If A · B > 0, the angle between them is less than 90° — they point somewhat in the same direction.
- If A · B = 0, the vectors are perpendicular (orthogonal). This is huge in physics and computer graphics.
- If A · B < 0, the angle is greater than 90° — they point in opposite directions.
Think of it as a measure of projection. If you shine a light perpendicular to vector B, the dot product tells you how much of A you actually see along B's direction.
Key Properties
The dot product has several properties you should know:
- Commutative: A · B = B · A
- Distributive: A · (B + C) = A · B + A · C
- Scalar multiplication: (cA) · B = c(A · B)
- Self-dot product: A · A = |A|² (gives you the squared length of A)
Dot Product vs. Cross Product
Don't confuse these two. They're related but do completely different things.
| Property | Dot Product (A · B) | Cross Product (A × B) |
|---|---|---|
| Result | Scalar (number) | Vector |
| Output dimension | 1D | 3D (or 2D in magnitude) |
| Angle info | cos(θ) | sin(θ) |
| Perpendicular vectors | A · B = 0 | |A × B| = |A||B| |
How to Calculate the Dot Product
Here's a step-by-step example with vectors in 2D:
A = (3, 4) and B = (2, -1)
- Multiply matching components: 3 × 2 = 6, and 4 × (-1) = -4
- Add the results: 6 + (-4) = 2
A · B = 2
That's the dot product. Positive, so the angle between them is acute (less than 90°).
For the geometric form with magnitudes:
|A| = √(3² + 4²) = √25 = 5
|B| = √(2² + (-1)²) = √5
cos(θ) = (A · B) / (|A||B|) = 2 / (5 × √5) ≈ 0.179
θ ≈ 79.7° — which confirms the angle is acute.
Where the Dot Product Shows Up
This isn't just abstract math. The dot product appears everywhere:
- Physics: Work = F · d (force dotted with displacement)
- Computer graphics: Lighting calculations, determining if a surface faces toward or away from a light source
- Machine learning: Similarity measures, neural network operations
- Projection: Finding one vector's shadow onto another
- Engines: Unity, Unreal, and other game engines use it constantly for collision detection and character movement
Common Mistakes to Avoid
- Forgetting the vectors must be the same dimension. You can't dot a 3D vector with a 2D one (unless you pad the 2D one with a zero).
- Confusing dot product with cross product. One gives you a number, the other gives you a vector.
- Not normalizing when comparing directions. If you only care about the angle, divide by the magnitudes first.
Quick Reference
| Formula Type | Equation |
|---|---|
| Component form (3D) | A · B = a₁b₁ + a₂b₂ + a₃b₃ |
| Geometric form | A · B = |A| |B| cos(θ) |
| Cosine of angle | cos(θ) = (A · B) / (|A| |B|) |
| Self-product | A · A = |A|² |
The dot product is one of those operations that looks simple on paper but shows up constantly in real work. Once you understand it's measuring directional alignment, everything else clicks into place.