Dot Product Calculator — Vector Dot Product, Angle Between Vectors
Calculate the dot product of two vectors and find the angle between them. Covers the algebraic and geometric formulas, vector projection, and the work-energy connection.
The dot product is one of the most useful operations in all of mathematics. It tells you how much two vectors point in the same direction — which turns out to be exactly what you need for calculating work, finding angles, projecting vectors, and powering machine learning algorithms. Use the CalcHub Dot Product Calculator for any dimension.
The Algebraic Formula
For vectors a = (a₁, a₂, ..., aₙ) and b = (b₁, b₂, ..., bₙ):
$$\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = a_1 b_1 + a_2 b_2 + \cdots + a_n b_n$$
The result is a scalar (a single number), not a vector.
Example (3D): a = (3, −2, 5), b = (1, 4, 2) a · b = 3×1 + (−2)×4 + 5×2 = 3 − 8 + 10 = 5The Geometric Formula
$$\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}||\mathbf{b}|\cos\theta$$
Where θ is the angle between the vectors and |a| is the magnitude of a.
This connects the algebraic and geometric views — and gives us a way to find angles.
Finding the Angle Between Two Vectors
Rearranging the geometric formula:
$$\cos\theta = \frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{a}||\mathbf{b}|}$$
Example: a = (1, 0, 1), b = (1, 1, 0) a · b = 1×1 + 0×1 + 1×0 = 1|a| = √(1+0+1) = √2
|b| = √(1+1+0) = √2
cos θ = 1 / (√2 × √2) = 1/2
θ = arccos(1/2) = 60°
What the Sign Tells You
| Dot Product | Angle Between Vectors | Relationship |
|---|---|---|
| > 0 | θ < 90° | Pointing roughly the same way |
| = 0 | θ = 90° | Perfectly perpendicular (orthogonal) |
| < 0 | θ > 90° | Pointing roughly opposite ways |
Vector Projection
The projection of a onto b (how much of a lies along b):
Scalar projection: proj = a · b̂ = (a · b) / |b| Vector projection: projb(a) = [(a · b) / |b|²] × b Example: Project a = (4, 2) onto b = (3, 0) Scalar proj = (4×3 + 2×0) / 3 = 12/3 = 4 Vector proj = (4/9)(3, 0) × 3 = (4, 0)This makes geometric sense — the shadow of (4, 2) on the x-axis is at x=4.
Work = Force · Displacement
In physics, work is the dot product of force and displacement vectors:
W = F · d = |F||d|cos θ Example: You push a box with force F = (10, 5) N over displacement d = (3, 0) m. W = 10×3 + 5×0 = 30 joulesThe vertical component of your force (5 N upward) does no work because the displacement is purely horizontal — cos 90° = 0. Only the component along the direction of motion does work.
How is the dot product used in machine learning?
Neural networks rely heavily on dot products. The output of a neuron is typically the dot product of the input vector with a weight vector (plus a bias), passed through an activation function. Cosine similarity — used in recommendation systems and NLP — is just the normalized dot product: cos θ = (a · b) / (|a||b|).
Can the dot product be computed in any number of dimensions?
Yes. The algebraic formula a₁b₁ + a₂b₂ + ... + aₙbₙ works in any number of dimensions, including high-dimensional spaces used in machine learning. Only the geometric interpretation (angle in space) becomes harder to visualize beyond 3D.
What's the difference between dot product and cross product?
The dot product produces a scalar and measures how parallel two vectors are (maximum when aligned, zero when perpendicular). The cross product produces a vector perpendicular to both inputs and measures how perpendicular they are (maximum when perpendicular, zero when parallel). The cross product only works in 3D.