# Dot product

The dot product, also commonly known as the "inner product", or, less commonly, the "scalar product", is a number associated with a pair of vectors. It figures prominently in many problems in physics, and variants of it appear in an enormous number of mathematical areas.

 Subject classification: this is a mathematics resource.
 Educational level: this is a secondary education resource.
 Educational level: this is a tertiary (university) resource.

## Geometric Definition

It is defined geometrically as the product of the lengths of the two vectors times the cosine of the angle between them. This definition is used in 2 dimensions (plane geometry) or 3 dimensions (solid geometry and physics.) The dot product is written with a raised dot between the vectors,

${\displaystyle {\vec {A}}\cdot {\vec {B}}=AB\cos \theta }$ ,

where ${\displaystyle \theta }$  is the angle between the two vectors. Following a common convention, the magnitudes have been written as the variable without the vector symbol: ${\displaystyle A\equiv ||{\vec {A}}||}$ , and ${\displaystyle B\equiv ||{\vec {B}}||}$ .

A few properties are immediately apparent.

• It is symmetric: ${\displaystyle {\vec {A}}\cdot {\vec {B}}={\vec {B}}\cdot {\vec {A}}\,}$ .
• It is linear in each argument: ${\displaystyle (\lambda {\vec {A}})\cdot {\vec {B}}={\vec {A}}\cdot (\lambda {\vec {B}})=\lambda ({\vec {A}}\cdot {\vec {B}})\,}$ .
• If the two vectors are orthogonal (perpendicular) to each other, their dot product is zero. This is because the cosine of 90° is zero.
• The length of a vector is the square root of the dot product of the vector with itself. This is because the angle is 0, so the cosine is 1.
${\displaystyle \|{\vec {A}}\|={\sqrt {{\vec {A}}\cdot {\vec {A}}}}\,}$
(The double absolute value sign, shown above, is known as the norm. It can be thought of as a generalization of the absolute value of a number. It is used in many places in mathematics. For vectors, it is the length.)

## Algebraic definition

It turns out that, given the components of vectors in a Cartesian (Euclidean) vector space, there is an extremely simple way to calculate the dot product. It is the sum of the pairwise products of the components of the vectors:

${\displaystyle {\vec {A}}\cdot {\vec {B}}=A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}\,}$ .

or, depending on what notation you prefer:

${\displaystyle {\vec {A}}\cdot {\vec {B}}=A_{1}B_{1}+A_{2}B_{2}+A_{3}B_{3}=\sum _{i=1}^{3}A_{i}B_{i}\,}$ .

This definition is also used in 2 dimensions, with only two terms in the addition.

It needs to be emphasized that this formula only works if the components of the vectors are described in Cartesian space. In other coordinate systems, it may be necessary to use other, somewhat more complicated formulas.

The equivalence of this algebraic definition and the earlier geometric one is extremely important. Among many other things, it lets us calculate the angle between two vectors, given their components. Calculate the lengths of the vectors as the square root of the dot product of each vector with itself, calculate the dot product of the two vectors, divide by the lengths, and take the inverse cosine:

${\displaystyle \theta =\cos ^{-1}\left({\frac {A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}}{\|A\|\|B\|}}\right)\,}$ .

Using the algebraic definition, one can see that the dot product is additive in each argument:

${\displaystyle {\vec {A}}\cdot ({\vec {B}}+{\vec {C}})={\vec {A}}\cdot {\vec {B}}+{\vec {A}}\cdot {\vec {C}}\,}$ .
${\displaystyle ({\vec {A}}+{\vec {B}})\cdot {\vec {C}}={\vec {A}}\cdot {\vec {C}}+{\vec {B}}\cdot {\vec {C}}\,}$ .

something which is not so easy to see from the geometric definition.

## Proof of Equivalence of the Two Definitions

If one is good at geometric visualization in 3 dimensions, and has a good understanding of the Euclidean rotation group, one can rotate the Cartesian coordinate system around until the two vectors lie in the x-y plane, and the first vector lies along the x axis.

This requires knowing that any rotation around a coordinate axis is a transformation by an orthogonal matrix, that the sum of the pairwise products of components is unchanged by an orthogonal transformation, and that the two vectors can be rotated into the required position by a combination of rotations around coordinate axes.
Once this is done, it becomes a problem in 2 dimensions.

${\displaystyle B_{x}\,}$  is the projection of ${\displaystyle {\vec {B}}\,}$  onto the x axis, which is also the length of ${\displaystyle {\vec {B}}\,}$  times the cosine of ${\displaystyle \theta \,}$ .

${\displaystyle B_{x}=\|B\|\cos \theta \,}$
${\displaystyle A_{x}=\|A\|\,}$
${\displaystyle A_{y}=0\,}$
${\displaystyle A_{x}B_{x}+A_{y}B_{y}=A_{x}B_{x}=\|A\|\|B\|\cos \theta \,}$

Another way to prove this is to prove it first for the norm of a vector, and then use the law of cosines.

We first need to show that the geometric length of ${\displaystyle {\vec {A}}\,}$  is ${\displaystyle {\sqrt {A_{x}^{2}+A_{y}^{2}+A_{z}^{2}}}\,}$

Whatever coordinate system we are in, the vector ${\displaystyle {\vec {A}}\,}$  runs from one corner to the opposite corner of a rectangular box with sides ${\displaystyle A_{x}\,}$ , ${\displaystyle A_{y}\,}$ , and ${\displaystyle A_{z}\,}$ .

Two applications of Pythagoras' theorem suffice to prove the required result. The length of a vector is the square root of the sum of the squares of its components.

Next, whatever coordinate system we are in, form the plane containing ${\displaystyle {\vec {A}}\,}$  and ${\displaystyle {\vec {B}}\,}$ , and use plane geometry. Let ${\displaystyle {\vec {C}}={\vec {A}}-{\vec {B}}\,}$ . That is, ${\displaystyle {\vec {C}}\,}$  runs from the tip of ${\displaystyle {\vec {B}}\,}$  to the tip of ${\displaystyle {\vec {A}}\,}$ . Form the triangle with those vectors as sides.

By the law of cosines for a triangle:

${\displaystyle \|C\|^{2}=\|A\|^{2}+\|B\|^{2}-2\|A\|\ \|B\|\cos \theta \,}$

Since we have established that the algebraic definition works for calculating norms:

${\displaystyle C_{x}^{2}+C_{y}^{2}+C_{z}^{2}=A_{x}^{2}+A_{y}^{2}+A_{z}^{2}+B_{x}^{2}+B_{y}^{2}+B_{z}^{2}-2\|A\|\|B\|\cos \theta \,}$

Since ${\displaystyle {\vec {C}}={\vec {A}}-{\vec {B}}\,}$ :

${\displaystyle A_{x}^{2}+B_{x}^{2}-2A_{x}B_{x}+A_{y}^{2}+B_{y}^{2}-2A_{y}B_{y}+A_{z}^{2}+B_{z}^{2}-2A_{z}B_{z}=A_{x}^{2}+A_{y}^{2}+A_{z}^{2}+B_{x}^{2}+B_{y}^{2}+B_{z}^{2}-2\|A\|\|B\|\cos \theta \,}$

so

${\displaystyle -2A_{x}B_{x}-2A_{y}B_{y}-2A_{z}B_{z}=-2\|A\|\|B\|\cos \theta \,}$

so

${\displaystyle A_{x}B_{x}+A_{y}B_{y}+A_{z}B_{z}=\|A\|\|B\|\cos \theta \,}$