pretiosus.io

Dot Product

Topic

Tags

Vectors

Vector multiplication is an often-encountered operation that is useful and needs to be performed. There are different kinds of multiplication operations, on this page, we will only cover the dot product. The dot product is a type of inner product, where the inner product is a more general term and the dot product is the term for finite Euclidean spaces.

In a mathematical way, the dot product can be described by the following expression

ab\begin{equation} \vec{a} \cdot \vec{b} \end{equation}

The further meaning of this expression can be described by the sum of all values of the vectors a\vec{a} and b\vec{b}, starting at the first element of the vector and ending at the last element. In this case, we assume that the vectors are of length n, as can be seen at the top of the summation sign.

ab=i=1naibi=a1b1+a2b2++anbn\begin{equation} \vec{a} \cdot \vec{b} = \sum^n_{i=1}a_ib_i = a_1b_1 + a_2b_2 + \cdots + a_nb_n \end{equation}

Let's work the expression from above out by using a simple example where the two vectors are defined as

a=[32]b=[15]\begin{aligned} \vec{a} &= \left[\begin{matrix}3 & 2\end{matrix}\right]\\ \vec{b} &= \left[\begin{matrix}1 & 5\end{matrix}\right] \end{aligned}

By only using the coefficients in front of the unit terms ex\vec{e}_x and ey\vec{e}_y. The dot product of these two vectors can then be computed and results in the following summation

ab=i=12aibi=31+25ab=13\begin{equation} \begin{aligned} \vec{a} \cdot \vec{b} &= \sum^2_{i=1}a_ib_i = 3*1 + 2*5\\ \vec{a} \cdot \vec{b} &= 13 \end{aligned} \end{equation}

Geometric visualization

Now the mathematical representation of the dot product is given, it is time to give a clear visualization of what the dot product actually means in a geometrical way. In general, the dot product is encountered in different situations where the interpretation of it can differ. However, in this section, we will show what it looks like geometrically speaking.

Let's consider the vectors a\vec{a} and b\vec{b} in figure 1. The dot product for geometric purposes is written differently. Now it takes the form of the following expression

ab=abcosθ\begin{equation} \vec{a} \cdot \vec{b} = \|a\| \|b\| \cos{\theta} \end{equation}

In this expression is θ\theta the angle between the two vectors and a\|a\| the norm of the vector a, which equals a=a1+a2++an\|a\| = \sqrt{a_1 + a_2 + \cdots + a_n} and is a scalar value.

Visualization of dot product with two vectors a and b

Figure 1. Vectors a\vec{a} and b\vec{b} with an unknown angle θ\theta

By rewriting the expression in equation 4 into a function of only the vectors a\vec{a} and b\vec{b}, the angle θ\theta can then be computed. This expression is shown below

cosθ=abab\begin{equation} \cos{\theta} = \frac{\vec{a} \cdot \vec{b}}{\|a\| \|b\| } \end{equation}

Example

Let's now compute the angle between the two vectors in figure 1. In this figure the vector a\vec{a} and b\vec{b} are

a=[35],b=[92]\vec{a} = \left[\begin{array} {cc} 3 & 5 \end{array}\right], \vec{b} = \left[\begin{array} {cc} 9 & 2 \end{array}\right]

substituting this into equation 5 we can compute the angle θ\theta. This results into;

cosθ=39+5232+5292+22cosθ=373485\begin{equation} \begin{aligned} \cos{\theta} &= \frac{3\cdot9 + 5\cdot2}{\sqrt{3^2 + 5^2} \cdot \sqrt{9^2 + 2^2}}\\ \cos{\theta} &= \frac{37}{\sqrt{34} \cdot \sqrt{85}} \end{aligned} \end{equation}

Now by taking the cos1cos^{-1} of the fraction from above, the final angle θ\theta can be computed in this case, it is computed in degrees.

θ=46.5043°\begin{equation} \theta = 46.5043^{\degree} \end{equation}

More about Vectors