Dot Product Calculator
Enter the components of two vectors to find their dot product, the angle between them, and whether they are orthogonal. Supports 2D and 3D vectors.
The dot product (also called scalar product or inner product) is a fundamental operation on two vectors that produces a single number (scalar). Written A · B or ⟨A, B⟩, it captures how "aligned" two vectors are. Maximum when parallel (same direction), zero when perpendicular, negative when pointing opposite ways.
The formula is simple: multiply corresponding components and sum. For A = (a₁, a₂, a₃) and B = (b₁, b₂, b₃): A · B = a₁b₁ + a₂b₂ + a₃b₃. The result is geometric: A · B = |A| × |B| × cos(θ), where θ is the angle between vectors. This gives us a way to find angles, projections, work done by forces, and similarity in high-dimensional spaces.
Dot product is the foundation of countless mathematical and computational tools: - **Physics**: work done by a force is W = F · d (force projected onto displacement). - **Computer graphics**: lighting calculations use dot product (Lambert's cosine law). - **Machine learning**: cosine similarity ranks documents/items by direction similarity. - **Statistics**: correlation is essentially a normalized dot product. - **Engineering**: projecting forces onto axes, decomposing motion.
Unlike the cross product, dot product works in any dimension. In 100-dimensional feature space (text embeddings), the dot product still measures alignment via cos(θ). This makes it the workhorse of modern AI and information retrieval systems.
Common applications: physics (work, projection), computer graphics (lighting, shading), machine learning (similarity), statistics (correlation), engineering (force decomposition), and any analysis involving directional relationships between quantities.
Inputs
Results
Dot Product (A·B)
32
|A| (magnitude)
3.741657
|B| (magnitude)
8.774964
Angle Between
12.933154° (0.225726 rad)
Orthogonal?
No
Formula
How to use this calculator
- Choose 2D or 3D dimensions.
- Enter components of vector A.
- Enter components of vector B.
- Calculator returns dot product, magnitudes, and angle.
- Result interpretation: 0 = perpendicular, positive = aligned, negative = opposite.
- For unit vectors: dot product = cos(θ) directly.
Worked examples
Work calculation
**Scenario:** Force F = (50, 0, 0) N pushes block 10 m at 30° below horizontal: displacement d = (8.66, 0, -5). **Calculation:** W = F · d = 50×8.66 + 0×0 + 0×(-5) = 433 J. **Result:** ~433 J of work. Only horizontal component of displacement matters (force is horizontal). Total displacement is 10 m, but work uses projection onto force direction (8.66 m).
Surface lighting
**Scenario:** Surface normal N = (0, 1, 0) (pointing up). Light direction L = (0.7, 0.7, 0). Brightness? **Calculation:** N · L = 0×0.7 + 1×0.7 + 0×0 = 0.7. **Result:** Brightness = 0.7 (70% of maximum). Surface is angled 45° from light direction. Used in computer graphics for Lambertian (diffuse) shading. For complete light model: also includes ambient, specular components.
Cosine similarity for recommendations
**Scenario:** User A likes [movies, books, tech]: vector (3, 5, 2). User B likes [movies, books, tech]: vector (1, 4, 0). Similarity? **Calculation:** A · B = 3 + 20 + 0 = 23. |A| = √38 ≈ 6.16. |B| = √17 ≈ 4.12. cos(θ) = 23/(6.16 × 4.12) ≈ 0.907. **Result:** Cosine similarity 0.907 (very similar — both like books and movies). Used in recommendation engines: high similarity users get each other's recommendations. Below 0.5 typically means low similarity.
When to use this calculator
**Use dot product for:**
- **Finding angles between vectors**: cos(θ) = A·B / (|A||B|). - **Testing perpendicularity**: A · B = 0 means perpendicular. - **Physics work**: W = F · d. - **Computer graphics**: lighting calculations. - **Machine learning**: cosine similarity for items/text. - **Statistics**: correlation analysis. - **Projections**: how much of A points in direction B. - **Decomposing vectors**: into parallel and perpendicular components.
**Dot vs cross product:**
Use dot when you need: - A scalar number. - Measure of alignment. - Angle between vectors. - Work or projection.
Use cross when you need: - A perpendicular vector. - Rotational quantity (torque, angular momentum). - Surface normal from edges. - Area of parallelogram.
**Geometric interpretation:**
- A · B = |A||B|cos(θ) measures "alignment". - Magnitude × magnitude × cosine. - Maximum when parallel: |A| × |B|. - Zero when perpendicular. - Minimum (most negative) when antiparallel: -|A| × |B|.
**Cosine similarity intuition:**
For unit vectors: A · B = cos(θ) directly. - 1.0: identical direction. - 0.5: 60° apart. - 0.0: perpendicular. - -0.5: 120° apart. - -1.0: opposite directions.
In ML, often used for word embeddings, document vectors, image features.
**Higher dimensions:**
Dot product works in any dimension by summing products of corresponding components: A · B = Σᵢ aᵢ × bᵢ
In 100-D feature space (text embeddings, image features): same formula, just more terms.
**Physical interpretation:**
For force and displacement: W = F · d = |F||d|cos(θ)
- θ = 0: full work (force aligned with motion). - θ = 90°: no work (force perpendicular to motion). - θ = 180°: negative work (force opposes motion).
Lifting weight: force up, displacement up → positive work. Carrying horizontally: force up, displacement horizontal → zero work.
**Common applications:**
- **CAD**: angle between edges or surfaces. - **Robotics**: aligning end-effector with target. - **Aerospace**: thrust vector vs velocity (for force calculations). - **Navigation**: heading correction. - **Audio**: signal correlation analysis. - **Image recognition**: template matching by dot product. - **Information retrieval**: ranking documents.
**Software:**
- Python NumPy: np.dot(a, b) - MATLAB: dot(a, b) - Most languages: simple loop or built-in.
**Pitfalls:**
- **Forgetting dot is scalar**: result is single number, not vector. - **Wrong dimension**: vectors must have same length. - **Sign**: positive ≠ "magnitude", just means same general direction. - **Cos(θ) ambiguity**: 0 < θ < π only; can't distinguish A vs -A. - **Unit vectors**: simplify A · B = cos(θ); always check magnitudes. - **Order doesn't matter** (commutative) — but for projection direction, it does.
Common mistakes to avoid
- Confusing dot product (scalar) with cross product (vector).
- Forgetting to sum the products of corresponding components.
- Using formula on vectors of different dimensions.
- Wrong angle interpretation (cos can be positive or negative).
- Confusing dot product with element-wise multiplication.
- For unit vectors: forgetting magnitudes are 1, so A · B = cos(θ).
- Calculating angle for parallel vectors (cos = 1 or -1, need to check sign).
- Using radians vs degrees inconsistently in angle output.
Frequently Asked Questions
Sources & further reading
Related Calculators
Cross Product Calculator
Calculate the cross product of two 3D vectors, including the resulting vector and its magnitude.
Vector Calculator
Calculate vector magnitude, unit vector, addition, and subtraction for 2D or 3D vectors.
2x2 Matrix Calculator
Calculate the determinant, inverse, and product of 2x2 matrices.