Dot Product Calculator – Scalar Product & Angle Between Two Vectors
Use this free Dot Product Calculator to find the scalar (dot) product of two vectors from their components, together with the angle between them. It works in 3D — just leave the z components as 0 for flat 2D problems.
There are two ways to multiply vectors, and they answer different questions. The cross product asks about perpendicularity and produces another vector. The dot product asks about alignment — how much do these two vectors point the same way? — and produces a single number. Feed it two vectors and it returns a scalar that is large and positive when they march together, zero when they are perpendicular, and negative when they pull against each other. That one number, simple as it looks, is the engine inside work and energy, projections, and the angle between any two directions in space.
The dot product has two definitions, and the fact that they agree is one of the quiet miracles of vector algebra. From components, it is the sum of pairwise products: AxBx + AyBy + AzBz. From geometry, it is |A| |B| cos θ, the product of the lengths times the cosine of the angle between them. Compute it the first way and you can solve for the angle — which is exactly what this calculator does, reporting θ alongside the product itself. Compute it the second way and you can see what the number means: it is the length of A times the length of the shadow B casts along A (or vice versa).
That shadow interpretation — the projection — is the one to keep. A · B measures how much of B lies along A, scaled by A's length. A force dotted with a displacement counts only the force component that actually pushes along the motion, which is why work is a dot product. A velocity dotted with a direction gives the speed in that direction. Whenever a physical question has the shape "how much of this acts along that?", the dot product is the tool that answers it.
Formula
A · B = AxBx + AyBy + AzBz and cos θ = (A · B) / (|A| |B|), so A · B = |A| |B| cos θ
The geometric form rearranges to give the angle directly, θ = cos⁻¹( (A · B) / (|A| |B|) ), and because the angle between two vectors is defined between 0° and 180°, the arccosine needs no quadrant correction — a luxury the component-to-angle conversion does not enjoy. Two derived formulas do heavy work in applications. The scalar projection of B onto A — the signed length of B's shadow along A — is (A · B) / |A|. The vector projection, that shadow expressed as a vector, is ((A · B) / |A|²) A. And dotting a vector with itself gives A · A = |A|², which is Pythagoras restated: the component formula for the dot product and the magnitude formula are the same arithmetic read two ways.
| Symbol | Meaning | Units |
|---|---|---|
| A · B | dot (scalar) product of A and B | product of the vectors' units (e.g. N·m = J) |
| Ax, Ay, Az | components of A (likewise B) | each vector's own unit |
| |A|, |B| | magnitudes of the two vectors | each vector's own unit |
| θ | angle between the vectors, tails together | degrees, always between 0° and 180° |
Work: the dot product physics runs on
Work is defined as W = F · d, and the dot product is doing real conceptual labour in that definition. Push a crate with a force angled 30° above the direction of travel and only the component along the floor — F cos θ — contributes to the work; the rest presses the crate into the ground and accomplishes nothing but friction. The dot product automatically discards the useless component, which is why the work–energy theorem, power (P = F · v), and so much of mechanics are written in dots. A force perpendicular to the motion does no work at all: the dot product is zero, exactly.
That zero has a famous consequence. Gravity pulls a satellite straight towards the Earth while the satellite moves at right angles to that pull (in a circular orbit), so gravity does no work on it, its speed never changes, and the orbit persists. The Moon has been falling towards the Earth for billions of years without getting closer, because falling along the force is the only kind that counts as work — and its motion is never along the force. Whenever you meet a dot product of zero in physics, something real is being said: no work, no flux, no overlap, no effect.
The rate version is just as direct: power is P = F · v, force dotted with velocity. An engine force of F = (30, 40, 0) N on a vehicle moving at v = (2, 0, 0) m/s delivers P = 60 + 0 = 60 W — only the 30 N component along the motion earns its keep, and the 40 N sideways component, however large, contributes nothing at all. Read Example 4 backwards through the projection formula and the same unity appears: the scalar projection of that force onto the displacement is 230 ÷ 5.385 = 42.71 N, and 42.71 N × 5.385 m of travel = 230 J. Work is a projection times a distance; the dot product is both halves of that sentence at once.
How to use
- Enter the x, y and z components of vector A and vector B (use 0 for z in 2D problems).
- Click "Calculate Dot Product".
- You get the dot product, both magnitudes, and the angle between the vectors in degrees.
- Read the sign before the size: positive means the vectors are acute (working together), zero means perpendicular, negative means obtuse (working against each other).
Worked examples
Example 1 — the standard pair. Let A = (1, 2, 3) and B = (4, 5, 6). A · B = (1×4) + (2×5) + (3×6) = 4 + 10 + 18 = 32. Also |A| = √14 = 3.74 and |B| = √77 = 8.77, so cos θ = 32 / (3.74 × 8.77) and the angle between them is 12.93° — the vectors point in nearly the same direction, which the strongly positive dot product already announced.
Example 2 — a perfect zero. A = (3, 4, 0) and B = (4, −3, 0): A · B = 12 − 12 + 0 = 0, so the angle is exactly 90°. The component products cancel term by term — a reliable way to test perpendicularity without measuring any angle at all.
Example 3 — parallel vectors. A = (2, 0, 0) and B = (5, 0, 0): A · B = 10 = |A| × |B| = 2 × 5, and θ = 0°. The dot product reaches its maximum possible value, |A||B|, only when the vectors are parallel — the cosine is 1 and nothing is wasted.
Example 4 — work done by an angled force. A force F = (30, 40, 0) N acts while the object moves d = (5, 2, 0) m. W = F · d = (30×5) + (40×2) = 150 + 80 = 230 J. Note that the force's large y component contributes only through the small y displacement — the dot product weighs each component by how much motion actually happened along it.
Example 5 — a negative product. A = (1, 1, 0) and B = (−2, 1, 0): A · B = −2 + 1 = −1. With |A| = 1.41 and |B| = 2.24, cos θ = −1 / (1.41 × 2.24) = −0.316, so θ = 108.43°. The vectors lean against each other; if B were a force and A a displacement, the force would be removing energy, not adding it.
Example 6 — dotting with a z component. A = (2, 3, 4) and B = (1, 0, −1): A · B = 2 + 0 − 4 = −2, with |A| = √29 = 5.39 and |B| = √2 = 1.41, giving θ = 105.23°. Leaving out the z terms would have given +2 and an acute angle — in 3D problems every component must be included, including the ones that are zero.
The dot product in real life
Work and power. W = F · d and P = F · v are the definitions, not approximations: engines, muscles and motors are all rated by how much of their force (or its rate) acts along the motion. A winch pulling at an angle delivers less useful work than its tension suggests, by exactly the cosine the dot product supplies.
Checking perpendicularity. Surveyors, carpenters using CAD, and crystallographers all test "is this exactly square?" by dotting the direction vectors: zero means square, with no protractor involved. Example 2 is the test in miniature.
Headwinds and tailwinds. The component of wind along a runway is the dot product of the wind vector with the runway's unit direction vector — the number pilots call the headwind component, which decides take-off performance and which runway is in use.
Computer graphics lighting. How brightly a surface is lit depends on the dot product of the surface's normal vector with the direction to the light: facing the light, 1; edge-on, 0; facing away, negative (clamped to darkness). Every shaded 3D image you have ever seen is this calculation repeated millions of times.
Cosine similarity in data. Documents, products and users are routinely encoded as long vectors, and the cosine of the angle between them — the dot product divided by the magnitudes — measures how similar they are. Search engines and recommendation systems run on this page's second formula.
Flux through a surface. How much of a field or flow passes through a surface is the dot product of the field with the surface's area vector: face the flow and the flux is maximal, turn edge-on and it vanishes. Electricity generation, solar-panel output and river flow through a net all reduce to this.
Projections: the dot product's second career
Divide the dot product by a magnitude and it becomes a length: the scalar projection of B onto A is (A · B)/|A|, the length of B's shadow on A's line, signed negative if B points backwards along A. Take A = (4, 3, 0) and B = (1, 0, 0): A · B = 4 and |B| = 1, so the projection of A onto the x direction is 4 — just A's x component, as it must be, since components are projections onto the axes. Project A onto the diagonal direction (1, 1, 0) instead: the dot product is 4 + 3 = 7, the direction's length is √2, and the scalar projection is 7/√2 = 4.95 — longer than either single component, because the diagonal catches parts of both.
Multiply the scalar projection by the unit vector and you get the vector projection, ((A · B)/|A|²) A: the piece of B that lies along A, extracted as a vector in its own right. Splitting any vector into a part parallel to a chosen direction and a part perpendicular to it — the projection plus the remainder — is how physicists separate useful from wasted force, how navigators split wind into headwind and crosswind, and how statisticians fit lines to data (least-squares regression is projection in disguise). All of it is this page's arithmetic with one division added.
Quick reference: what the sign and size tell you
| A · B | Angle θ | Meaning |
|---|---|---|
| = |A| |B| (maximum) | 0° | parallel, same direction |
| positive | 0° to 90° | acute — vectors cooperate |
| 0 | 90° | perpendicular — no overlap, no work |
| negative | 90° to 180° | obtuse — vectors oppose |
| = −|A| |B| (minimum) | 180° | anti-parallel, exactly opposed |
The table encodes the bound |A · B| ≤ |A| |B| (the Cauchy–Schwarz inequality): the dot product can never exceed the product of the magnitudes, because cos θ can never exceed 1. If your hand calculation ever produces a dot product larger than |A||B|, an arithmetic error is guaranteed — the calculator's angle formula would be asked for the arccosine of a number greater than 1, which does not exist.
Common mistakes
- Expecting a vector answer. The dot product is a scalar — a lone number with units but no direction. If your result has components, you have computed something else (probably the cross product or a component-wise product that means nothing).
- Omitting a component. In 3D, all three pairwise products belong in the sum, zeros included. Example 6 flips from +2 to −2 when the z terms are dropped — a different answer with a different angle.
- Using the geometric formula with the wrong angle. In |A||B| cos θ, θ is the angle between the vectors placed tail to tail, between 0° and 180° — not the angle either vector makes with an axis, and never a bearing.
- Concluding a vector is zero from a zero dot product. A · B = 0 means perpendicular (or that one vector is zero). Two perfectly healthy vectors of length 5 dot to zero at right angles, as Example 2 shows.
- Sign slips in the pairwise products. Negative components are where errors breed: (2)(−1) is −2, and the sum 2 + 0 − 4 in Example 6 depends on respecting every sign. Write the three products out separately before adding.
FAQ
What does the dot product tell us?
It measures how much two vectors point in the same direction. It is also how physics defines work: W = F · d, the force component along the displacement times the displacement.
What does a dot product of zero mean?
The vectors are perpendicular (the angle between them is 90°). A negative dot product means the angle is greater than 90° — the vectors point partly against each other.
Is the dot product a vector?
No. Unlike the cross product, the dot product is a single number (a scalar) with no direction.
What are the units of a dot product?
The product of the two vectors' units: newtons × metres = joules for work, m/s × m/s = m²/s² for two velocities. The angle the calculator reports is of course unitless, since it comes from the ratio (A · B)/(|A||B|), where the units cancel.
What is A · A — a vector dotted with itself?
It equals |A|², the squared magnitude: for (3, 4, 0), A · A = 9 + 16 = 25 = 5². This is why the magnitude formula and the dot product formula look alike — magnitude is the dot product of a vector with itself, square-rooted.
Does the order matter — is A · B the same as B · A?
Yes, the dot product is commutative: the component sum is identical either way. This is a real contrast with the cross product, where swapping the order flips the direction of the answer.
Can the dot product be bigger than |A| times |B|?
Never. |A · B| ≤ |A| |B| always, because A · B = |A||B| cos θ and |cos θ| ≤ 1. A result outside that bound means an arithmetic mistake, full stop.
How is the dot product used to project one vector onto another?
The scalar projection of B onto A is (A · B)/|A| — the signed length of B's shadow along A. Multiply by the unit vector A/|A| to get the vector projection, ((A · B)/|A|²) A. Components themselves are just projections onto the three axes.
Why is the angle always between 0° and 180°?
Because "the angle between two vectors" is defined as the smaller of the two angles formed when they are placed tail to tail, and the arccosine returns exactly that range. Direction around a full circle matters for a single vector's heading, but between two vectors only the separation counts.
Can I use the dot product in 2D?
Yes — set the z components to 0 (or omit them) and everything reduces to AxBx + AyBy. The calculator accepts 2D input directly by leaving z blank or zero.