Dot Product Calculator

Calculate the dot product (scalar product) of two vectors in 2D or 3D space. Get instant results with step-by-step solutions.

Vector A

Optional for 2D

Vector B

Optional for 2D

Results

Calculated
Dot Product (A · B)
0
A · B = scalar value

Step-by-Step Solution

Angle Between Vectors
0°
Vector Relationship
-

Frequently Asked Questions

What does a negative dot product mean?

A negative dot product indicates that the angle between the two vectors is greater than 90 degrees. In other words, the vectors point in generally opposite directions. The more negative the value, the closer they are to being exactly opposite (180 degrees apart).

Can the dot product be zero?

Yes! A dot product of zero has special significance: it means the two vectors are perpendicular (orthogonal) to each other. This is because cos(90 degrees) = 0, so regardless of the vectors' magnitudes, perpendicular vectors always have a zero dot product.

How do I find the angle between two vectors using the dot product?

Use the formula: theta = arccos((A · B) / (|A| × |B|)). First calculate the dot product, then divide by the product of both vector magnitudes. Take the inverse cosine (arccos) of the result to get the angle in radians. Multiply by 180/pi to convert to degrees.

Does order matter in dot product calculation?

No, the dot product is commutative, meaning A · B = B · A. Unlike the cross product where order matters, you can calculate the dot product in either order and get the same result. This is because multiplication of individual components is commutative.

What is the dot product used for in machine learning?

In machine learning, dot products are used for similarity measurements (cosine similarity), neural network calculations (weighted sums), and dimensionality reduction. They're fundamental to transformers in NLP, recommendation systems, and image classification algorithms.

Can I use the dot product in 2D?

Absolutely! In 2D, simply use A · B = AxBx + AyBy. The formula works the same way - you just have two components instead of three. All the geometric interpretations about angle and perpendicularity still apply in 2D.

Why is it called the "scalar" product?

It's called the scalar product because the result is always a scalar (a single number) rather than a vector. This distinguishes it from the cross product, which produces a vector result. The term "dot product" comes from the notation using a dot (A · B).

How is work calculated using the dot product?

Work equals force dot displacement: W = F · d. This means only the component of force in the direction of motion contributes to work. If you push perpendicular to the motion (dot product = 0), no work is done. If force and displacement are parallel, work equals force magnitude times distance.

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). For two vectors a = (a₁, a₂, …, aₙ) and b = (b₁, b₂, …, bₙ), the dot product is: a·b = a₁b₁ + a₂b₂ + … + aₙbₙ. In other words: multiply corresponding components and sum the results. Example in 3D: a = (2, 3, −1), b = (4, −1, 5). a·b = (2)(4) + (3)(−1) + (−1)(5) = 8 − 3 − 5 = 0. Since a·b = 0, these vectors are perpendicular (orthogonal)! Geometric interpretation: a·b = ‖a‖ · ‖b‖ · cos(θ), where ‖a‖ is the magnitude of a, ‖b‖ is the magnitude of b, and θ is the angle between them. This formula connects algebra (component multiplication) to geometry (angle between vectors). Key results: If a·b > 0: angle is acute (less than 90°). If a·b = 0: vectors are perpendicular (orthogonal). If a·b < 0: angle is obtuse (greater than 90°). Properties: Commutative: a·b = b·a. Distributive: a·(b + c) = a·b + a·c. Scalar associativity: (ka)·b = k(a·b). Self dot product: a·a = ‖a‖² (magnitude squared).
What is the difference between the dot product and the cross product?
The dot product and cross product are both ways to "multiply" vectors, but they produce fundamentally different results and measure different things. Dot product (a·b): Returns a scalar (single number). Defined for vectors of any dimension. Formula: a₁b₁ + a₂b₂ + … + aₙbₙ. Geometric meaning: ‖a‖‖b‖cos(θ) — captures the "parallel component" relationship. Zero when vectors are perpendicular. Maximum when vectors are parallel. Cross product (a × b): Returns a vector (perpendicular to both a and b). Only defined in 3D space (and mathematically in 7D). Formula: determinant of a 3×3 matrix with i, j, k unit vectors in the first row. Geometric meaning: ‖a‖‖b‖sin(θ)·n̂ — magnitude equals the area of the parallelogram formed by a and b. Zero when vectors are parallel. Maximum when vectors are perpendicular. Is NOT commutative: a × b = −(b × a). Applications: Dot product: work, power, projections, angle calculation, cosine similarity, neural network computations. Cross product: torque, angular momentum, surface normals (for 3D lighting), the direction perpendicular to a surface, finding vectors orthogonal to two given vectors. When to use which: "What is the component of force in the direction of motion?" → dot product. "What is the torque produced by this force?" → cross product. "Are these two vectors perpendicular?" → dot product = 0. "What direction is perpendicular to these two vectors?" → cross product.
How is the dot product used in machine learning?
The dot product is foundational to virtually all machine learning algorithms. Here are the key applications: 1. Linear models and neural networks: Every neuron in a neural network computes a weighted sum: output = W·x + b, where W is the weight vector, x is the input vector, and the dot product W·x computes the weighted sum. This is a dot product. Linear regression: prediction = weights · features. Logistic regression: sigmoid(weights · features). Every fully-connected layer is a matrix of dot products. 2. Cosine similarity: Used to measure how similar two data points are: cosine_similarity = (a·b) / (‖a‖·‖b‖). Applications: Document similarity in NLP. Recommendation systems (find items similar to a user's preferences). Word embeddings: "king − man + woman ≈ queen" works via vector dot products. Face recognition: compare face embedding vectors. 3. Attention mechanisms (Transformers): The "attention" in transformers (GPT, BERT, etc.) is computed as: Attention(Q, K, V) = softmax(Q·Kᵀ / √d)·V. Q·Kᵀ is a matrix of dot products between query and key vectors. This determines which parts of the input to "attend to." All modern LLMs use dot products at their core. 4. Support Vector Machines (SVMs): The kernel function in SVMs computes dot products between data points to find optimal separating hyperplanes. 5. Principal Component Analysis (PCA): Eigenvectors are computed using dot products; projecting data onto principal components uses dot products. 6. Recommendation systems (matrix factorization): Netflix/Spotify-style recommendations: user preferences × item features (dot product) → predicted rating for user-item pairs.

Key Takeaways

  • The dot product multiplies two vectors to produce a scalar (single number), not a vector
  • Formula: A · B = AxBx + AyBy + AzBz
  • A dot product of zero means the vectors are perpendicular (90 degrees apart)
  • Positive result = vectors point in similar directions; negative = opposite directions
  • Used extensively in physics, computer graphics, machine learning, and engineering

What Is the Dot Product? A Complete Explanation

Property Dot Product (a·b) Cross Product (a×b)
Result typeScalar (single number)Vector (3D only)
Formulaa₁b₁ + a₂b₂ + … + aₙbₙDeterminant expansion (3D)
Geometric meaning‖a‖‖b‖cos(θ)‖a‖‖b‖sin(θ)·n̂
When = 0Vectors are perpendicular (θ=90°)Vectors are parallel (θ=0°)
When = maxVectors are parallel (θ=0°)Vectors are perpendicular (θ=90°)
DimensionsWorks in any dimensionOnly defined in 3D (and 7D)
Commutative?Yes: a·b = b·aNo: a×b = −(b×a)
Angle θ cos(θ) Dot Product a·b Interpretation
0°1.000‖a‖·‖b‖Vectors point same direction
30°0.8660.866‖a‖·‖b‖Slight divergence
45°0.7070.707‖a‖·‖b‖45° apart
60°0.5000.500‖a‖·‖b‖60° apart
90°0.0000Perpendicular (orthogonal)
120°−0.500−0.5‖a‖·‖b‖Obtuse angle
180°−1.000−‖a‖·‖b‖Vectors point opposite directions
Application How Dot Product Is Used
3D lighting (Lambert)Intensity = N·L (surface normal · light direction)
Cosine similarity (ML/NLP)cos(θ) = (a·b) / (‖a‖·‖b‖); text similarity
Neural networksEach neuron computes dot product of inputs + weights
Projection calculationproj_b(a) = (a·b/‖b‖²)·b
Physics: work doneW = F·d (force vector · displacement vector)
Game collision detectionCheck if velocity dot normal < 0 (object moving toward surface)
Principal Component AnalysisEigenvectors use dot products for variance computation

The dot product (also called the scalar product or inner product) is a fundamental operation in linear algebra that takes two vectors and returns a single scalar value. Unlike the cross product which produces another vector, the dot product always yields a number that represents how much one vector extends in the direction of another.

Mathematically, if you have two vectors A = (Ax, Ay, Az) and B = (Bx, By, Bz), their dot product is calculated by multiplying corresponding components and summing the results. This seemingly simple operation has profound implications in physics, engineering, computer science, and data science.

The geometric interpretation of the dot product is equally important: it equals the product of the magnitudes of the two vectors and the cosine of the angle between them. This relationship makes the dot product invaluable for determining whether vectors are parallel, perpendicular, or at some angle to each other.

A · B = AxBx + AyBy + AzBz
Geometric Form:
A · B = |A| |B| cos(theta)
A, B = Input vectors
|A|, |B| = Vector magnitudes
theta = Angle between vectors

How to Calculate the Dot Product (Step-by-Step Guide)

Calculating the dot product is straightforward once you understand the process. Here is a comprehensive step-by-step guide that works for both 2D and 3D vectors.

Step-by-Step Calculation Process

1

Identify the Vector Components

Write out each vector's components. For example, Vector A = (3, 4, 2) has components Ax = 3, Ay = 4, Az = 2. Vector B = (1, 5, -3) has Bx = 1, By = 5, Bz = -3.

2

Multiply Corresponding Components

Multiply each pair of corresponding components: Ax × Bx = 3 × 1 = 3, Ay × By = 4 × 5 = 20, Az × Bz = 2 × (-3) = -6.

3

Sum All Products

Add all the products together: 3 + 20 + (-6) = 17. This is your dot product: A · B = 17.

4

Interpret the Result

A positive result (17) indicates the vectors point in generally the same direction. A negative result means opposite directions. Zero means they are perpendicular.

Worked Example: 2D Vectors

Given: A = (4, 3) and B = (2, -1)

Step 1: Multiply x-components: 4 × 2 = 8

Step 2: Multiply y-components: 3 × (-1) = -3

Step 3: Sum: 8 + (-3) = 5

Answer: A · B = 5

Understanding the Geometric Meaning

The dot product has a beautiful geometric interpretation that makes it incredibly useful in practical applications. The formula A · B = |A| |B| cos(theta) reveals that the dot product is related to both the lengths of the vectors and the angle between them.

When two vectors are parallel (pointing in exactly the same direction), the angle between them is 0 degrees, and cos(0) = 1. This means the dot product equals the simple product of their magnitudes. When vectors are perpendicular (90 degrees apart), cos(90) = 0, so the dot product is zero regardless of the vector lengths.

This geometric relationship allows us to use the dot product to find the angle between any two vectors by rearranging the formula: theta = arccos((A · B) / (|A| |B|)). This calculation is fundamental in computer graphics for lighting calculations, in physics for work calculations, and in machine learning for measuring similarity between data points.

Key Insight: Projection

The dot product also represents projection. Specifically, A · B / |B| gives the length of vector A projected onto vector B. This is essential in physics for decomposing forces and in graphics for shadow calculations.

Essential Properties of the Dot Product

Understanding the mathematical properties of the dot product helps you work with it more effectively and recognize when it can simplify complex calculations.

Property Mathematical Form Meaning
Commutative A · B = B · A Order doesn't matter
Distributive A · (B + C) = A · B + A · C Works with addition
Scalar Multiplication (kA) · B = k(A · B) Scalars factor out
Self Dot Product A · A = |A|² Equals magnitude squared
Perpendicular Test A · B = 0 iff A perp B Zero means perpendicular

Pro Tip: Finding Vector Magnitude

Need to find a vector's length? Use the self dot product! For vector A = (3, 4), the magnitude |A| = sqrt(A · A) = sqrt(3² + 4²) = sqrt(25) = 5. This is faster than the traditional formula when you're already working with dot products.

Real-World Applications of the Dot Product

The dot product isn't just abstract mathematics - it powers countless real-world applications across multiple fields.

Physics and Engineering

In physics, work is defined as the dot product of force and displacement: W = F · d. This elegant formula captures the fact that only the component of force in the direction of motion does work. Engineers use this daily when calculating energy transfer in mechanical systems, structural analysis, and electromagnetic field calculations.

Computer Graphics and Gaming

Every 3D game and movie uses dot products extensively. Lighting calculations depend on the dot product between surface normals and light direction vectors to determine how brightly a surface should be illuminated. This creates realistic shading, shadows, and reflections. The dot product also enables efficient collision detection and camera angle calculations.

Machine Learning and AI

In machine learning, the dot product measures similarity between data points represented as vectors. Cosine similarity, derived from the dot product, is fundamental to recommendation systems, natural language processing, and image recognition. When Netflix suggests movies or Google ranks search results, dot products are working behind the scenes.

Navigation and GPS

GPS systems use dot products to calculate directions, determine shortest paths, and compute distances. The projection property helps decompose movement into northward, eastward, and elevation components for accurate positioning.

Common Mistake: Confusing Dot and Cross Products

The dot product returns a scalar (number) and measures how parallel vectors are. The cross product returns a vector perpendicular to both inputs and measures how perpendicular they are. Using the wrong one leads to dimensional errors and incorrect results.

Dot Product vs. Cross Product: Complete Comparison

While both operations involve two vectors, they serve very different purposes and produce different types of results.

Feature Dot Product Cross Product
Result Type Scalar (number) Vector
Notation A · B A × B
Dimensions Works in any dimension Only 3D
Commutative? Yes (A · B = B · A) No (A × B = -(B × A))
Zero Result Means Vectors are perpendicular Vectors are parallel
Max Result When Vectors are parallel Vectors are perpendicular
Common Uses Work, projection, similarity Torque, area, normal vectors

Common Mistakes and How to Avoid Them

Even experienced students and professionals make these errors. Learn to recognize and avoid them.

Mistake 1: Forgetting It's a Scalar

The dot product always produces a single number, not a vector. If your answer has multiple components, you've made an error somewhere in the calculation.

Mistake 2: Mixing Up Component Order

While the dot product is commutative (A · B = B · A), you must still multiply corresponding components correctly. Ax goes with Bx, Ay goes with By, and so on.

Mistake 3: Ignoring Zero Components

In 2D problems, if you're using 3D formulas, remember that the z-components are zero. Missing this doesn't change the answer but can cause confusion.

Mistake 4: Sign Errors

Negative components are common in vectors. Double-check your multiplication, especially when multiplying two negatives (positive result) or a positive by a negative (negative result).

Pro Tip: Quick Verification

After calculating, verify your result makes sense. If vectors point roughly the same direction, the dot product should be positive. If they point in roughly opposite directions, it should be negative. If they look perpendicular, it should be close to zero.

Advanced Concepts: Going Beyond the Basics

Once you've mastered the fundamentals, these advanced concepts open up powerful applications.

Orthogonal Projection

The projection of vector A onto vector B is given by projBA = ((A · B) / (B · B)) B. This decomposes A into components parallel and perpendicular to B, essential in physics for force decomposition and in graphics for shadow calculations.

Gram-Schmidt Orthogonalization

This algorithm uses dot products to convert any set of vectors into an orthonormal basis (mutually perpendicular unit vectors). It's fundamental in numerical linear algebra and data compression.

Higher Dimensions

The dot product formula extends seamlessly to any number of dimensions: just multiply and sum corresponding components. This is crucial in machine learning where data often exists in hundreds or thousands of dimensions.

Ready to Calculate Your Vectors?

Use our calculator above to instantly compute dot products, find angles between vectors, and see step-by-step solutions. Perfect for homework, engineering problems, or exploring vector mathematics.