Dot Product Calculator
The vectors A = (1, 2, 3) and B = (4, 5, 6) have a dot product of 32. Their magnitudes are 3.7417 and 8.7750, so cos theta is 32 / 32.833 = 0.9746 and the angle between them is 12.93 degrees.
Give the components of two vectors, or their magnitudes and the angle between them. The calculator returns the dot product, both magnitudes, the angle, the projection of A on B, and the work if A is a force. Everything runs in your browser.
| Dot product | |
| Magnitude of A | |
| Magnitude of B | |
| cos of the angle | |
| Angle between them | |
| Scalar projection of A on B | |
| Vector projection of A on B | |
| Relationship | |
| Work, A as force in N and B as displacement in m |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter two vectors as components, or as magnitudes with the angle between them, and the calculator returns the dot product, the angle and the projection of one on the other.
Key takeaways
- Components: A . B = a1b1 + a2b2 + a3b3, so (1, 2, 3) and (4, 5, 6) give 32
- Geometry: A . B = |A| x |B| x cos(theta), which gives the angle as 12.93 degrees here
- A zero dot product means a 90 degree angle, as with (3, 4) and (4, -3)
- Projection of A on B is A . B / |B| long, and work is a dot product in joules
On this page
Two forms of the same number
The dot product takes two vectors and returns a single number. There are two ways to compute it and they always agree. In components you multiply the matching parts and add them: A . B = a1 x b1 + a2 x b2 + a3 x b3. In geometry you multiply the lengths by the cosine of the angle between them: A . B = |A| x |B| x cos(theta).
OpenStax University Physics, section 2.4 calls this the scalar product, which describes exactly what comes out. The other product of two vectors, the cross product, returns a vector instead, and the two get confused in homework more often than any other pair of formulas in the subject.
Each form matches what you have in hand. Components come from a spreadsheet, a CAD file or a game engine. Magnitudes and an angle come from a physics problem, a survey or a force diagram. The calculator above accepts either and reports the angle, the projection and the work along the way.
Component form, step by step
Multiply matching components and add the products. For A = (3, 4) and B = (4, -3): 3 x 4 + 4 x -3 = 12 - 12 = 0. For A = (1, 2, 3) and B = (4, 5, 6): 1 x 4 + 2 x 5 + 3 x 6, which is 4 + 10 + 18 = 32.
The order of the vectors does not matter, because multiplication of ordinary numbers does not care about order. A 2D pair drops the third term, and a 3D pair keeps it. Getting that third term wrong is the difference between 14 and 32 in the example above, which is large enough to flip a physics answer from correct to nonsense.
| A | B | Dot product | |A| | |B| | cos | Angle |
|---|---|---|---|---|---|---|
| (3, 4) | (4, -3) | 0 | 5.0000 | 5.0000 | 0.0000 | 90.00 deg |
| (1, 2, 3) | (4, 5, 6) | 32 | 3.7417 | 8.7750 | 0.9746 | 12.93 deg |
| (2, -1, 4) | (3, 0, -2) | -2 | 4.5826 | 3.6056 | -0.1210 | 96.95 deg |
| (3, 1, 0) | (2, 2, 1) | 8 | 3.1623 | 3.0000 | 0.8433 | 32.51 deg |
| (1, 2) | (1, 1) | 3 | 2.2361 | 1.4142 | 0.9487 | 18.43 deg |
Read the angle column as a check on the dot product column. A positive dot product pairs with an angle below 90, a zero pairs with exactly 90, and a negative pairs with an angle above 90. If your numbers do not follow that pattern, one of the two calculations is wrong.
The angle between two vectors
Rearranged, the geometric form gives the angle: cos(theta) = A . B / (|A| x |B|). For (1, 2, 3) and (4, 5, 6), the magnitudes are 3.7417 and 8.7750, so 32 / 32.833 = 0.9746, and the angle is 12.93 degrees. Those two vectors point in nearly the same direction, which is what a cosine close to 1 says.
Going the other way is just as useful. A force of 8 N and a displacement of 5 m at 60 degrees apart give 8 x 5 x cos(60) = 20 for the dot product, since cos(60) is 0.5. The same arithmetic appears in every work and flux calculation.
| Sign of the dot product | cos of the angle | Angle between the vectors | Example |
|---|---|---|---|
| Positive | above zero | 0 to 90 degrees | (1, 2, 3) and (4, 5, 6) give 32 |
| Zero | zero | exactly 90 degrees | (3, 4) and (4, -3) give 0 |
| Negative | below zero | 90 to 180 degrees | (2, -1, 4) and (3, 0, -2) give -2 |
| Largest possible | 1 | 0 degrees, same direction | |A| x |B| with parallel vectors |
| Most negative | -1 | 180 degrees, opposite | -|A| x |B| with opposed vectors |
Two details keep the angle honest. The magnitudes have to be positive lengths, so a zero vector has no angle at all, and a calculator that reports one is guessing. And the cosine never exceeds 1, so a result of 1.02 means the components and the magnitudes came from different data.
Projection: how much of A points along B
The scalar projection of A onto B is A . B / |B|. It answers a question people ask constantly without naming it: if I walk in the direction of B, how far do I get in the direction A pushes me. For A = (1, 2) and B = (1, 1), the dot product is 3 and |B| is 1.4142, so the scalar projection is 3 / 1.4142 = 2.1213.
The vector projection multiplies that length by the unit vector along B: (A . B / |B|^2) x B. Here that is 3 / 2 x (1, 1), which is (1.5, 1.5). For A = (3, 4) and B = (2, 0) the scalar projection is 6 / 2 = 3 and the vector projection is (3, 0), the entire shadow of A on the x-axis.
The projection is shorter than A unless the vectors are parallel, and that inequality is the Cauchy-Schwarz bound in disguise: the dot product can never exceed the product of the magnitudes. It is also the arithmetic under a least squares fit, where the fitted values are the projection of the data onto the model space.
Work done by a force
Work is a dot product with units attached: W = F . d, in joules when the force is in newtons and the displacement in metres, which is the NIST SI definition of the joule as one newton metre. A force of (30, 40) N has a magnitude of 50 N, and pushing a crate 5 m along the x-axis, displacement (5, 0), does 30 x 5 + 40 x 0 = 150 J of work.
Only the component along the motion counts, and the dot product does that automatically. Push the same 50 N at 60 degrees to the displacement and the work is 50 x 5 x cos(60) = 125 J, not 250 J. Push at 90 degrees, as when carrying a bag while walking, and the work comes out as zero, which is why the bag's weight does not tire your arms in the physics sense no matter how far you carry it.
The sign has meaning too. A force opposed to the motion, such as friction, gives a negative dot product and negative work, and that number is the energy leaving the moving object as heat.
Cosine similarity and right-angle checks
Text search, recommendation systems and embedding models all rank items by the cosine of the angle between two vectors, which is the dot product divided by both magnitudes. Two document vectors (3, 1, 0) and (2, 2, 1) have a dot product of 8, magnitudes of 3.1623 and 3, and a cosine of 0.8433, an angle of 32.51 degrees. Dividing by the magnitudes makes the score blind to document length, which is the whole point.
At the other end of the scale sits the carpenter's check. Two vectors at right angles have a dot product of zero, so (3, 0) and (0, 4) give 0 no matter how long the walls are, and the 3-4-5 triangle people use to square a deck is the same fact with the diagonal computed from the Pythagorean theorem. A dot product of zero is the cleanest test for perpendicularity you can run on a set of coordinates.
Both uses come down to one habit: compute the dot product first, then decide whether you want to divide by the magnitudes.
Mistakes that flip the answer
Most wrong dot products come from four habits, and all four are visible in a single line of arithmetic.
| Mistake | What comes out | Fix |
|---|---|---|
| Adding the components instead of multiplying them | (1, 2) and (4, 5) give 12 instead of 14 | Multiply matching parts, then add |
| Dropping the third component in 3D | (1, 2, 3) and (4, 5, 6) give 14 instead of 32 | The third term is 3 x 6 = 18 |
| Feeding degrees to a cosine that wants radians | cos(60) in radian mode is -0.9524, so a 250 J case returns -238.1 | Convert to radians first: 60 deg is 1.0472 rad |
| Treating a negative dot product as an error | -2 gets reported as 2, and a 96.95 degree angle becomes 83.05 | The sign carries the obtuse angle |
| Using the dot product to find a direction | It returns one number, not a vector | The cross product returns the perpendicular vector |
The radian mistake deserves a second look because it is invisible in the formula and obvious in the answer. A calculator in radian mode reads 60 as 60 radians, which is about 9.5 full turns, and the cosine lands at -0.9524. Convert the angle once, at the top of the calculation, and the whole chain stays honest.
The last row is a scope error rather than an arithmetic one. A dot product cannot point anywhere, so any problem that asks for a perpendicular direction, a torque or a magnetic force needs the cross product, and no amount of dot product arithmetic will substitute for it.
Frequently asked questions
What is a dot product in simple terms?
It is one number that measures how much two vectors point the same way. For (1, 2, 3) and (4, 5, 6) the dot product is 32, which is positive, so the angle between them is acute at 12.93 degrees.
How do I calculate a dot product from components?
Multiply matching components and add the results. (1, 2, 3) and (4, 5, 6) give 4 + 10 + 18 = 32. In 2D the same step stops after two terms.
What does a dot product of zero mean?
The vectors are perpendicular. (3, 4) and (4, -3) give 12 - 12 = 0, and the angle between them is exactly 90 degrees.
How do I find the angle between two vectors?
Divide the dot product by the product of the magnitudes, then take the arccosine. For 32 with magnitudes 3.7417 and 8.7750, cos is 0.9746 and the angle is 12.93 degrees.
What is the dot product of (1, 2) and (3, 4)?
11, from 1 x 3 + 2 x 4. The magnitudes are 2.2361 and 5, so the angle is 10.30 degrees.
Can a dot product be negative?
Yes. A negative value means the angle is obtuse. (2, -1, 4) and (3, 0, -2) give -2, and the angle between them is 96.95 degrees.
Is the dot product the same as the cross product?
No. The dot product returns a scalar and measures alignment, while the cross product returns a vector perpendicular to both inputs and measures the area they span.
What is the dot product of two unit vectors 60 degrees apart?
0.5, because both magnitudes are 1 and cos(60) is 0.5. At 90 degrees the answer is 0, and at 180 degrees it is -1.
How is the dot product used to calculate work?
Work is force dotted with displacement. A force of (30, 40) N acting through a displacement of (5, 0) m does 150 J of work, since 30 x 5 + 40 x 0 = 150.
What is the projection of (3, 4) onto (2, 0)?
A scalar projection of 3 and a vector projection of (3, 0). The dot product is 6 and the magnitude of B is 2, so 6 / 2 = 3.
What is the dot product of two perpendicular unit vectors?
Zero, always. The unit vectors (1, 0) and (0, 1) give 1 x 0 + 0 x 1 = 0, and every other perpendicular pair follows the same pattern.
How is the dot product used in cosine similarity?
Cosine similarity divides the dot product by both magnitudes. Vectors (3, 1, 0) and (2, 2, 1) give 8, and dividing by 3.1623 x 3 gives 0.8433, an angle of 32.51 degrees.
What happens if one vector is zero?
The dot product is zero, but the angle is undefined because a zero vector has no direction. The calculator reports the angle as not available rather than inventing 90 degrees.
Does the order of the vectors change the dot product?
No. A . B equals B . A for every pair, because each term is a product of two ordinary numbers and the sum does not care about order.
What is the difference between a 2D and a 3D dot product?
A 3D dot product adds one more term, a3 x b3. Skipping it turns 32 into 14 for the pair (1, 2, 3) and (4, 5, 6), which is a common source of wrong answers.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.