The Dot Product: A Complete Guide
What Is the Dot Product?
The dot product (also called the scalar product or inner product) is a fundamental operation that takes two vectors and produces a single number (scalar). For vectors A = (a₁, a₂, …, aₙ) and B = (b₁, b₂, …, bₙ), the dot product is A·B = a₁b₁ + a₂b₂ + … + aₙbₙ. The dot product encodes the relationship between two vectors' magnitudes and the angle between them through the identity A·B = |A||B|cos(θ), making it one of the most important operations in linear algebra, physics, and computer science.
Geometric: A · B = |A| · |B| · cos(θ)
Angle: θ = arccos(A·B / (|A| · |B|))
Properties: Commutative, Distributive, NOT Associative
Algebraic vs Geometric Definition
The algebraic definition (sum of component products) is computational: multiply corresponding components and add. The geometric definition (|A||B|cos θ) reveals meaning: the dot product measures how much two vectors "agree" in direction. When θ = 0° (parallel, same direction), cos(0°) = 1 and A·B = |A||B| — maximum positive value. When θ = 90° (perpendicular), cos(90°) = 0 and A·B = 0. When θ = 180° (antiparallel), cos(180°) = −1 and A·B = −|A||B| — maximum negative value. That these two definitions are equivalent is a consequence of the law of cosines.
A·B = (3)(−2) + (4)(5) = −6 + 20 = 14.
|A| = √(9+16) = 5, |B| = √(4+25) = √29 ≈ 5.385.
cos(θ) = 14/(5 × 5.385) = 0.5197, θ = arccos(0.5197) ≈ 58.67°.
Orthogonality: The Zero Dot Product
The most important geometric fact about the dot product: A·B = 0 if and only if A and B are perpendicular (orthogonal), assuming neither is the zero vector. This test is the foundation of orthogonal bases, the Gram-Schmidt process, Fourier analysis, and countless algorithms. In higher dimensions where "perpendicular" is hard to visualize, A·B = 0 is the precise mathematical definition of orthogonality. Orthogonal vectors are independent — knowing one tells you nothing about the other.
Vector Projection
The scalar projection of A onto B is comp_B(A) = A·B/|B|, the signed length of A's "shadow" on B. The vector projection is proj_B(A) = (A·B/|B|²)·B, a vector along B representing A's component in B's direction. The rejection (perpendicular component) is A − proj_B(A). Together, projection and rejection decompose any vector into parallel and perpendicular components relative to another vector, which is essential for physics (force decomposition), computer graphics (lighting), and data analysis (PCA).
Vector projection: proj_B(A) = (A·B / |B|²) · B
Rejection: rej_B(A) = A − proj_B(A)
Verify: proj + rej = A ✓
Cosine Similarity
Cosine similarity = A·B/(|A|·|B|) = cos(θ) measures directional similarity on a scale from −1 to +1. A value of 1 means identical direction, 0 means orthogonal, and −1 means opposite directions. This metric ignores magnitude — only direction matters. It's the backbone of modern information retrieval: search engines rank documents by cosine similarity between query and document vectors. In NLP, word embeddings use cosine similarity to capture semantic relationships ("king" − "man" + "woman" ≈ "queen"). In recommendation systems, it measures user preference similarity.
Work Done by a Force
In physics, work is the dot product of force and displacement: W = F·d = |F||d|cos(θ). When you push a box horizontally (θ = 0°), all force contributes to work. When you carry a box horizontally (force upward, θ = 90°), work is zero — you're not moving it in the force direction. When pushing against motion (θ = 180°), work is negative (friction). This extends to variable forces: W = ∫F·ds is a line integral of the dot product along a path.
W = F·d = 6×10 + 8×0 = 60 J.
|F| = 10N, |d| = 10m, θ = arccos(60/100) = 53.13°.
Only the horizontal component (6N) does work.
Properties of the Dot Product
The dot product is commutative (A·B = B·A), distributive (A·(B+C) = A·B + A·C), bilinear ((kA)·B = k(A·B)), and positive-definite (A·A ≥ 0, equals 0 only if A = 0). The Cauchy-Schwarz inequality states |A·B| ≤ |A||B|, with equality when A and B are parallel. This is not just a theoretical bound — it guarantees cos(θ) always falls between −1 and 1, which is why arccos always produces a valid angle.
Dot Product in n Dimensions
Unlike the cross product (only 3D), the dot product generalizes to any number of dimensions: A·B = Σᵢ aᵢbᵢ. In data science, feature vectors may have hundreds or thousands of components. In quantum mechanics, the inner product 〈ψ|φ〉 generalizes the dot product to complex vector spaces. The formula θ = arccos(A·B/(|A||B|)) defines angle in any dimension, even where geometric intuition fails.
Dot Product vs Cross Product
The dot product returns a scalar, measures how parallel vectors are, and works in any dimension. The cross product returns a vector, measures how perpendicular vectors are, and works only in 3D. Numerically: A·B = |A||B|cos(θ) while |A×B| = |A||B|sin(θ). When vectors are parallel, the dot product is maximum and the cross product is zero; when perpendicular, the opposite. Together they provide a complete picture of vector relationships.
How to Use This Calculator
Choose Component Mode to enter x, y (and z for 3D) values directly, or Magnitude & Angle Mode if you know |A|, |B|, and the angle θ between them. Click "Calculate Dot Product" to see: the scalar result, angle θ in degrees and radians, orthogonality badge, scalar and vector projections, cosine similarity, work interpretation, and a full step-by-step solution. The visualization shows both vectors, the angle arc, and the projection shadow on an interactive coordinate grid.