How to Calculate a Dot Product
The dot product (also called the scalar product) combines two vectors into a single number. That number measures how much the two vectors point the same way: it is at its largest when the vectors are parallel, exactly zero when they are perpendicular, and negative when they point in opposing directions. Enter the components of both vectors above — in 2D or 3D — and this calculator returns the dot product, both magnitudes, the angle between them in degrees and radians, and the full step-by-step working. That combination is why the dot product shows up everywhere from physics work problems to 3D graphics lighting.
The Formula
Multiply each pair of matching components, then add the products: a · b = a₁b₁ + a₂b₂ + a₃b₃. In 2D the third term simply drops away. Order does not matter — a · b always equals b · a.
Here a₁, a₂, and a₃ are the components of vector a along the x, y, and z axes, and b₁, b₂, b₃ are the matching components of vector b. The symbols |a| and |b| denote the magnitudes — the lengths — of the two vectors, each found by Pythagoras: |a| = √(a₁² + a₂² + a₃²). θ (theta) is the angle between the vectors when they are placed tail to tail. Components pair off strictly by position: first with first, second with second, never across.
How to Use the Calculator
- Choose the size: click “2D vectors” or “3D vectors” — 3D shows a third component box for each vector.
- Enter vector a: type its components into the a₁ (x), a₂ (y), and a₃ (z) fields.
- Enter vector b the same way in the b₁, b₂, b₃ fields, keeping the component order consistent.
- Press Calculate Dot Product. You get the headline a · b value, the magnitudes |a| and |b|, the angle θ in degrees and radians, and numbered steps you can compare against your own working.
Worked Example 1: (1, 2, 3) · (4, −5, 6)
- Multiply the components: 1 × 4 = 4 · 2 × −5 = −10 · 3 × 6 = 18.
- Add them: 4 − 10 + 18 = 12.
- Magnitudes: |a| = √(1 + 4 + 9) = √14 ≈ 3.7417; |b| = √(16 + 25 + 36) = √77 ≈ 8.775.
- Angle: cos θ = 12 ÷ (3.7417 × 8.775) ≈ 0.3655, so θ ≈ 68.56°.
Two sanity checks confirm the arithmetic. First, the sign: the dot product came out positive, and 68.56° is indeed acute, so the sign and the angle agree. Second, the size: a dot product can never exceed |a| × |b| ≈ 32.83, and 12 sits comfortably inside that bound. Notice the one negative component, −5, dragged the total down through its −10 product — without it, the vectors would have been much more closely aligned. If your hand calculation ever produces a dot product larger than the product of the magnitudes, a component has been mis-multiplied.
Worked Example 2: (4, 2) · (−1, 5) in 2D
- Multiply matching components: 4 × −1 = −4 and 2 × 5 = 10.
- Add the products: −4 + 10 = 6.
- Magnitudes: |a| = √(16 + 4) = √20 ≈ 4.4721; |b| = √(1 + 25) = √26 ≈ 5.099.
- Angle: cos θ = 6 ÷ (4.4721 × 5.099) = 6 ÷ 22.8035 ≈ 0.2631, so θ ≈ 74.74° (about 1.3045 radians).
This pair is a good warning against judging by one component. The x-components fight each other — 4 points right, −1 points left, contributing −4 — yet the y-components agree strongly enough (+10) to pull the total positive. The angle confirms the story: 74.74° is acute but far from parallel, exactly matching a small positive dot product relative to the maximum possible value of 22.80. Had the second vector been (−1, 2) instead, the products would be −4 and 4, the dot product exactly 0, and the vectors perfectly perpendicular.
Reading the Sign
The sign is the fastest summary of the geometry: positive means an acute angle (the vectors lean the same way), zero means exactly perpendicular, and negative means an obtuse angle (they lean apart). A zero dot product is the standard test for perpendicular vectors in exams and in code.
Where the Dot Product Earns Its Keep
In physics, work is a dot product: W = F · d multiplies a force by a displacement and automatically ignores the part of the force wasted pushing sideways. In computer graphics, the brightness of a surface is computed from the dot product of its normal vector and the light direction — face the light and the value is high, turn edge-on and it falls to zero. Game engines use it to check whether an enemy is in front of a player, and cosine similarity — the dot product of two normalised vectors — ranks search results and recommendations in machine learning.
Common Mistakes
- Pairing the wrong components. a₁ must multiply b₁, not b₂. Writing the vectors in different orders between the two rows scrambles every product while still looking tidy.
- Dividing by the wrong thing in the angle formula. cos θ needs the dot product divided by |a| × |b| — the product of the magnitudes, not their sum, and not one magnitude alone.
- Expecting a vector as the answer. The dot product is a scalar. If you need a vector back — a perpendicular direction, say — you want the cross product, a different operation entirely.
Working with vectors in matrix form? The row-by-column multiplication in our matrix calculator is the dot product repeated. For lengths between points, use the distance formula calculator, and for direction of a line, the slope calculator.