Dot product of two vectors vs. the (cosine of the) angle between them
Suppose given two vectors v and w, neither of them the zero vector.
In fact, suppose each of v and w has length 1 . (At the very very
end, we'll see what happens when this restriction is lifted.)
To come to grips with the significance of the dot product of v with w
let's try to find out for which number(s) k (non-zero, if possible)
the vector (from the origin to) w is the hypotenuse of a right triangle
whose other two legs are the vector (from the origin to) kv and the
vector from kv to w. (Draw two pictures, one with angle between
v and w acute, and k > 0 , and one with angle in question obtuse,
and k < 0 .)
In particular, k should be so chosen that the last two legs mentioned
really are perpendicular to each other. But then the Pythagorean Theorem
would let us expect that the sum of the squares of their two lengths is
just equal to the square of the length of the hypotenuse, i.e.,
|| kv || 2 + || w - kv || 2 = || w || 2 .
Remembering that we're supposing || v || = 1 and || w || = 1 , this
equation simplifies (why?) to
k 2 + || w - kv || 2 = 1 .
Now, to come to grips with the expression || w - kv || 2 , let's say
v = (v 1, v 2, ..., v i, ..., v n) and w = (w 1, w 2, ..., w i, ..., w n) .
Then, remembering that || v || = 1 and || w || = 1 ,
|| w - kv || 2 = ∑ i=1,...,n (w i - kv i) 2 =
= ∑ i=1,...,n ( (w i) 2 - 2kv iw i + (kv i) 2 ) =
= ∑ i=1,...,n (w i) 2
- ∑ i=1,...,n 2k(v i)(w i)
+ ∑ i=1,...,n k 2 (v i) 2 =
= || w || 2 - 2k( v • w ) + k 2 || v || 2 =
= 1 - 2k( v • w ) + k 2 ;
so the simplified equation
simplifies further to
k 2 + 1 - 2k( v • w ) + k 2 = 1 ,
or, rebalancing by leaving only the "k 2" terms on the LHS,
2 k 2 = 2k( v • w ) ,
or, if you prefer,
2k(k - ( v • w ) ) = 0 .
Clearly, the only solutions k to this equation have form k = 0 (which,
as we said at the outset, we'd prefer to avoid, if possible), and
k = v • w
(which, when v • w = 0 , will be the only solution).
Thus the number k we are seeking has the uniform expression k = v • w ,
and this is the significance of the dot product of the (unit) vectors v and w.
Trigonometrically, of course, when the angle between v and w is acute, the length k of kv is the cosine (why?) of that angle, while when that angle is
obtuse, it's the negative -|k| (= k ) of the length |k| of kv that is that cosine, whence, at least for unit vectors v and w,
cos ( ∠ between v and w ) = k = v • w .
Finally, let's drop the requirements that v and w be unit vectors. But
let's continue to assume they're each non-zero, so that they both have non-zero lengths.
Well, then (1/||v||) v and (1/||w||) w are unit vectors. (Why?) And the
angle between the vectors from the origin to v and from the origin
to w is certainly the same as the angle between those two unit vectors
(1/||v||) v and (1/||w||) w. So:
cos ( ∠ between v and w ) =
= cos ( ∠ between (1/||v||) v and (1/||w||) w ) =
= ((1/||v||) v ) • ((1/||w||) w ) =
= (1/||v||)(1/||w||)( v • w ) =
v • w
= ——— .
(When at least one of v and w — v, say — is the zero vector,
the above procedure can't be carried out. On the other hand, it's hard
to come up with a number you'd really like to think of as measuring any
"angle" between the zero vector and the vector from the origin to w.
But the dot product of zero with w still makes sense, as zero. And
the "cross-multiplied" form of the above equation,
||v|| ||w|| cos ( ∠ between v and w ) = v • w,
remains valid (after all, it becomes 0 = 0 ) no matter what number you
might chose to play the role of cos ( ∠ between v and w ) .)
Prepared 18 Feb 2004.
Questions, broken code, and other errata, please, to me,