Dot product: Component vs. Geometric definition - Eli Bendersky's website
Toggle navigation
Eli Bendersky's website
About
Projects
Archives
The goal of this post is to answer a simple question: why are the<br>following two definitions of the vector dot product in Euclidean<br>space [1] equivalent for vectors \vec{a} and \vec{b}:
Component definition:<br>\vec{a}\cdot\vec{b}=\sum_{i=1}^{n}a_i b_i
Geometric definition:<br>\vec{a}\cdot\vec{b}=|\vec{a}||\vec{b}|cos(\theta), where<br>|\vec{a}| is the magnitude of \vec{a} and<br>is the angle between the vectors’ directions
Here’s a graphical depiction of our vectors (focusing on<br>for clarity, though this applies to any-dimensional<br>vectors). It shows both the components of the vectors and the angle<br>between them. The length of the arrow for \vec{a} is<br>|\vec{a}|.
We’ll show two proofs of the equivalence here, the geometric proof and<br>the projection proof. The Appendix describes some properties of dot<br>products that facilitate these proofs.
Geometric proof
We’ll be using this diagram of our vectors \vec{a} and<br>\vec{b}, as well as the vector \vec{c}=\vec{a}-\vec{b}:
Using the law of cosines [2] on the triangle formed by the three<br>vectors:
\[|\vec{c}|^2=|\vec{a}|^2+|\vec{b}|^2-2|\vec{a}||\vec{b}|cos(\theta)\]<br>Since for any vector \vec{a}, we have<br>\vec{a}\cdot\vec{a}=|\vec{a}|^2 (see Appendix), let’s rewrite<br>this equation as:
\[\vec{c}\cdot\vec{c}=\vec{a}\cdot\vec{a}+\vec{b}\cdot\vec{b}-2|\vec{a}||\vec{b}|cos(\theta)\]<br>But \vec{c}=\vec{a}-\vec{b} and the dot product obeys the<br>distributive property (see Appendix). Therefore:
\[\begin{aligned}<br>(\vec{a}-\vec{b})\cdot(\vec{a}-\vec{b})&=\vec{a}\cdot\vec{a}+\vec{b}\cdot\vec{b}-2|\vec{a}||\vec{b}|cos(\theta)\\<br>\vec{a}\cdot\vec{a}-2\vec{a}\cdot\vec{b}+\vec{b}\cdot\vec{b}&=\vec{a}\cdot\vec{a}+\vec{b}\cdot\vec{b}-2|\vec{a}||\vec{b}|cos(\theta)\\<br>-2\vec{a}\cdot\vec{b}&=-2|\vec{a}||\vec{b}|cos(\theta)\\<br>\vec{a}\cdot\vec{b}&=|\vec{a}||\vec{b}|cos(\theta)<br>\end{aligned}\]
Projection proof
For this proof, we’ll assume the geometric definition is correct and<br>will see how it leads to the component definition. We’ll begin by<br>denoting vectors \vec{e}_1,\vec{e}_2\dots\vec{e}_n as the<br>standard orthonormal basis for . For example, in 2D<br>space, these basis vectors are \vec{e}_1=[1\ 0] and<br>\vec{e}_2=[0\ 1], shown in<br>this diagram:
If we take an arbitrary \vec{a}\in\mathbb{R}^n and calculate its<br>dot product with a basis vector, we can use the geometric definition:
\[\vec{a}\cdot\vec{e}_i=|\vec{a}||\vec{e}_i|cos(\theta_i)=|\vec{a}|cos(\theta_i)=a_i\]<br>where a_i is the component of \vec{a} in the direction<br>of \vec{e}_i. The diagram makes it easy to see why this is true<br>from basic trigonometry, but in the more general case this is just a<br>vector<br>projection.
Now let’s represent vectors \vec{a} and \vec{b} as<br>linear combinations of the basis vectors:
\[\begin{aligned}<br>\vec{a}&=\sum_{i=1}^{n}a_i\vec{e}_i\\<br>\vec{b}&=\sum_{i=1}^{n}b_i\vec{e}_i\\<br>\end{aligned}\]<br>And calculate the dot product \vec{a}\cdot\vec{b}, beginning by<br>rewriting \vec{b} with its linear combination of basis vectors<br>representation:
\[\vec{a}\cdot\vec{b}=\vec{a}\cdot\sum_{i=1}^{n}b_i\vec{e}_i\]<br>Using the fact that the dot product distributes over linear<br>combinations:
\[\vec{a}\cdot\vec{b}=\sum_{i=1}^{n}b_i(\vec{a}\cdot\vec{e}_i)\]<br>But earlier we’ve shown that \vec{a}\cdot\vec{e}_i=a_i.<br>Therefore:
\[\vec{a}\cdot\vec{b}=\sum_{i=1}^{n}b_i a_i=\sum_{i=1}^{n}a_i b_i\]<br>Which is the component definition \blacksquare.
Appendix A: Inner product space
A generalization of dot products in is the inner<br>product, which is an operation meeting some specific requirements,<br>defined on a vector space.
The inner product is denoted as<br>\langle x,y\rangle:\mathbb{R}^n\times\mathbb{R}^n\to\mathbb{R},<br>and must satisfy the following requirements for all vectors<br>x,y,z\in\mathbb{R}^n and scalars a,b\in\mathbb{R}:
Symmetry: \langle x,y\rangle=\langle y,x\rangle
Linearity in the first argument:<br>\langle ax+by,z\rangle=a\langle x,z\rangle+b\langle y,z\rangle
Positive-definiteness: if x\ne 0 then<br>\langle x,x\rangle>0
For , we define the inner product operation in its<br>component formulation as:
\[\langle x,y\rangle=\sum_{i=1}^{n}x_i\cdot y_i\]<br>Let’s prove the requirements listed above for this operation; this is<br>fairly straightforward, given the well-known properties of scalar<br>multiplication and addition on :
Symmetry:
\[\langle x,y\rangle=\sum_{i=1}^{n}x_i\cdot y_i=\sum_{i=1}^{n}y_i\cdot x_i=\langle y,x\rangle\]<br>Linearity in the first argument:
\[\begin{aligned}<br>\langle ax+by,z\rangle&=\sum_{i=1}^{n}(ax+by)_i\cdot z_i\\<br>&=\sum_{i=1}^{n}a x_i\cdot z_i+b y_i\cdot z_i\\<br>&=a\sum_{i=1}^{n}x_i\cdot z_i+b\sum_{i=1}^{n}y_i\cdot z_i=a\langle x,z\rangle+b\langle y,z\rangle<br>\end{aligned}\]<br>Positive-definiteness:
Consider the components of vector x. Clearly,<br>\forall i\quad x_i\cdot x_i=x_i^2\ge 0. Since the vector<br>x is not the zero vector, at least one of its components<br>is nonzero, and for that component x_i\cdot...