Vector Operations
10 solvers available
Fundamentals
Products
Geometric Relations
Dot Product Calculator
Calculate the dot product (scalar product) of two vectors with detailed step-by-step explanations. The dot product measures the extent to which two vectors point in the same direction.
Learn About Dot Product
Understanding the concepts behind calculations.
📑 Quick Navigation
What is the Dot Product?
The dot product (also called the scalar product or inner product) is an operation that takes two vectors and returns a single number (scalar). It measures how much one vector goes in the direction of another.
Core Idea: The dot product answers the question: "If I project vector a onto vector b, how long is the projection?" It quantifies alignment between vectors.
Notation
The dot product of vectors a and b is written as:
And it's read as "a dot b".
💡 Key Insight: Unlike vector addition (which produces another vector), the dot product produces a scalar (a regular number). This is why it's called the "scalar product".
The Formula
Algebraic Definition (Component-wise)
To compute the dot product, multiply corresponding components and add them up.
For 2D Vectors:
For 3D Vectors:
Geometric Definition
Where:
‖a‖is the magnitude (length) of vector a‖b‖is the magnitude (length) of vector bθ(theta) is the angle between the two vectors
📐 Note: The geometric definition shows that the dot product depends on both the lengths of the vectors and the angle between them.
Geometric Interpretation
📏 Projection Interpretation
The dot product a·b equals the length of a multiplied by the length of the projection of b onto a:
This tells you how much of vector b lies in the direction of vector a.
📐 Angle Interpretation
The dot product is maximum when vectors are parallel (θ = 0°, cos θ = 1) and minimum when opposite (θ = 180°, cos θ = -1).
Visual Guide by Angle
- θ = 0° (Parallel, same direction):
a·b = ‖a‖‖b‖→ Maximum positive - 0° < θ < 90° (Acute angle):
a·b > 0→ Positive - θ = 90° (Perpendicular):
a·b = 0→ Zero - 90° < θ < 180° (Obtuse angle):
a·b < 0→ Negative - θ = 180° (Parallel, opposite direction):
a·b = -‖a‖‖b‖→ Maximum negative
💡 Key Insight: The sign of the dot product tells you about the angle:
- Positive → Vectors point in similar directions (acute angle)
- Zero → Vectors are perpendicular (orthogonal)
- Negative → Vectors point in opposite directions (obtuse angle)
Properties of the Dot Product
✅ Commutative
The order doesn't matter.
✅ Distributive
Dot product distributes over addition.
✅ Scalar Multiplication
Scalars can be pulled out.
✅ Relation to Magnitude
Dot product of a vector with itself equals the square of its magnitude.
✅ Orthogonality Condition
If the dot product is zero, the vectors are perpendicular.
✅ Cauchy-Schwarz Inequality
Maximum dot product occurs when vectors are parallel.
Step-by-Step Examples
Example 1: Dot Product of 2D Vectors
Problem: Compute a · b for a = (3, 4) and b = (1, 2)
Step 1: Write vectors in component form
Step 2: Multiply corresponding components
Step 3: Add the products
Solution: a · b = 11
Since 11 > 0, the angle between these vectors is acute (< 90°).
Example 2: Dot Product of 3D Vectors
Problem: Compute u · v for u = (1, -2, 3) and v = (4, 5, -6)
Step 1: Write in column form
Step 2: Multiply corresponding components
Step 3: Add the products
Solution: u · v = -24
Since -24 < 0, the angle between these vectors is obtuse (> 90°).
Example 3: Perpendicular Vectors (Dot Product = 0)
Problem: Show that a = (2, 3) and b = (-3, 2) are perpendicular.
Step 1: Compute dot product
Solution: a · b = 0 → Yes, they are perpendicular!
This is a quick way to check orthogonality.
Example 4: Dot Product of a Vector with Itself
Problem: Compute v · v for v = (3, 4)
Notice that ‖v‖ = √(3² + 4²) = √25 = 5, so v·v = 25 = 5² = ‖v‖²
Solution: v · v = 25 = ‖v‖² ✓
Example 5: Dot Product with Zero Vector
Problem: Compute a · 0 for any vector a
Solution: The dot product of any vector with the zero vector is always 0.
Relation to Angle Between Vectors
The dot product formula can be rearranged to find the angle between any two vectors:
📐 Formula for Angle
Where θ is the angle between vectors a and b (0° to 180°).
🎯 Quick Reference
- θ = 0°: Same direction →
a·b = ‖a‖‖b‖ - θ = 90°: Perpendicular →
a·b = 0 - θ = 180°: Opposite →
a·b = -‖a‖‖b‖
Example: Finding the Angle
Problem: Find the angle between a = (1, 0) and b = (1, 1)
Step 1: Compute dot product
Step 2: Compute magnitudes
Step 3: Apply the formula
Solution: The angle between (1,0) and (1,1) is 45°.
Real-World Applications
📊 Machine Learning & Data Science
- Cosine Similarity: Measures document/text similarity using normalized dot product
- Recommendation Systems: Find similar users or products
- PCA (Principal Component Analysis): Uses dot products to find variance directions
- Kernel Methods: Dot products in higher-dimensional spaces
🚀 Physics
- Work Formula:
W = F · d(work = force dot displacement) - Power:
P = F · v(force dot velocity) - Electric Flux:
Φ = E · A(field dot area) - Magnetic Flux:
Φ = B · A
📐 Computer Graphics
- Lighting Calculations: Dot product determines light intensity on surfaces
- Back-face Culling: Determine if a polygon is visible
- Shadow Determination: Check if a point is in shadow
- Reflection Vectors: Compute how light bounces
🧠 Mathematics
- Orthogonality Checking: Test if vectors are perpendicular
- Projections: Decompose vectors into components
- Gram-Schmidt Process: Orthogonalize sets of vectors
- Least Squares: Minimize error using dot products
🎮 Game Development
- Enemy Detection: Check if enemy is in front of player
- Field of View: Determine if an object is within viewing angle
- Collision Detection: Projection-based collision response
📈 Economics & Finance
- Portfolio Theory: Covariance calculations use dot products
- Correlation Analysis: Similarity between financial instruments
- Risk Assessment: Measure relationships between assets
Common Mistakes to Avoid
- ❌ Confusing dot product with vector addition: Dot product produces a scalar, not a vector. You can't visualize it as an arrow!
- ❌ Forgetting to multiply all components: In n-dimensions, you must multiply all n pairs of components.
- ❌ Sign errors with negative components: Be careful: (-2) × 5 = -10, not 10!
- ❌ Thinking dot product of zero means zero vectors: Zero dot product means perpendicular vectors, not necessarily zero vectors.
- ❌ Misapplying the geometric formula: You need both magnitudes AND the angle — can't use just one.
- ❌ Assuming dot product is associative:
(a·b)·cdoesn't make sense becausea·bis a scalar.
⚠️ Common Error Example:
Wrong: (1,2) · (3,4) = (1+2) × (3+4) = 3 × 7 = 21 → This is NOT correct!
Correct: (1,2) · (3,4) = 1×3 + 2×4 = 3 + 8 = 11
Remember: Multiply corresponding components, then add. Don't add components first!
Frequently Asked Questions
Q: Why is it called the "dot product"?
A: Because we write it with a dot (·) between the vectors, like a·b.
Q: Is the dot product commutative?
A: Yes! a·b = b·a. The order doesn't matter because multiplication of real numbers is commutative.
Q: What does a dot product of zero mean?
A: It means the vectors are perpendicular (orthogonal). Neither vector needs to be zero.
Q: Can the dot product be negative?
A: Yes! A negative dot product means the angle between vectors is obtuse (> 90°).
Q: What's the difference between dot product and cross product?
A: Dot product produces a scalar (number). Cross product produces a vector perpendicular to both inputs (only in 3D).
Q: How is the dot product related to cosine similarity?
A: Cosine similarity = (a·b)/(‖a‖‖b‖) = cos θ. It measures the angle between vectors regardless of their lengths.
Q: Can I take the dot product of a vector with itself?
A: Yes! a·a = ‖a‖², which is the square of its length. This is always non-negative and zero only if a is the zero vector.
Q: Why is the dot product useful in machine learning?
A: It's used in similarity measures (cosine similarity), linear regression, neural networks (weighted sums), and kernel methods.
Practice Problems
Beginner
- Compute
(2, 3) · (4, 1) - Compute
(-1, 5) · (3, -2) - Compute
(1, 2, 3) · (4, 5, 6) - Find
v · vforv = (3, 4)and verify it equals‖v‖²
Intermediate
- Determine if
(2, -3, 1)and(4, 2, -2)are perpendicular. - Find the angle between
(1, 0)and(1, √3) - For what value of
kare(2, k)and(3, -6)perpendicular? - Compute
(2a)·(3b)ifa·b = 5
Advanced
- Prove that
‖a + b‖² = ‖a‖² + ‖b‖² + 2(a·b) - If
a·b = 0anda·c = 0, what can you say abouta·(b + c)? - Find the projection of
(3, 4)onto(1, 0)using the dot product.
Click to reveal solutions
1. (2)(4) + (3)(1) = 8 + 3 = 11
2. (-1)(3) + (5)(-2) = -3 + (-10) = -13
3. (1)(4) + (2)(5) + (3)(6) = 4 + 10 + 18 = 32
4. (3)(3) + (4)(4) = 9 + 16 = 25, and ‖v‖² = 5² = 25 ✓
5. (2)(4) + (-3)(2) + (1)(-2) = 8 - 6 - 2 = 0 → Yes, perpendicular
6. cos θ = (1·1 + 0·√3)/(1·2) = 1/2 → θ = 60°
7. (2)(3) + (k)(-6) = 0 → 6 - 6k = 0 → k = 1
8. (2a)·(3b) = 6(a·b) = 6 × 5 = 30
9. ‖a+b‖² = (a+b)·(a+b) = a·a + a·b + b·a + b·b = ‖a‖² + ‖b‖² + 2(a·b)
10. a·(b+c) = a·b + a·c = 0 + 0 = 0
11. proj = ((3,4)·(1,0))/(‖(1,0)‖²) × (1,0) = 3/1 × (1,0) = (3,0)
Summary
🎯 Key Takeaways
- Definition:
a·b = a₁b₁ + a₂b₂ + ... + aₙbₙ(component-wise multiplication sum) - Geometric meaning:
a·b = ‖a‖‖b‖ cos θ(measures alignment) - Output: A scalar (number), not a vector
- Zero dot product: Vectors are perpendicular (orthogonal)
- Positive dot product: Acute angle (< 90°)
- Negative dot product: Obtuse angle (> 90°)
- a·a = ‖a‖² (dot product with itself equals squared magnitude)
- Applications: Work, lighting, cosine similarity, projections
💡 Pro Tip: Use dot product to check if vectors are perpendicular, find angles, compute work/physics quantities, and measure similarity in machine learning.
Try It Yourself!
Use the calculator above to practice dot products:
- Enter your vectors as comma-separated values (e.g.,
3,4for a 2D vector) - Click "Calculate" to see:
- Component-wise multiplication
- Sum of products
- Resultant dot product
- Angle between vectors (if magnitudes computed)
Test these examples:
- Positive dot product:
(3,4)·(1,2)→3×1 + 4×2 = 11 - Negative dot product:
(5,-2)·(-1,3)→5×(-1) + (-2)×3 = -11 - Perpendicular:
(2,3)·(-3,2)→2×(-3) + 3×2 = 0 - 3D:
(1,0,0)·(0,1,0)→0(perpendicular axes) - Same vector:
(3,4)·(3,4)→25 = 5²
📐 Pro Tip: Try computing a·a for any vector — it always equals the square of its length! This is a great way to check your magnitude calculations.