Dot Product Calculator
Multiply matching components, add the products, and two vectors collapse into a single number that says how much they point the same way. This dot product calculator does that for 2D or 3D vectors and goes further than the bare product: it returns both magnitudes, the angle between the vectors in degrees and radians, a perpendicular check, and the scalar and vector projections of A onto B, with the term-by-term working shown.
Vector A
Vector B
Dot product:
The angle is undefined when either vector is the zero vector. A zero dot product with two nonzero vectors means they are perpendicular.
Quick Answer
- Quick Answer
- Reading the result: the sign is the story
- The five formulas this calculator runs
- Worked example: A = (2, 3, 4) and B = (5, 1, 7), every step
- Dot product or cross product: which one do you need?
- Where the dot product earns its keep
- What competing calculators miss
- Edge cases the tool treats honestly
- Frequently Asked Questions
- Add This Calculator to Your Website
- References
Reading the result: the sign is the story
The number 41 on its own says little. Its sign and size relative to the two magnitudes say almost everything, because A · B = |A|·|B| cos θ ties the product directly to the angle.
| Dot product | Angle θ | Relationship | Projection of A onto B |
|---|---|---|---|
| Positive | 0° to 90° | Acute vectors lean the same way | Positive, points along B |
| Zero (both vectors nonzero) | Exactly 90° | Perpendicular orthogonal | Zero vector |
| Negative | 90° to 180° | Obtuse vectors lean opposite ways | Negative, points against B |
| Equals |A|·|B| | 0° | Parallel, same direction | Full length of A |
| Equals −|A|·|B| | 180° | Parallel, opposite directions | Negative full length of A |
In the worked example the three component products contribute very unevenly. The z components do most of the work, which is typical: the dot product is dominated by whichever axis both vectors are large on.
That breakdown is a practical checking tool. If a hand calculation and the tool disagree, compare term by term: a sign slip or a swapped component shows up in exactly one row. The badge on the result applies the same table automatically, labelling the pair acute, perpendicular, or obtuse on every calculation.
The five formulas this calculator runs
One product, four consequences. All five formulas below are standard linear algebra, stated in the form the tool computes them.
Magnitude: |A| = √(ax2 + ay2 + az2), the Pythagorean theorem extended to three axes.
Angle: θ = cos−1( (A · B) ÷ (|A|·|B|) ), always between 0° and 180°.
Scalar projection of A onto B: (A · B) ÷ |B|, the signed length of A’s shadow along B.
Vector projection of A onto B: ((A · B) ÷ |B|2) × B, that shadow expressed as a vector.
The geometric definition comes first in most textbooks and the component formula follows from it: the Wolfram MathWorld entry on the dot product defines it as |A|·|B| cos θ for nonzero vectors and derives the component sum from that definition, which is why the angle formula on this page is just the definition rearranged. Engineering students meet the same identities in statics, where the Engineering LibreTexts section on dot products uses them to find the component of a force along a line, which is exactly the projection this tool reports. A related reading of a single vector’s direction, rather than a pair, is handled by a central angle calculator in circular geometry, while the same component arithmetic scaled up to matrices leads to the complex eigenvector calculator.
Worked example: A = (2, 3, 4) and B = (5, 1, 7), every step
These are the pre-filled vectors, so you can reproduce every figure below with one click on Calculate.
Dot product. (2)(5) + (3)(1) + (4)(7) = 10 + 3 + 28 = 41.
Magnitudes. |A| = √(4 + 9 + 16) = √29 = 5.385165. |B| = √(25 + 1 + 49) = √75 = 8.660254.
Angle. cos θ = 41 ÷ (5.385165 × 8.660254) = 41 ÷ 46.636895, so θ = 28.462133°, which the tool also reports as 0.496758 rad. Acute, as the positive product promised.
Projections. Scalar projection of A onto B: 41 ÷ 8.660254 = 4.734272. Vector projection: (41 ÷ 75) × (5, 1, 7) = (2.733333, 0.546667, 3.826667). Read that as: the part of A that lies along B’s direction is a vector about 4.73 long pointing the same way as B.
A 2D check. Switch the tool to 2D with A = (3, 4) and B = (5, 2): the product is (3)(5) + (4)(2) = 15 + 8 = 23, |A| = 5, |B| = 5.385165, the angle is 31.328693° (0.546789 rad), the scalar projection is 4.270993, and the vector projection is (3.965517, 1.586207). The 3-4-5 magnitude in that example is a useful hand check: if |A| had come out as anything but exactly 5, the inputs would be wrong.
Dot product or cross product: which one do you need?
The two products answer opposite questions about a pair of vectors, and picking the wrong one is the most common vector mistake after sign errors.
Dot product: this page
Returns a scalar. Measures alignment: how much of A runs along B. Biggest when the vectors are parallel, zero when perpendicular. Use it for angles, projections, work (force · displacement), and similarity scores. Works in 2D, 3D, and any dimension.
Cross product: the companion tool
Returns a vector perpendicular to both inputs. Measures the perpendicular part: biggest when the vectors are at right angles, zero when parallel. Use it for torque, rotation axes, and surface normals. Defined in 3D only. Compute it with the cross product calculator.
The intuition Khan Academy uses in its comparison of the dot and cross products is worth borrowing: the dot product grows as the vectors line up, the cross product grows as they spread apart, and each is at its minimum exactly where the other is at its maximum. If your question contains the words angle, along, or how much in the direction of, it is a dot product question. If it contains perpendicular to both, torque, or normal, it is a cross product question.
Where the dot product earns its keep
Work in physics. Work = force · displacement. Only the force component along the motion counts, and the dot product discards the rest automatically. A force at right angles to the movement does no work, which the zero product states in one line.
Lighting in graphics. A surface is bright when its normal points toward the light. Engines compute normal · light direction thousands of times per frame; a negative result means the surface faces away and is not lit at all.
Similarity in data work. Embedding vectors in search and recommendation systems are compared by dot product (or its normalised cousin, cosine similarity, which is this page’s angle calculation in disguise). A larger product means two items point the same way in feature space.
Orthogonality tests everywhere. Checking that two directions are truly perpendicular, in geometry, signal processing, or least-squares fitting, is one dot product and a comparison with zero.
What competing calculators miss
The top-ranking dot product tools are strong on the core product. The differences are in the edges, and the edges are where homework and code actually go wrong.
Miss 1: zero vectors handled badly. Several rival tools, and the older version of this page, refuse to compute anything when a vector is (0, 0, 0), or report a NaN angle. The dot product of a zero vector is perfectly well defined: it is 0. Only the angle and the projection onto a zero vector are undefined, and this tool says exactly that, per output, instead of failing the whole calculation.
Miss 2: projections split across separate pages. Pearson’s calculator family, for example, puts the projection on its own page from the dot product, so a student needs two tools and must re-enter the vectors. Here the scalar and vector projections ride along with every calculation, because they cost nothing once the product and magnitudes exist.
Miss 3: no working shown. A bare answer of 41 cannot be marked, debugged, or learned from. This tool prints each component product and each magnitude step, so a wrong input is visible in the working rather than hidden behind a wrong total.
Miss 4: angle in degrees only. Physics and calculus courses work in radians as often as degrees. The tool reports both, 28.462133° and 0.496758 rad for the worked example, so there is no second conversion step to get wrong.
Miss 5: n-dimensional input nobody asked for. One ranking rival leads with free-form coordinate lists for any dimension, which is powerful and also an easy place to miscount components. Most real work is 2D or 3D with labelled fields; this tool keeps those fields explicit and hides the z row in 2D mode so a stale z value can never leak into a 2D answer.
Edge cases the tool treats honestly
Zero vector. Dot product 0, magnitudes as computed, angle undefined, perpendicular verdict reported as n/a rather than Yes. Calling a zero vector perpendicular to everything would be a defensible convention in some texts; silently printing Yes would mislead more readers than it helps.
Negative components and negative products. Fully supported. A negative product is information, not an error: the angle is obtuse, and the scalar projection is negative because A’s shadow falls on the extension of B backwards.
Rounding. Every displayed number is rounded to six decimal places by the tool’s formatter, so 5.385165 is √29 to that precision. Products of large components can exceed the display’s comfort, but the arithmetic itself is ordinary double-precision, the same as a scientific calculator.
Mismatched dimensions. Not possible here by design: both vectors share the one Dimensions setting, so a 2D A can never be dotted against a 3D B by accident.
Frequently Asked Questions
Multiply the matching components of the two vectors and add the results. In 3D: A · B = axbx + ayby + azbz. The answer is a single number, not a vector.
Use θ = cos⁻¹((A · B) / (|A|·|B|)). Compute the dot product, divide by the product of the magnitudes, and take the inverse cosine. The result is always between 0° and 180°. This tool reports it in degrees and radians.
The vectors are perpendicular (orthogonal), provided neither is the zero vector. A 90° angle makes cos θ = 0, so the product vanishes. If one vector is zero, the product is also 0 but no angle exists.
Yes. A negative dot product means the angle between the vectors exceeds 90°; they point in broadly opposite directions. The most negative value possible is −|A|·|B|, reached at exactly 180°.
The dot product returns a scalar measuring alignment; the cross product returns a vector perpendicular to both inputs, with magnitude |A|·|B| sin θ, and is only defined in 3D. Use the dot product for angles and projections, the cross product for torque and normals.
The projection of A onto B is the shadow of A along B’s direction. The scalar projection (A · B) / |B| is its signed length; multiplying by B’s unit direction gives the projection vector, ((A · B) / |B|²) B.
Yes: A · B = axbx + ayby. Switch the tool to 2D mode and enter just the x and y components; the z fields hide so they cannot affect the result.
Zero. Any vector dotted with (0, 0, 0) gives 0. The angle is undefined in that case because you would divide by a zero magnitude, and a projection onto a zero vector is undefined for the same reason.
Add This Calculator to Your Website
References
- Wolfram MathWorld, “Dot Product” – the geometric definition A · B = |A|·|B| cos θ, the component formula, scalar and vector projection, and the properties (commutative, distributive) used on this page. MathWorld: Dot Product. Accessed October 2026.
- LibreTexts, Engineering Statics (Baker and Haynes), “2.7: Dot Products” – dot products applied to force vectors, including the angle between two vectors and the component of a force along a line. LibreTexts: Dot Products (Engineering Statics). Accessed October 2026.
- LibreTexts, All Things Flow (Smyth, Oregon State University), “2.1: Scalars and Vectors” – the index-notation definition of the dot product as a sum of component products, magnitude from the self-product, and orthogonality at a zero product. LibreTexts: Scalars and Vectors. Accessed October 2026.
- Khan Academy, Linear Algebra, “Dot and Cross Product Comparison and Intuition” – why the dot product is largest for parallel vectors and zero for perpendicular ones, and how the cross product behaves in the opposite way. Khan Academy: Dot and Cross Product Comparison. Accessed October 2026.
- Khan Academy, “The Dot Product” – the projection interpretation of the dot product, as the length of one vector’s shadow on another multiplied by the second vector’s magnitude, the basis of the projection outputs. Khan Academy: The Dot Product. Accessed October 2026.
- Delft University of Technology, Interactive Textbooks, “Linear Algebra” (NB1140) – inner and cross products in physics, magnitude and angle from components, and the projection as the length of one vector along another. TU Delft: Linear Algebra, Inner and Cross Products. Accessed October 2026.
- Wolfram MathWorld Classroom, “Inner Product” – the dot product as the standard inner product on Euclidean space, the terminology used in linear algebra courses. MathWorld Classroom: Inner Product. Accessed October 2026.
