Dot Product Calculator
Calculate the dot product (scalar product) of two 3D vectors.
What Is Dot Product Calculator?
Dot Product Calculator computes the scalar product of two vectors — a single number that reveals how aligned the vectors are, projects one vector onto another, and calculates work done by forces. The dot product appears throughout physics (work and energy), engineering (signal processing), computer graphics (lighting and shading), and machine learning (similarity measures). Unlike vector addition or cross product, the dot product outputs a scalar (regular number), not a vector.
Consider two vectors: a = (3, 4) and b = (5, 0). The dot product is a · b = (3)(5) + (4)(0) = 15 + 0 = 15. Geometrically, this equals |a| × |b| × cos(θ), where θ is the angle between them. Vector a has magnitude 5, vector b has magnitude 5, and the angle between them is arccos(15/25) = arccos(0.6) ≈ 53.13°. The dot product of 15 tells us the vectors are moderately aligned — neither perpendicular (dot = 0) nor parallel (dot = 25).
The dot product's physical meaning becomes clear with force and displacement. If you push with force F = (10, 0, 0) newtons and an object moves by d = (3, 4, 0) meters, the work done is F · d = (10)(3) + (0)(4) + (0)(0) = 30 joules. Only the component of force in the direction of motion contributes to work — the dot product automatically extracts this parallel component.
How Dot Product Calculator Works: Formulas Explained
Algebraic formula: For vectors a = (a₁, a₂, a₃) and b = (b₁, b₂, b₃), the dot product is a · b = a₁b₁ + a₂b₂ + a₃b₃. Multiply corresponding components, then sum the products. Example: a = (2, -3, 5), b = (4, 1, -2). a · b = (2)(4) + (-3)(1) + (5)(-2) = 8 - 3 - 10 = -5. The result is a scalar, not a vector.
Geometric formula: a · b = |a| × |b| × cos(θ), where |a| and |b| are the magnitudes and θ is the angle between the vectors. This reveals the dot product's geometric meaning: it's the product of one vector's magnitude times the projection of the other vector onto it. Example: |a| = 5, |b| = 8, θ = 60°. a · b = 5 × 8 × cos(60°) = 40 × 0.5 = 20.
Finding the angle: Rearrange the geometric formula: cos(θ) = (a · b) / (|a| × |b|). Then θ = arccos[(a · b) / (|a| × |b|)]. Example: a = (3, 4), b = (5, 0). a · b = 15, |a| = 5, |b| = 5. cos(θ) = 15 / (5 × 5) = 0.6. θ = arccos(0.6) ≈ 53.13°. This is how you find the angle between any two vectors.
Projection formula: The projection of vector a onto vector b is: proj_b(a) = (a · b / |b|²) × b. This gives the component of a that points in b's direction. Example: a = (5, 0), b = (3, 4). a · b = 15, |b|² = 25. proj_b(a) = (15/25) × (3, 4) = 0.6 × (3, 4) = (1.8, 2.4). The projection has magnitude |a| × cos(θ) = 5 × 0.6 = 3.
Working through complete examples: Find (2, 3, 4) · (1, -1, 2). Dot product = (2)(1) + (3)(-1) + (4)(2) = 2 - 3 + 8 = 7. Find the angle between (1, 0, 0) and (0, 1, 0). Dot product = 0, so cos(θ) = 0, meaning θ = 90° — the vectors are perpendicular (orthogonal). Find projection of (6, 8) onto (3, 0). a · b = 18, |b|² = 9. proj = (18/9) × (3, 0) = 2 × (3, 0) = (6, 0). The entire vector (6, 8) projects to (6, 0) on the x-axis.
Step-by-Step Guide to Calculating Dot Products
- Verify vectors have the same dimension. Both vectors must have the same number of components. You can compute the dot product of two 3D vectors, but not a 2D and a 3D vector. Example: (2, 3, 4) and (1, -1, 2) are both 3D — valid. (2, 3) and (1, -1, 2) are incompatible — cannot compute dot product.
- Multiply corresponding components. Pair up components by position: first with first, second with second, third with third. Example: a = (2, -3, 5), b = (4, 1, -2). Products: 2×4 = 8, (-3)×1 = -3, 5×(-2) = -10. Track signs carefully — negative times positive is negative, negative times negative is positive.
- Sum the products. Add all the component products: 8 + (-3) + (-10) = 8 - 3 - 10 = -5. The dot product of (2, -3, 5) and (4, 1, -2) is -5. A negative dot product indicates the vectors point in generally opposite directions (angle > 90°).
- Interpret the result. Dot product > 0: vectors are acute (angle < 90°), pointing in similar directions. Dot product = 0: vectors are perpendicular (orthogonal). Dot product < 0: vectors are obtuse (angle > 90°), pointing in opposite general directions. The magnitude of the dot product indicates strength of alignment.
- Calculate angle if needed. Use θ = arccos[(a · b) / (|a| × |b|)]. First find magnitudes: |a| = √(a₁² + a₂² + a₃²), |b| = √(b₁² + b₂² + b₃²). Then compute cos(θ) = (a · b) / (|a| × |b|). Finally, take arccos to find θ in degrees or radians.
- Apply to your problem. Use the dot product for work calculations (W = F · d), finding angles, projecting vectors, testing orthogonality, or measuring similarity. In machine learning, the dot product measures how similar two feature vectors are — higher dot product means more similar.
Real-World Dot Product Examples
Example 1: Work Done by a Force. A force F = (50, 30, 0) newtons pushes an object through displacement d = (10, 5, 0) meters. Work done: W = F · d = (50)(10) + (30)(5) + (0)(0) = 500 + 150 + 0 = 650 joules. The force has magnitude √(2500 + 900) = √3400 ≈ 58.3 N. Displacement has magnitude √(100 + 25) = √125 ≈ 11.2 m. Angle: cos(θ) = 650 / (58.3 × 11.2) ≈ 0.996, so θ ≈ 5° — nearly aligned, explaining the high work output.
Example 2: Computer Graphics Lighting. A surface has normal vector n = (0, 1, 0) pointing straight up. A light source direction is L = (0.6, 0.8, 0) (already normalized). Diffuse lighting intensity = n · L = (0)(0.6) + (1)(0.8) + (0)(0) = 0.8. The surface receives 80% of maximum light intensity. If the surface were vertical with normal (1, 0, 0), intensity would be (1)(0.6) + (0)(0.8) = 0.6 = 60%. This dot product calculation runs millions of times per second in 3D games.
Example 3: Testing Vector Orthogonality. Are vectors (3, 4, 0) and (4, -3, 5) perpendicular? Compute dot product: (3)(4) + (4)(-3) + (0)(5) = 12 - 12 + 0 = 0. Zero dot product confirms they are orthogonal (perpendicular). This test is essential in computer graphics (checking if surface faces camera), physics (decomposing forces into perpendicular components), and linear algebra (finding orthogonal bases).
Example 4: Signal Processing Correlation. Two discrete signals are represented as vectors: s₁ = (1, 2, 3, 4, 5) and s₂ = (2, 4, 6, 8, 10). Dot product: 1×2 + 2×4 + 3×6 + 4×8 + 5×10 = 2 + 8 + 18 + 32 + 50 = 110. High positive value indicates strong correlation — s₂ is exactly 2×s₁. If s₂ were (5, 4, 3, 2, 1), dot product would be 1×5 + 2×4 + 3×3 + 4×2 + 5×1 = 35 — lower correlation. If s₂ were (-1, -2, -3, -4, -5), dot product would be -55 — negative correlation (inverse relationship).
Example 5: Projecting Force onto Inclined Plane. Gravity acts downward: g = (0, 0, -9.8) m/s². An inclined plane has surface direction s = (3, 0, 4) (rising 4 units for every 3 units forward). Unit surface vector: ŝ = (3/5, 0, 4/5) = (0.6, 0, 0.8). Component of gravity along the plane: g · ŝ = (0)(0.6) + (0)(0) + (-9.8)(0.8) = -7.84 m/s². The negative sign indicates gravity pulls down the plane. An object on this plane accelerates at 7.84 m/s² down the slope (ignoring friction).
Common Mistakes in Dot Product Calculations
Confusing dot product with cross product. Dot product gives a scalar (number); cross product gives a vector. Dot product: a · b = a₁b₁ + a₂b₂ + a₃b₃. Cross product: a × b = (a₂b₃ - a₃b₂, a₃b₁ - a₁b₃, a₁b₂ - a₂b₁). Example: (1, 0, 0) · (0, 1, 0) = 0 (scalar). (1, 0, 0) × (0, 1, 0) = (0, 0, 1) (vector). They serve different purposes — dot measures alignment, cross produces a perpendicular vector.
Adding instead of multiplying components. Wrong: (2, 3) · (4, 5) = (2+4, 3+5) = (6, 8). Correct: (2, 3) · (4, 5) = 2×4 + 3×5 = 8 + 15 = 23. The dot product multiplies corresponding components, then sums — it does not produce a vector. The result is always a scalar.
Forgetting that dot product can be negative. A negative dot product doesn't indicate an error — it means the vectors point in generally opposite directions (angle between 90° and 180°). Example: (1, 0) · (-1, 0) = -1. The vectors are anti-parallel (180° apart). Cosine of 180° is -1, so the negative dot product is correct.
Mismatching component positions. Multiply first component with first, second with second, etc. Wrong: (2, 3, 4) · (5, 6, 7) = 2×6 + 3×7 + 4×5 = 12 + 21 + 20 = 53. Correct: (2, 3, 4) · (5, 6, 7) = 2×5 + 3×6 + 4×7 = 10 + 18 + 28 = 56. Position matters — components must align by index.
Pro Tips for Dot Product Applications
Use dot product for fast orthogonality testing. Instead of calculating angles, just check if a · b = 0. This is computationally cheaper and avoids floating-point errors from arccos. In 3D modeling, test if a surface normal is perpendicular to the view direction (a · b ≈ 0 means edge-on silhouette).
Apply to similarity measurement. In machine learning and information retrieval, the dot product (or cosine similarity, which normalizes by magnitudes) measures how similar two vectors are. Document vectors with high dot product share similar word distributions. Recommendation systems use dot products to match user preferences with item features.
Decompose vectors efficiently. Any vector v can be split into components parallel and perpendicular to a direction n: v_parallel = (v · n̂) n̂ and v_perpendicular = v - v_parallel, where n̂ is a unit vector. This decomposition is essential for analyzing forces on inclined planes, separating signal from noise, and computing reflections.
Recognize the connection to matrix multiplication. The dot product of two vectors equals the matrix product of a row vector times a column vector: [a₁, a₂, a₃] × [b₁; b₂; b₃] = a₁b₁ + a₂b₂ + a₃b₃. This connection underlies neural network computations, where each neuron computes a dot product of inputs with weights.
Frequently Asked Questions
Zero dot product means the vectors are perpendicular (orthogonal) — the angle between them is exactly 90°. Geometrically, one vector has no component in the direction of the other. Physically, a force perpendicular to displacement does zero work. In graphics, a surface with normal perpendicular to the light direction receives no direct illumination.
No. Since a · b = |a| × |b| × cos(θ) and cos(θ) ≤ 1, the dot product is always ≤ |a| × |b|. Maximum dot product occurs when vectors are parallel (θ = 0°, cos = 1), giving a · b = |a| × |b|. If your calculation shows a · b > |a| × |b|, there's an arithmetic error.
For complex vectors, use the Hermitian dot product: a · b = Σ aᵢ* × bᵢ, where aᵢ* is the complex conjugate of aᵢ. This ensures the dot product of a vector with itself is real and non-negative. For real vectors, conjugation has no effect, so the standard formula applies. Complex dot products are essential in quantum mechanics.
The law of cosines c² = a² + b² - 2ab×cos(C) can be derived from the dot product. For vectors a and b forming two sides of a triangle, the third side is (a - b). Then |a - b|² = (a - b) · (a - b) = |a|² + |b|² - 2(a · b) = |a|² + |b|² - 2|a||b|×cos(θ). This is the law of cosines in vector form.
Related Calculators
You may also find these calculators useful: Cross Product Calculator, Vector Magnitude Calculator, Angle Between Vectors Calculator, Vector Projection Calculator.