Artificial Intelligence 🤖
Vectors
Dot/scalar product

Dot/scalar product

We continue with a definition of the dot product, sometimes also referred to as the scalar product.

Given two vectors a=(a1,a2,a3)\boldsymbol{a}=\left(a_{1}, a_{2}, a_{3}\right) and b=(b1,b2,b3)\boldsymbol{b}=\left(b_{1}, b_{2}, b_{3}\right), expressed in terms of the standard basis vectors {i,j,k}\{\mathbf{i}, \mathbf{j}, \mathbf{k}\}, the dot product is defined as,

ab=a1b1+a2b2+a3b3.\boldsymbol{a} \cdot \boldsymbol{b}=a_{1} b_{1}+a_{2} b_{2}+a_{3} b_{3} .

We note the following properties:

  • u(v+w)=uv+uwu \cdot(v+w)=u \cdot v+u \cdot w
  • uv=vuu \cdot v=v \cdot u
  • v0=0\boldsymbol{v} \cdot \mathbf{0}=0
  • (cu)v=v(cu)=c(uv)(c \boldsymbol{u}) \cdot \boldsymbol{v}=\boldsymbol{v} \cdot(c \boldsymbol{u})=c(\boldsymbol{u} \cdot \boldsymbol{v})
  • uu=u2\boldsymbol{u} \cdot \boldsymbol{u}=|\boldsymbol{u}|^{2}
  • If uu=0\boldsymbol{u} \cdot \boldsymbol{u}=0, then u=0\boldsymbol{u}=\mathbf{0}

We move to a geometric interpretation of the dot product. Figure 9.4 depicts two vectors, a\boldsymbol{a} and b\boldsymbol{b}, as well as the vector ab\boldsymbol{a}-\boldsymbol{b}. The angle between a\boldsymbol{a} and b\boldsymbol{b} is given by θ\theta.

Figure 9.4: Geometric interpretation of the dot product.

We have the following theorem: given a\boldsymbol{a} and b\boldsymbol{b}, the dot product is defined by

ab=abcosθ.\boldsymbol{a} \cdot \boldsymbol{b}=|\boldsymbol{a}||\boldsymbol{b}| \cos \theta .

Starting from the Law of Cosines, we have

ab2=a2+b22abcosθ|\boldsymbol{a}-\boldsymbol{b}|^{2}=|\boldsymbol{a}|^{2}+|\boldsymbol{b}|^{2}-2|\boldsymbol{a}||\boldsymbol{b}| \cos \theta

Expanding the LHS of Eq. (9.17) and using the properties listed above, gives

ab2=(ab)(ab),=aaabba+bb,=a22ab+b2.\begin{aligned} |\boldsymbol{a}-\boldsymbol{b}|^{2} & =(\boldsymbol{a}-\boldsymbol{b}) \cdot(\boldsymbol{a}-\boldsymbol{b}), \\ & =\boldsymbol{a} \cdot \boldsymbol{a}-\boldsymbol{a} \cdot \boldsymbol{b}-\boldsymbol{b} \cdot \boldsymbol{a}+\boldsymbol{b} \cdot \boldsymbol{b}, \\ & =|\boldsymbol{a}|^{2}-2 \boldsymbol{a} \cdot \boldsymbol{b}+|\boldsymbol{b}|^{2} . \end{aligned}

Plugging back to Eq. (9.17)

a22ab+b2=a2+b22abcosθ,|\boldsymbol{a}|^{2}-2 \boldsymbol{a} \cdot \boldsymbol{b}+|\boldsymbol{b}|^{2}=|\boldsymbol{a}|^{2}+|\boldsymbol{b}|^{2}-2|\boldsymbol{a}||\boldsymbol{b}| \cos \theta,

which yields Eq. (9.16)

If the angle θ=π/2\theta=\pi / 2, i.e. a\boldsymbol{a} and b\boldsymbol{b} are perpendicular, then the dot product is zero. In an orthonormal basis such as {i,j,k}\{\mathbf{i}, \mathbf{j}, \mathbf{k}\}, we have the following identities:

ii=1jj=1kk=1ij=0ik=0jk=0\begin{array}{lll} \mathbf{i} \cdot \mathbf{i}=1 & \mathbf{j} \cdot \mathbf{j}=1 & \mathbf{k} \cdot \mathbf{k}=1 \\ \mathbf{i} \cdot \mathbf{j}=0 & \mathbf{i} \cdot \mathbf{k}=0 & \mathbf{j} \cdot \mathbf{k}=0 \end{array}

Consider again the two vectors a=(a1,a2,a3)\boldsymbol{a}=\left(a_{1}, a_{2}, a_{3}\right) and b=(b1,b2,b3)\boldsymbol{b}=\left(b_{1}, b_{2}, b_{3}\right). If we are asked to find the angle θ\theta between the vectors we use the dot product as follows,

cosθ=abab=a1b1+a2b2+a3b3a12+a22+a32b12+b22+b32\begin{aligned} \cos \theta & =\frac{\boldsymbol{a} \cdot \boldsymbol{b}}{|\boldsymbol{a} \| \boldsymbol{b}|} \\ & =\frac{a_{1} b_{1}+a_{2} b_{2}+a_{3} b_{3}}{\sqrt{a_{1}^{2}+a_{2}^{2}+a_{3}^{2}} \sqrt{b_{1}^{2}+b_{2}^{2}+b_{3}^{2}}} \end{aligned}

Moreover, using Eq. (9.18), we can find the length of the missing edge in a triangle. Given a\boldsymbol{a} and b\boldsymbol{b}, the length of the missing edge is given by ab|\boldsymbol{a}-\boldsymbol{b}| (see Fig. 9.4).

Remarks

  1. The triangle inequalities

Substituting 1cosθ1-1 \leq \cos \theta \leq 1 in Eq. (9.17) yields

(ab)2ab2(a+b)2(a-b)^{2} \leq|\boldsymbol{a}-\boldsymbol{b}|^{2} \leq(a+b)^{2}

since Eq. (9.17) takes its minimum value at a2+b22ab=(ab)2a^{2}+b^{2}-2 a b=(a-b)^{2} and its maximum at a2+b2+2ab=(a+b)2a^{2}+b^{2}+2 a b=(a+b)^{2}. From Eq. (9.20), taking the positive square root of each term gives the triangle inequalities,

ababa+b.|| a|-| b|| \leq|\boldsymbol{a}-\boldsymbol{b}| \leq|a|+|b| .
  1. Suppose we have the identity
ab=ac,a \cdot b=a \cdot c,

for a0\boldsymbol{a} \neq \mathbf{0}. Note that this does not necessarily mean that b=c\boldsymbol{b}=\boldsymbol{c}. Rather,

abac=0\boldsymbol{a} \cdot \boldsymbol{b}-\boldsymbol{a} \cdot \boldsymbol{c}=0

which leads to,

a(bc)=0.\boldsymbol{a} \cdot(\boldsymbol{b}-\boldsymbol{c})=0 .

It follows that the above is true if, either b=c\boldsymbol{b}=\boldsymbol{c} or if a\boldsymbol{a} is perpendicular to bc\boldsymbol{b}-\boldsymbol{c}.

Exercise - What is the angle between:

  1. a=(1,2,3)\boldsymbol{a}=(1,2,3) and b=(2,2,4)\boldsymbol{b}=(-2,2,4) ?
  2. a=(1,3,1)\boldsymbol{a}=(1,3,-1) and b=(1,1,5)\boldsymbol{b}=(-1,-1,-5) ?
  3. a=(1,0,2)\boldsymbol{a}=(1,0,2) and b=(1,2,3)\boldsymbol{b}=(-1,2,3) ?