Dot Product Calculator
3D dot product, magnitudes, and angle.
Formula
A·B = AxBx+AyBy+AzBz
Example
(1,2,3)·(4,5,6) = 32.
Embed this calculator on your site
Add this free calculator to your own website with one line of code. The embedded version is responsive, ad-free, and includes a small attribution link back to CalcNest AI.
<iframe src="https://calcnestai.com/embed/dot-product-calculator.html" width="100%" height="700" frameborder="0" style="border: 1px solid #e5e5e5; border-radius: 12px; max-width: 720px;" loading="lazy" title="Dot Product Calculator — Free Tool by CalcNest AI"></iframe>
Understanding the Dot Product Calculator
A dot product calculator multiplies two vectors to produce a single number, along with their magnitudes and the angle between them. The result is a scalar rather than a vector, which is what distinguishes it from the cross product and makes it the tool for projection and alignment.
How it actually works
Enter the components of two vectors. The calculator sums the componentwise products, computes each magnitude, and derives the angle from the ratio. Vectors (1,2,3) and (4,5,6) give a dot product of 32 and an angle of about 12.93 degrees.
| Dot product | Meaning |
|---|---|
| Positive | Angle under 90°, broadly aligned |
| Zero | Perpendicular |
| Negative | Angle over 90°, broadly opposed |
| Equal to |A||B| | Parallel and same direction |
The deeper context most people miss
The sign alone answers whether two directions broadly agree, which is why the dot product appears in tests that need only a yes or no. Checking whether a surface faces the camera, whether a point is in front of a plane, or whether motion opposes a force are all sign tests requiring no trigonometry at all.
Why the dot product equals both a sum and a cosine
There are two apparently unrelated definitions: the sum of componentwise products, and the product of the magnitudes times the cosine of the angle between the vectors. That these agree is the substantive content of the dot product, and it follows from the law of cosines applied to the triangle formed by the two vectors and their difference. Expanding the squared length of that difference algebraically and comparing with the law of cosines gives the identity directly. The practical value is that the algebraic form is trivial to compute while the geometric form is what carries meaning, so the dot product converts a geometric question into arithmetic. This is why it appears everywhere in computation: finding an angle requires no trigonometry until the final arccosine, and frequently the cosine itself is sufficient without ever recovering the angle, which saves the expensive inverse function. Cosine similarity in text and recommendation systems is exactly this, comparing document or preference vectors by the cosine of the angle between them, which measures orientation while ignoring magnitude, so a long document and a short one on the same topic score as similar. That magnitude-independence is the whole reason cosine similarity is preferred over Euclidean distance in high-dimensional sparse spaces, where distances become uninformative as dimension grows.
A worked example: projection and work
A dot product of 32 with magnitudes of 3.74 and 8.78 gives a cosine near 0.975, hence an angle of about 13 degrees, meaning the vectors point in nearly the same direction. Projection is the geometric operation this enables: the component of one vector along another is the dot product divided by the second vector's magnitude, which decomposes any vector into a part along a given direction and a part perpendicular to it. That decomposition underlies a great deal of physics and graphics. Work in physics is force dotted with displacement, so pushing perpendicular to motion does no work regardless of effort, which is why carrying a heavy box across a level floor does no work against gravity in the physical sense even though it is tiring. Power is force dotted with velocity. In lighting calculations, the brightness of a surface under a directional light is proportional to the dot product of the surface normal with the light direction, which is Lambert's cosine law and is computed for every pixel in real-time rendering, making it one of the most executed operations in graphics. Negative results are clamped to zero since a surface facing away receives no light, and forgetting that clamp produces the characteristic artefact of surfaces lit from behind.
Deciding between dot and cross products
The question determines the tool. Use the dot product when you want a scalar: the angle between directions, whether two vectors are perpendicular, the projection of one onto another, work, power, or a similarity score. Use the cross product when you want a vector: a perpendicular direction, a surface normal, torque, angular momentum, or an orientation test for which side of a line a point lies on. The two are complementary in a precise sense, with the dot product proportional to cosine and the cross product to sine of the same angle, so their squares sum appropriately and one vanishes exactly where the other is maximal. In practice the dot product is far more commonly used, partly because it generalises to any number of dimensions while the cross product does not, and partly because scalar answers suffice for most tests. In machine learning, dot products are the fundamental operation: a neural network layer is a matrix multiplication, which is a collection of dot products, and the overwhelming majority of computation in training and inference is exactly this. Attention mechanisms compute dot products between query and key vectors. Kernel methods generalise the dot product to implicit feature spaces. That ubiquity is why hardware acceleration targets matrix multiplication specifically.
Cosine similarity and the curse of dimensionality
In high-dimensional spaces, Euclidean distance behaves counterintuitively: as dimension grows, the distances between randomly distributed points concentrate, so the nearest and farthest neighbours become nearly equidistant and distance stops discriminating. This is one facet of the curse of dimensionality and it undermines nearest-neighbour methods in high dimensions. Cosine similarity degrades more gracefully because it measures orientation rather than distance, which is why it dominates in text retrieval, where documents are represented as vectors over a vocabulary of tens of thousands of terms, and in embedding-based search, where vectors have hundreds or thousands of dimensions. Normalising vectors to unit length makes cosine similarity and Euclidean distance monotonically related, so the choice becomes one of convenience, and many embedding systems normalise for exactly that reason. The related practical point is that dot products on unnormalised vectors conflate magnitude with alignment, so a document containing a term many times scores highly for reasons of length rather than relevance, which is why term frequency is dampened and inverse document frequency weighting exists. In embedding models, whether vectors are normalised affects which similarity measure is appropriate, and mixing conventions is a recurring source of retrieval quality problems that is easy to overlook because the system still returns results.
Variations: generalisations and computation
The dot product generalises to any dimension, unlike the cross product, and it extends to complex vectors with a conjugate on one argument, which keeps the magnitude real and positive. Inner products generalise further to function spaces, where the integral of a product of functions plays the same role, and this underlies Fourier analysis, where the coefficients are inner products of a signal with basis sinusoids, and orthogonality of the basis is exactly the statement that those inner products vanish between different frequencies. Matrix multiplication is composed of dot products. The Gram matrix collects all pairwise dot products of a set of vectors. Kernel functions compute dot products in high-dimensional feature spaces without constructing the vectors, which is the kernel trick underlying support vector machines. In computation, the main practical concerns are numerical: summing many products accumulates rounding error, and specialised routines use compensated summation or blocked algorithms; and the arccosine at the end is sensitive near zero and π, where small errors in the cosine produce large errors in the angle, which is why the ratio should be clamped to the valid range and why atan2-based formulations are sometimes preferred for angle recovery.
Using the dot product effectively
Use the sign alone where a yes or no suffices, since positive means broadly aligned and negative broadly opposed, which answers facing and orientation tests without any trigonometry. Avoid computing the arccosine unless you need the angle itself, since the cosine is frequently sufficient and the inverse function is both expensive and numerically sensitive near zero and π. Clamp the ratio to the range from minus one to one before taking arccosine, since floating point error can push it slightly outside and produce a not-a-number result. Normalise vectors before comparing directions, since unnormalised dot products conflate magnitude with alignment. Prefer cosine similarity to Euclidean distance in high dimensions, where distances concentrate and stop discriminating. Use the dot product for projection by dividing by the target vector's magnitude, which decomposes a vector into parallel and perpendicular components. Clamp lighting calculations at zero, since a negative dot product means a surface faces away and should receive no light. And remember it generalises to any dimension while the cross product does not.
What people get wrong
- Taking arccosine without clamping the ratio to the valid range, when floating point error can push it just outside and produce a not-a-number result.
- Comparing unnormalised vectors by dot product, which conflates magnitude with alignment so longer vectors score higher regardless of direction.
- Using Euclidean distance in high-dimensional spaces, where distances between points concentrate and nearest and farthest neighbours become nearly equidistant.
- Omitting the clamp at zero in lighting calculations, where a negative dot product means the surface faces away and should receive no illumination.
Where the math comes from
A · B = a₁b₁ + a₂b₂ + a₃b₃, and equivalently |A||B|cos θ. The equality of these two forms follows from the law of cosines. The result is a scalar, positive when the angle is under 90 degrees, zero when perpendicular, and negative beyond. Unlike the cross product, it generalises to any number of dimensions.
Questions and answers
What is the difference between percent and percentage point?
Percent change is relative (going from 5% to 10% is a 100% increase). Percentage point change is absolute (the same shift is a 5 percentage point increase). News stories often confuse these.
How do I calculate a discount?
Discount amount = original x discount %. Final price = original x (1 - discount %). For 20% off $100: discount $20, final $80.
What is the formula for compound percentage?
Final = original x (1 + r1) x (1 + r2) x ... where each r is a percentage as decimal. A 10% raise then 10% cut: 1.10 x 0.90 = 0.99 = 99% of original.
How do I reverse a percentage?
If $80 is 80% of original: original = $80 / 0.80 = $100. To reverse 'X% off' to find original: original = final / (1 - X/100).
How do percentages work in tax?
Marginal tax rate applies to income within a bracket. Effective rate is total tax / total income. They diverge because of progressive brackets.
What does the dot product tell me?
How aligned two vectors are, scaled by their magnitudes. Positive means the angle is under 90 degrees, zero means perpendicular, and negative means over 90. The sign alone answers many practical tests without needing the angle itself.
Why does it equal both a sum and a cosine?
The equality follows from the law of cosines applied to the triangle formed by the two vectors and their difference. That's the substantive content: an easily computed algebraic sum turns out to encode a geometric relationship.
When should I use dot rather than cross?
When you want a scalar: angles, perpendicularity tests, projections, work, or similarity. Use the cross product when you want a vector: a perpendicular direction, a surface normal, torque, or an orientation test.
Why is cosine similarity used instead of distance?
Because it measures orientation while ignoring magnitude, so documents of different lengths on the same topic score as similar. It also degrades more gracefully in high dimensions, where Euclidean distances concentrate and stop discriminating between near and far points.
Why does my angle calculation return not-a-number?
Because floating point error pushed the cosine ratio just outside the range from minus one to one, where arccosine is undefined. Clamping the ratio before taking the inverse cosine fixes it, and it's a standard defensive step.
What is projection?
The component of one vector along another, computed as the dot product divided by the target vector's magnitude. It decomposes any vector into a part along a given direction and a part perpendicular to it, which underlies much of physics and graphics.
Why is the dot product so central to machine learning?
Because a neural network layer is a matrix multiplication, which is a collection of dot products, and that accounts for the overwhelming majority of computation in both training and inference. Attention mechanisms compute them between query and key vectors.
Related calculators
Sigma Notation Evaluator · Logarithm · Normal Distribution · Parabola Vertex · Cross Product