Dot Product Calculator

Compute dot products, angles, projections and cross products for 2D–5D vectors.

Ad placeholder (leaderboard)
Enjoying the tools? Go Pro for £4.99 (one-time) and remove all ads — forever, on this device. Remove ads — £4.99

The dot product (also called the scalar product or inner product) is one of the most widely used operations in mathematics, physics, and computer science. Given two vectors A and B, it produces a single scalar that encodes both the magnitudes of the vectors and the cosine of the angle between them.

The formula

For vectors in n dimensions:

A · B = a₁b₁ + a₂b₂ + … + aₙbₙ

The equivalent geometric form links the dot product to the angle θ between the vectors:

A · B = |A| |B| cos θ

Rearranging gives the angle formula, which is how this calculator finds θ:

θ = arccos( A · B / (|A| |B|) )

where |A| = √(a₁² + a₂² + … + aₙ²) is the Euclidean magnitude of A.

How it works

  1. Dot product — component-wise multiplication followed by summation. The calculator shows every multiplicative term before summing so you can verify each step.
  2. Magnitudes — computed as the square root of the sum of squared components (the L² norm).
  3. Angle — derived from arccos(dot / (|A| × |B|)). The result is clamped to [-1, 1] before taking arccos to guard against floating-point rounding errors.
  4. Scalar projections — the component of one vector along the other: compA→B = A·B / |B| and compB→A = A·B / |A|.
  5. Cross product (3D only) — A × B = (ay·bz − az·by, az·bx − ax·bz, ax·by − ay·bx). Its magnitude equals the area of the parallelogram spanned by A and B.

The geometric flags (orthogonal, parallel, anti-parallel, acute, obtuse) are derived automatically: two vectors are orthogonal when |dot| is below 10⁻¹⁰ (within floating-point tolerance), and parallel or anti-parallel when |cos θ| ≥ 1 − 10⁻⁹.

Worked example

Consider A = (3, 1, −2) and B = (4, −3, 1) in 3D.

Step 1 — dot product:

A · B = (3)(4) + (1)(−3) + (−2)(1) = 12 − 3 − 2 = 7

Step 2 — magnitudes:

|A| = √(9 + 1 + 4) = √14 ≈ 3.7417

|B| = √(16 + 9 + 1) = √26 ≈ 5.0990

Step 3 — angle:

cos θ = 7 / (3.7417 × 5.0990) ≈ 7 / 19.079 ≈ 0.3670

θ = arccos(0.3670) ≈ 68.49°

Step 4 — cross product:

A × B = ((1)(1)−(−2)(−3), (−2)(4)−(3)(1), (3)(−3)−(1)(4)) = (1−6, −8−3, −9−4) = (−5, −11, −13)

|A × B| = √(25 + 121 + 169) = √315 ≈ 17.748 (area of the parallelogram)

Enter these values into the calculator above to verify each step in the working panel.

VectorsDot productAngle
A=(1,0), B=(0,1)090° (orthogonal)
A=(1,0), B=(1,0)10° (parallel)
A=(3,4), B=(−4,3)090° (orthogonal)
A=(3,1,−2), B=(4,−3,1)7≈ 68.49°
A=(1,2,3), B=(−3,−2,−1)−10≈ 135.58° (obtuse)
Ad placeholder (rectangle)