Dot Product Calculator Formula

Understand the math behind the dot product calculator. Each variable explained with a worked example.

Formulas Used

Dot

dot = a1*b1 + a2*b2 + a3*b3

Mag A

mag_a = sqrt(pow(a1,2) + pow(a2,2) + pow(a3,2))

Mag B

mag_b = sqrt(pow(b1,2) + pow(b2,2) + pow(b3,2))

Angle

angle = acos((a1*b1 + a2*b2 + a3*b3) / (sqrt(pow(a1,2)+pow(a2,2)+pow(a3,2)) * sqrt(pow(b1,2)+pow(b2,2)+pow(b3,2)))) * 180 / pi

Variables

VariableDescriptionDefault
a1Vector A: x1
a2Vector A: y2
a3Vector A: z3
b1Vector B: x4
b2Vector B: y5
b3Vector B: z6

How It Works

Dot Product

Formula

A · B = a₁b₁ + a₂b₂ + a₃b₃

Geometric Interpretation

A · B = |A| × |B| × cos(theta)

So: theta = arccos(A · B / (|A| × |B|))

Properties

  • If A · B = 0, the vectors are perpendicular
  • If A · B > 0, the angle is acute (less than 90°)
  • If A · B < 0, the angle is obtuse (greater than 90°)
  • Worked Example

    Dot product of (1,2,3) and (4,5,6).

    a1 = 1a2 = 2a3 = 3b1 = 4b2 = 5b3 = 6
    1. 01A · B = 1×4 + 2×5 + 3×6 = 4 + 10 + 18 = 32
    2. 02|A| = √(1+4+9) = √14 ≈ 3.742
    3. 03|B| = √(16+25+36) = √77 ≈ 8.775
    4. 04cos(theta) = 32/(3.742 × 8.775) ≈ 0.9746
    5. 05theta ≈ 12.93°

    Ready to run the numbers?

    Open Dot Product Calculator