🏆 US-Registered Digital Marketing Agency
Advertisement
Advertisement
VECTORS

Dot Product Calculator — projection, work and orthogonality

Compute a · b in any dimension, then split a into the part along b and the part perpendicular to it, with a work-done mode and an orthogonality test.

This changes the labels and the wording, not the arithmetic.
Any number of components, separated by commas or spaces.
Must have the same number of components as a.
Vectors count as perpendicular when |a · b| falls below this fraction of |a||b|. Measured data almost never gives an exact zero.
Trailing zeros are trimmed.
a · b — the scalar product
0
 
0
Scalar projection of a onto b
0
Vector projection proj₋(a)
0
Perpendicular part (rejection)
Angle between a and b
Tip: the projection and the rejection always satisfy Pythagoras — the squares of their lengths add up to |a|². The bars above show that split, and it is the fastest way to see how much of a actually points along b.
Advertisement

The dot product calculator above multiplies two vectors of any dimension into a single number, and then does the thing the dot product is actually for: it splits one vector into the part that lies along the other and the part that is perpendicular to it. You get the scalar projection, the vector projection, the perpendicular remainder, the angle, and a tolerance-based orthogonality verdict. There is also a work-done mode for the physics case, where the dot product of force and displacement gives energy.

Arb Digital publishes free calculators that go past the headline number. A dot product on its own is one multiplication and one sum, and it tells you very little. Decomposed into a projection and a rejection it becomes the operation behind least-squares fitting, shadow lengths, component forces, orthogonal bases and the work-energy theorem. This page is built around that decomposition rather than around the multiplication.

What This Dot Product Calculator Does, and Where It Sits Among Our Vector Tools

Three live tools touch this operation, and the boundaries are worth stating plainly so you land on the right one. Our vector calculator is a general workbench — addition, subtraction, scalar multiples, dot, cross and projection, one operation at a time, in two or three dimensions. It gives you a dot product and a projection, but it stops there and it caps out at three components. Our cosine similarity calculator uses the dot product internally but for the opposite purpose: it divides magnitude out entirely, because in text and embedding work only direction is meant to matter, and it is written for hundreds of dimensions. Our cross product calculator handles the perpendicular-vector operation, which returns a vector rather than a scalar and only exists in three dimensions.

This page is the one where magnitude is the whole point. It keeps the units, works in any dimension, and reports the full decomposition — projection, rejection, the Pythagorean check between them, and work done in joules when you label the inputs as a force and a displacement. If you want direction-only similarity, use the cosine page. If you want one dot product among several other operations on 3D vectors, the vector calculator is quicker. If you need to know how much of one vector lies along another, and how much does not, this is the page for it.

How to Use It

  1. Enter both vectors with the same number of components. The dot product is only defined between vectors in the same space, and the tool will tell you rather than silently padding.
  2. Decide which vector is the direction. Projection is not symmetric: the component of a along b is a different number from the component of b along a whenever the magnitudes differ. The dot product itself is symmetric, but the projections are not.
  3. Switch to work mode for physics. The force goes in the first field and the displacement in the second, and the answer is read in joules.
  4. Set a tolerance you can defend. Exact zeros only occur in constructed examples. For measured data, a relative tolerance is the honest test for perpendicularity.
  5. Check the two bars. They show how much of a lies along b and how much is left over, and the two squared lengths always add back to |a|².

The Formula and How It's Calculated

There are two equivalent definitions and both are useful. The component form is a · b = a₁b₁ + a₂b₂ + … + aₙbₙ, which is what a computer evaluates. The geometric form is a · b = |a| |b| cosθ, which is what makes the result mean something. Setting the two equal is how the angle between vectors is extracted in the first place, and it works in any number of dimensions even though "angle" stops being something you can picture.

Take the defaults, a = (3, −2, 5) and b = (4, 1, −3). The component form gives 12 − 2 − 15 = −5. The magnitudes are |a| = √38 = 6.1644 and |b| = √26 = 5.0990, so cosθ = −5 ÷ 31.4325 = −0.1591 and the angle is 99.15 degrees. The negative sign is the informative part: the two vectors point more than a right angle apart, so a has a component running against b rather than with it. Wolfram MathWorld's entry on the dot product gives both forms and the projection interpretation that follows from them.

Advertisement

Scalar Projection, Vector Projection and the Rejection

Three related quantities get confused constantly, and keeping them apart is most of what this page is for. The scalar projection of a onto b, written comp₋(a), is a single signed number: a · b ÷ |b|. It is how far along b you travel, measured in the same units as a. The vector projection, proj₋(a), is that same distance turned back into a vector pointing along b: (a · b ÷ |b|²) b. The rejection is what is left, a − proj₋(a), and it is perpendicular to b by construction.

With the defaults, the scalar projection is −5 ÷ 5.0990 = −0.9806. Negative means the shadow falls on the opposite side of the origin from b. The vector projection is (−5/26)(4, 1, −3) = (−0.7692, −0.1923, 0.5769), and subtracting that from a leaves the rejection (3.7692, −1.8077, 4.4231), whose length is 6.0859. Check it: 0.9806² + 6.0859² = 0.9615 + 37.0385 = 38, which is |a|² exactly. That identity is not a coincidence — it is Pythagoras applied to a right-angled decomposition, and it is the reason this split is unique. Lamar University's Calculus II notes on the dot product derive the projection formula and the orthogonality test in the same section.

Every least-squares problem is this operation repeated. Fitting a line to data means projecting the observation vector onto the space the model can reach and treating the rejection as the residual. The residual is orthogonal to the fitted values, which is exactly why the sums of squares add up the way they do in a regression table. The same decomposition is why a shadow at a given sun angle has the length it does, and why only the component of a force along a slope contributes to sliding.

Work Done by a Force

The physics case is the dot product's most familiar application: W = F · d, work equals force dotted with displacement. The formula encodes the everyday fact that pushing sideways on a moving object does no work at all, and that a force with a component opposing the motion does negative work, removing energy rather than adding it.

Switch to work mode and try F = (12, 5, 0) newtons with d = (3, 4, 0) metres. The dot product is 36 + 20 = 56, so 56 joules of work are done. Note what happens if you rotate the force to (5, −12, 0), which has the identical magnitude of 13: the dot product becomes 15 − 48 = −33 joules. Same force strength, same displacement, and the sign has flipped, because the force is now mostly opposing the motion. This is why carrying a heavy box across a level floor at constant speed does no work against gravity — the gravitational force is vertical, the displacement is horizontal, and the dot product of perpendicular vectors is zero.

Testing for Orthogonality When the Numbers Are Measured

Two vectors are perpendicular exactly when their dot product is zero, and in textbook problems that zero arrives cleanly. In anything derived from measurement or floating-point arithmetic it does not. A dot product of 0.0000003 between two vectors of length 500 is perpendicular for every practical purpose; the same value between two unit vectors might not be.

That is why the test on this page is relative rather than absolute: it compares |a · b| against the product |a||b|, which is the largest the dot product could possibly be. The ratio is the cosine of the angle, so the tolerance you set is really a tolerance on angle. A relative tolerance of one in a million corresponds to being within about 0.00006 degrees of a right angle. Checking against an absolute zero instead makes the answer depend on the units you happened to choose, which is a defect and not a rounding detail. Our law of cosines calculator works the same angle relationship from side lengths in a triangle, which is the two-dimensional version of the same identity.

What the Sign Alone Tells You

Even without magnitudes, the sign of a dot product answers a useful question: is b on the same side as a, or the opposite side? Positive means the angle is under 90 degrees, zero means exactly 90, negative means over. That single bit is enough to decide which side of a plane a point lies on, whether a surface faces the camera, or whether a proposed step moves toward or away from a target.

The construction is standard. Take a plane through a point P with normal vector n. For any point Q, form the vector Q − P and dot it with n. Positive puts Q on the side n points to, negative on the other side, and zero means Q lies in the plane. Backface culling in graphics, half-space clipping and collision resolution all reduce to that one comparison, and none of them needs the angle or the magnitude. Our 3D distance calculator handles the separate question of how far apart two points are once you know which side they are on.

Need an interactive tool built properly?

Arb Digital builds fast, self-contained calculators and configurators that hold up under real traffic and earn links on their own merit.

See Our Web Design Work Talk To Our Team

Common Mistakes to Avoid

  • Expecting a vector back — the dot product returns a single number. The operation that returns a vector is the cross product, and it only exists in three dimensions.
  • Dividing by |b|² when you wanted |b| — the scalar projection divides by |b| once, the vector projection divides by |b| squared because it then multiplies by b. Mixing them scales the answer by |b|.
  • Assuming projection is symmetric — a · b equals b · a, but the component of a along b is not the component of b along a unless the two have equal magnitude.
  • Reading a negative result as an error — a negative dot product means the angle exceeds 90 degrees, which in a work calculation means energy is being removed.
  • Testing orthogonality against an exact zero — with measured or floating-point data that test almost always fails, so compare against a fraction of |a||b| instead.

Related Free Tools From Arb Digital

Run several vector operations side by side with the vector calculator, measure direction-only similarity in high dimensions with the cosine similarity calculator, get a perpendicular vector and an area with the cross product calculator, work an angle from three side lengths with the law of cosines calculator, or measure separation in space with the 3D distance calculator. The full free online tools hub lists every mathematics tool we publish.

Frequently Asked Questions

What is the dot product of two vectors?

It is the sum of the products of matching components, and it equals the product of the two magnitudes times the cosine of the angle between them. The result is a single number, not a vector.

What does a negative dot product mean?

The angle between the vectors is greater than 90 degrees, so they point more apart than together. In a work calculation that means the force is removing energy rather than adding it.

What is the difference between scalar and vector projection?

The scalar projection is a signed length, found by dividing the dot product by the magnitude of the direction vector. The vector projection is that length turned back into a vector pointing along the same direction.

How do I check whether two vectors are perpendicular?

Their dot product is zero. With measured or computed data compare its absolute value against a small fraction of the product of the magnitudes, rather than testing for an exact zero.

How is this different from cosine similarity?

Cosine similarity divides the dot product by both magnitudes, so only direction survives. This page keeps the magnitudes, which is what you need for projections, components and work.

Can the dot product be used in more than three dimensions?

Yes. It is defined for any two vectors with the same number of components, and the angle formula still holds. Only the cross product is restricted to three dimensions.

Why does the dot product give work done?

Because only the component of the force along the direction of motion transfers energy. Multiplying that component by the distance moved is exactly what the dot product computes.

Advertisement
Advertisement

Take it further