The dot product (or inner product, or scalar product) is ubiquitous throughout different areas of math, most importantly but not limited to linear algebra. It's an operation that takes in two vectors and returns a single number. Functionally, the dot product is calculated in two different ways:
a⋅b=∑i=0nai⋅bi
a⋅b=∣a∣∣b∣cosθ
Personally, I've always wondered - what does the dot product actually mean? Is there a visual representation for what the purpose of a dot product is?
To answer this question, we can start with our second formula,
a⋅b=∣a∣∣b∣cosθ
Looking at the diagram, the geometric meaning of the dot product by our second formula seems to become apparent. We can imagine dropping a perpendicular from the end of a to b:
We get a right triangle defined by the perpendicular, a, and b. We also know that the cosine of our angle θ is equal to the ratio of the magnitude of the vector project of a onto b (let's call it c) to the magnitude of a.
cosθ=∣a∣∣c∣
Multiplying |a| and |b| onto both sides gives us
∣a∣∣b∣cosθ=∣c∣∣b∣
This is an interesting result; apparently, the dot product gives us the component of a along b multiplied with the length of b itself.
Note that we can replace c with the actual definition of a component (or the magnitude of the projection of one vector onto another).
compba=a⋅∣b∣b=∣c∣
Plugging this into our original expression,
∣a∣∣b∣cosθ=a⋅∣b∣b=a⋅b
It works out cleanly in the end;
nothing's blown up, which is always good.
However, I'm more interested in our first expression: how does the sum of the componentwise products of our vectors relate in any way to the product of the magnitudes of the vectors and the cosine of the angle between them? What is the relationship between these two expressions?
To start, recall the law of cosines:
∣c∣2=∣a∣2+∣b∣2−2∣a∣∣b∣cosθ
Notice how we can express c in terms of a and b: namely,
c=a−b
Thus, we know the following about the magnitude of c:
∣c∣=∣a−b∣=∑i=0n(ai−bi)2
Thus, we can use the law of cosines:
∣a−b∣2=∣a2∣+∣b∣2−2∣a∣∣b∣cosθ
We know that
a⋅b=∣a∣∣b∣cosθ
Therefore, the equation becomes
∣a−b∣2=∣a∣2+∣b∣2−2(a⋅b)
2(a⋅b)=∣a∣2+∣b∣2−∣a−b∣2
a⋅b=21(∑i=0nai2+∑i=0nbi2−∑i=0n(ai−bi)2)
We can see a pattern here. When
(ai−bi)2
is multiplied out, we see a result of something along the lines of
ai2−2aibi+bi2
This matches up with each extraneous term in our sum, which ends up canceling out: