The dot product multiplies matching components and adds them, a · b = a₁b₁ + a₂b₂ + a₃b₃. The cross product of two 3D vectors is a vector perpendicular to both, and its length equals the area of the parallelogram they span. The angle between the vectors is computed as θ = atan2(|a × b|, a · b), which equals arccos(a · b / |a||b|) but stays accurate for nearly parallel vectors, and the projection of a onto b is (a · b / |b|²) b.
Physics (work and torque), 3D graphics and linear algebra are the usual uses. The default vectors a = (1, 2, 3) and b = (4, 5, 6) give a · b = 32, a × b = (−3, 6, −3) and an angle of about 12.93°.
A dot product of 0 means the vectors are perpendicular; a zero cross product means they are parallel or one is zero. In 2D mode both vectors lie in the xy-plane, so their cross product points along z: (3, 4) × (4, −3) = (0, 0, −25).
How to calculate the dot product
Multiply matching components and add them: a · b = a₁b₁ + a₂b₂ + a₃b₃. The result is a single number, not a vector. For a = (2, −1, 3) and b = (1, 4, −2), a · b = 2 − 4 − 6 = −8. For 2D vectors the sum has two terms instead of three.
Geometrically, a · b = |a||b| cos θ, where θ is the angle between the vectors. A positive dot product means the angle is under 90°, zero means exactly 90°, and negative means over 90°. OpenStax's dot product lesson develops both forms.
How to calculate the cross product
For 3D vectors, a × b = (a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁), a vector perpendicular to both a and b. For the same a = (2, −1, 3) and b = (1, 4, −2):
x: (−1)(−2) − (3)(4) = 2 − 12 = −10
y: (3)(1) − (2)(−2) = 3 + 4 = 7
z: (2)(4) − (−1)(1) = 8 + 1 = 9
So a × b = (−10, 7, 9). Check it against both inputs: (−10, 7, 9) · a = −20 − 7 + 27 = 0, and (−10, 7, 9) · b = −10 + 28 − 18 = 0.
The direction follows the right-hand rule, and swapping the order flips the sign: b × a = (10, −7, −9). OpenStax's cross product lesson covers the direction and area meaning.
Worked dot and cross products
Dimensions
a
b
Dot product
Cross product
3D
(1, 2, 3)
(4, 5, 6)
32
(−3, 6, −3)
2D
(3, 4)
(4, −3)
0
(0, 0, −25)
2D
(1, 0)
(−2, 0)
−2
(0, 0, 0)
3D
(1, 2, 3)
(2, 4, 6)
28
(0, 0, 0)
(1, 2, 3) and (4, 5, 6): 4 + 10 + 18 = 32, and the angle between them is about 12.93°.
(3, 4) and (4, −3): the dot product is 12 − 12 = 0, so they are perpendicular. A 2D cross product keeps only its z-component, here 3 × (−3) − 4 × 4 = −25.
(1, 0) and (−2, 0): they point in opposite directions, so the dot product is negative, the cross product is zero and the angle is 180°.
(1, 2, 3) and (2, 4, 6): b = 2a, so the vectors are parallel, the cross product is zero and the angle is 0°.
Magnitude and the angle between two vectors
A vector's magnitude is |a| = √(a₁² + a₂² + a₃²). For (1, 2, 3), |a| = √14 ≈ 3.742, and for (4, 5, 6), |b| = √77 ≈ 8.775.
The angle comes from cos θ = (a · b) ÷ (|a||b|) = 32 ÷ (√14 × √77) ≈ 0.9746, so θ ≈ 12.93°. For (2, −1, 3) and (1, 4, −2), the dot product of −8 gives an obtuse angle of about 117.81°.
Near 0° and 180° the arccos form loses accuracy in floating point, so θ = atan2(|a × b|, a · b) is the safer formula (Kahan's notes on roundoff). A zero vector has no direction, so its angle with another vector is undefined, not 0°.
Parallelogram and triangle area
The length |a × b| equals the area of the parallelogram spanned by a and b, and half of it is the area of the triangle they form. For (1, 2, 3) and (4, 5, 6), |(−3, 6, −3)| = √54 ≈ 7.348, so the triangle's area is about 3.674.
Projection of a onto b
The scalar projection, the signed length of a along b, is (a · b) ÷ |b|. The vector projection is ((a · b) ÷ |b|²) b. Projecting (2, 3) onto (4, 0) gives a scalar projection of 8 ÷ 4 = 2 and the vector (2, 0).
Projection is not symmetric: projecting b onto a answers a different question. A negative scalar projection means a points partly against b.
Dot and cross products in physics
Work is a dot product, W = F · d. A force of (3, 4) N that moves an object through (5, 0) m does 15 J of work, because only the force along the motion counts.
Torque is a cross product, τ = r × F. A 10 N force along y, applied 0.5 m from the pivot along x, gives τ = (0, 0, 5) N·m, pointing along the axis of rotation.
Common mistakes
Reversing the cross product. a × b and b × a point in opposite directions.
Mixing up the zero tests. A zero dot product means perpendicular; a zero cross product means parallel or opposite.
Reading a 2D cross product as a plain number. It is the z-component of a 3D vector. A positive value means b lies counterclockwise from a.
Input notes
In 2D mode both z-components are zero, so the cross product points along z.
Enter each component separately: 3i + 4j becomes x = 3 and y = 4.
Components carry no units. Use one consistent unit system before entering physical vectors.
How do you calculate the dot product of two vectors?
Multiply corresponding components and add the results: a · b = a₁b₁ + a₂b₂ + a₃b₃. For (1, 2, 3) · (4, 5, 6) that is 4 + 10 + 18 = 32. The dot product also equals |a||b| cos θ, so it is positive when the angle is under 90°, 0 at exactly 90° and negative beyond it: (1, 0) · (−2, 0) = −2.
How do you calculate the cross product?
For a = (a₁, a₂, a₃) and b = (b₁, b₂, b₃), a × b = (a₂b₃ − a₃b₂, a₃b₁ − a₁b₃, a₁b₂ − a₂b₁). For (1, 2, 3) × (4, 5, 6) that gives (12 − 15, 12 − 6, 5 − 8) = (−3, 6, −3). The result is perpendicular to both vectors, follows the right-hand rule, and changes sign if the order is swapped: b × a = (3, −6, 3).
How do you find the angle between two vectors?
Use cos θ = (a · b)/(|a||b|). For (1, 2, 3) and (4, 5, 6), cos θ = 32/(√14 × √77) ≈ 0.974632, so θ ≈ 12.93°. Near 0° or 180° the arccos form loses accuracy, so the calculator uses the equivalent θ = atan2(|a × b|, a · b), the form William Kahan recommends in his notes on floating-point roundoff.
What does it mean if the dot product is zero?
The two vectors are perpendicular (orthogonal), provided neither is the zero vector. (3, 4) · (4, −3) = 12 − 12 = 0, so those vectors meet at exactly 90°. In physics the same test shows that a force at right angles to the motion does no work, since work is the dot product of force and displacement.
What is the difference between scalar and vector projection?
The scalar projection of a onto b is the signed length of a along b, a · b / |b|; the vector projection is that length times the unit vector of b, (a · b / |b|²) b. Projecting (2, 3) onto (4, 0) gives a scalar projection of 8/4 = 2 and a vector projection of (2, 0). A negative scalar projection means a points partly against b.
This calculator includes 5 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.
Put this calculator on your site
Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.