Dot Product Calculator

This dot product calculator works with 2D, 3D, and general n-dimensional vectors. Enter the components of two vectors and get the scalar product a·b, the length of each vector, the angle between them, and the projection of A onto B, with step-by-step expansion.

It is designed for students and professionals in linear algebra, physics, engineering, and data science who need a precise and readable breakdown of vector computations.

1. Enter vectors

Use comma or space separated values. The two vectors must have the same dimension. Examples: 1, 2, 3, 0.5 -1.2 4.0, 2 0 -3 5.

Supports any dimension with exact component product

Dot product – algebraic and geometric definitions

For two vectors \( \mathbf{a}, \mathbf{b} \in \mathbb{R}^n \) with components \( \mathbf{a} = (a_1, a_2, \dots, a_n) \) and \( \mathbf{b} = (b_1, b_2, \dots, b_n) \), the dot product (or scalar product) is defined as

\[ \mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = a_1 b_1 + a_2 b_2 + \dots + a_n b_n. \]

Geometrically, the dot product relates to the angle \( \theta \) between the two vectors:

\[ \mathbf{a} \cdot \mathbf{b} = \|\mathbf{a}\| \, \|\mathbf{b}\| \cos\theta, \]

where \( \|\mathbf{a}\| \) and \( \|\mathbf{b}\| \) denote the Euclidean norms (lengths). This gives

\[ \cos\theta = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\| \, \|\mathbf{b}\|}, \qquad \theta = \arccos\!\left(\frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{a}\| \, \|\mathbf{b}\|}\right). \]

Orthogonality and angle between vectors

  • Orthogonal vectors: \( \mathbf{a} \) and \( \mathbf{b} \) are orthogonal if and only if \( \mathbf{a} \cdot \mathbf{b} = 0 \). Geometrically, the angle between them is \( 90^\circ \).
  • Parallel vectors: If \( \theta = 0^\circ \) or \( 180^\circ \), the vectors are parallel or anti-parallel. In practice we test whether the unit vectors have the same or opposite direction within a tolerance.
  • Zero vector: If one of the vectors is zero, its direction is undefined, so the angle is also undefined even though the dot product is 0.

Projection of one vector onto another

The projection of \( \mathbf{a} \) onto a non-zero vector \( \mathbf{b} \) is the component of \( \mathbf{a} \) that lies in the direction of \( \mathbf{b} \). It is given by

\[ \operatorname{proj}_{\mathbf{b}}(\mathbf{a}) = \frac{\mathbf{a} \cdot \mathbf{b}}{\|\mathbf{b}\|^2}\,\mathbf{b}. \]

The scalar factor \( (\mathbf{a} \cdot \mathbf{b}) / \|\mathbf{b}\|^2 \) tells you how many “copies” of \( \mathbf{b} \) you need to reach the shadow of \( \mathbf{a} \) along \( \mathbf{b} \). The length of this projection is \( \|\operatorname{proj}_{\mathbf{b}}(\mathbf{a})\| = \|\mathbf{a}\|\cos\theta \).

Typical applications of the dot product

  • Work in physics: Work done by a constant force \(\mathbf{F}\) along a displacement \(\mathbf{s}\) is \( W = \mathbf{F} \cdot \mathbf{s} = \|\mathbf{F}\|\|\mathbf{s}\|\cos\theta \).
  • Projections and decompositions: Splitting a vector into components along and orthogonal to a direction.
  • Similarity in data science: The cosine of the angle between feature vectors is a measure of similarity used in information retrieval and recommender systems.
  • Linear algebra: Orthogonality, orthogonal projections, and orthonormal bases are all built on the dot product.

Dot product – FAQ