Vector Calculator (Magnitude, Dot & Cross Product)
Vectors have both size and direction, and two products combine them: the dot product (a number) and the cross product (a new vector at right angles to both). This vector calculator takes the x, y and z components of vectors a and b and returns each magnitude, a · b, a × b and the angle between them.
How to use the vector calculator
Enter the x, y and z components of the two vectors (use 0 for z with 2D vectors). The calculator returns both magnitudes, the dot product, the three components and the length of the cross product, and the angle between the vectors.
Vector formulas
|a| = √(aₓ² + a_y² + a_z²) · a · b = aₓbₓ + a_yb_y + a_zb_z · θ = arccos(a · b ÷ (|a||b|))
a × b = (a_yb_z − a_zb_y, a_zbₓ − aₓb_z, aₓb_y − a_ybₓ)
Example
a = (3, −2, 1) and b = (1, 4, 2):
- |a| = √(9 + 4 + 1) = 3.7417, |b| = √(1 + 16 + 4) = 4.5826
- a · b = 3 × 1 + (−2) × 4 + 1 × 2 = -3
- a × b = ((−2)(2) − (1)(4), (1)(1) − (3)(2), (3)(4) − (−2)(1)) = (-8, -5, 14)
- |a × b| = √285 = 16.8819
- θ = arccos(-3 ÷ (3.7417 × 4.5826)) = 100.08°
Worked vector products
| a | b | a · b | a × b | Angle |
|---|---|---|---|---|
| (1, 0, 0) | (0, 1, 0) | 0 | (0, 0, 1) | 90.00° |
| (1, 2, 3) | (4, 5, 6) | 32 | (-3, 6, -3) | 12.93° |
| (3, -2, 1) | (1, 4, 2) | -3 | (-8, -5, 14) | 100.08° |
| (2, 2, 0) | (1, 0, 0) | 2 | (0, 0, -2) | 45.00° |
| (1, 1, 1) | (-1, -1, -1) | -3 | (0, 0, 0) | 180.00° |
| (0, 3, 4) | (0, 4, -3) | 0 | (-25, 0, 0) | 90.00° |
Notes
- A dot product of zero means the vectors are perpendicular; a cross product of zero means they are parallel.
- The torque on a lever is the cross product r × F — see the torque calculator.
Frequently asked questions
How do I calculate the magnitude of a vector?
The magnitude is |a| = √(aₓ² + a_y² + a_z²) — the 3D version of the Pythagorean theorem.
What is the dot product used for?
a · b = |a||b| cos θ, so it gives the angle between two vectors and tests whether they are perpendicular (dot product zero). In physics, work = force · displacement.
What does the cross product give?
A vector perpendicular to both a and b, with length |a||b| sin θ — the area of the parallelogram they span. Its direction follows the right-hand rule, and a × b = −(b × a).
How do I use this for 2D vectors?
Set both z components to 0. The cross product then points purely along z, and its z component equals aₓb_y − a_ybₓ.