Mathematics · Geometry & Trigonometry · Vectors
Dot Product Calculator
Calculates the dot product of two 3D vectors and the angle between them using the algebraic and geometric definitions.
Calculator
Formula
A and B are three-dimensional vectors with components (Ax, Ay, Az) and (Bx, By, Bz). The dot product is found by multiplying corresponding components and summing the results. |A| and |B| are the magnitudes (lengths) of each vector. The angle theta is the angle between the two vectors, ranging from 0 to 180 degrees. Setting the algebraic and geometric forms equal allows solving for theta via the inverse cosine.
Source: Anton, H., Bivens, I., & Davis, S. — Calculus: Early Transcendentals, 11th Edition. Wiley.
How it works
The dot product of two vectors A = (Ax, Ay, Az) and B = (Bx, By, Bz) is defined algebraically as the sum of the products of their corresponding components: A · B = Ax·Bx + Ay·By + Az·Bz. This operation reduces two vectors to a single number, which encodes information about both the lengths of the vectors and the angle between them. Unlike the cross product, the dot product is commutative — A · B always equals B · A.
The geometric definition links the dot product to the magnitudes of the two vectors and the cosine of the angle between them: A · B = |A| |B| cos(θ). Here, |A| and |B| are the Euclidean magnitudes computed as the square root of the sum of squared components. Rearranging this formula gives θ = arccos(A · B / (|A| |B|)), which is how the calculator derives the angle between the vectors. The result is clamped to the interval [−1, 1] before the arccos is applied to prevent floating-point errors from generating invalid results.
The dot product has rich practical meaning. A positive result means the two vectors point in broadly the same direction (θ < 90°); a negative result means they point in broadly opposite directions (θ > 90°); and a result of zero means the vectors are perpendicular (orthogonal), which is a critical condition in structural engineering, signal processing, and coordinate system design. In physics, the dot product directly computes the work done by a force F applied over a displacement d: W = F · d.
Worked example
Suppose you have two 3D vectors: A = (1, 2, 3) and B = (4, 5, 6).
Step 1 — Compute the dot product algebraically:
A · B = (1)(4) + (2)(5) + (3)(6) = 4 + 10 + 18 = 32
Step 2 — Compute the magnitude of A:
|A| = √(1² + 2² + 3²) = √(1 + 4 + 9) = √14 ≈ 3.7417
Step 3 — Compute the magnitude of B:
|B| = √(4² + 5² + 6²) = √(16 + 25 + 36) = √77 ≈ 8.7750
Step 4 — Compute the angle between the vectors:
cos(θ) = 32 / (3.7417 × 8.7750) = 32 / 32.8328 ≈ 0.97463
θ = arccos(0.97463) ≈ 12.933°
Interpretation: Since the dot product is positive (32) and the angle is small (~12.9°), vectors A and B are closely aligned and point in nearly the same direction.
Limitations & notes
This calculator is designed for three-dimensional Euclidean vectors with real-valued components. It does not support complex vector spaces (such as those found in quantum mechanics, where the inner product involves complex conjugation). For two-dimensional problems, simply enter 0 for the z-component of both vectors — the result will be correct. If either vector has zero magnitude (the zero vector), the angle between the vectors is undefined and the calculator will return NaN for that output, which is mathematically correct behaviour. Floating-point arithmetic may introduce very small rounding errors for certain inputs, particularly when the cosine ratio is very close to ±1; the calculator clamps the arccos argument to prevent domain errors. For higher-dimensional vectors (4D and above), this tool cannot be used directly — you would need to apply the algebraic formula manually across all n components.
Frequently asked questions
What does it mean when the dot product is zero?
A dot product of zero means the two vectors are perpendicular (orthogonal) — the angle between them is exactly 90°. For example, the vectors A = (1, 0, 0) and B = (0, 1, 0) have a dot product of 0, confirming they are at right angles. This property is fundamental in mathematics and engineering: orthogonal vectors appear in coordinate systems, principal component analysis, and Fourier analysis.
What is the difference between the dot product and the cross product?
The dot product produces a scalar (a single number) and measures the degree of alignment between two vectors. The cross product produces a new vector perpendicular to both input vectors and measures the degree of perpendicularity. The dot product is commutative (A · B = B · A), while the cross product is anticommutative (A × B = −B × A). Use the dot product for angles, projections, and work; use the cross product for torque, normals, and area of parallelograms.
How is the dot product used to find the projection of one vector onto another?
The scalar projection of vector A onto vector B is given by (A · B) / |B|. This tells you how much of A lies along the direction of B. The vector projection — the actual component of A in the direction of B — is ((A · B) / |B|²) × B. These projections are used extensively in physics (decomposing forces), computer graphics (shadow calculations), and statistics (least-squares regression).
Can the dot product be negative, and what does that mean?
Yes. A negative dot product means the angle between the two vectors is greater than 90° (obtuse). For instance, A = (1, 0, 0) and B = (−1, 0, 0) give a dot product of −1, and the angle between them is 180° — they point in exactly opposite directions. In physics, a negative dot product for force and displacement means the force is doing negative work, opposing the motion.
Does the order of vectors matter for the dot product?
No. The dot product is commutative: A · B = B · A. This is easy to verify algebraically — multiplying corresponding components and summing them gives the same result regardless of order. This is one key difference from the cross product, which reverses sign when the operand order is swapped. Commutativity makes the dot product well-suited for symmetric calculations like similarity scores in machine learning.
Last updated: 2025-01-15 · Formula verified against primary sources.