Dot products
In general, we said that vectors can only be added or multiplied by scalars. We never multiplied two vectors together. In general, they cannot be. However, there is a special product called the dot product which produces a single scalar from two vectors and has many uses. For two plane vectors
and
it is defined as
. If we take taller vectors, then the calculation can obviously extended, provided the vectors have the same size. For instance the dot product of
is calculated as
=
=
.
It is clear that the length of the plane vector
i.e. the length of the segment from (0,0) to (a,b) is
and is easily seen to be the square root of the dot product of
with itself!
Thus, in any dimensions, we may define the length of a vector
to be the square root of
. It is easy to observe that the length (also denoted as
) is always nonnegative and is zero iff
the zero vector.
Note that, the notation
really has the dot centered and not near the baseline as Maple is putting it. Some people like to make the notation clearer by using an expression
and this is called an inner product, rather than the informal dot product. We may discuss these in general vector spaces later.
We define a vector
to be a unit vector (i.e. having length
) if
is
. Clearly, for a nonzero
, each of the two vectors
and
are unit vectors both along the same line as
; one is parallel to
and the other is antiparallel to it.
The dot product has a more significant use, namely it satisfies:
, where
is the angle between the two vectors
. In the plane or three space, this can be checked with some work. However, the main point is that in higher dimensional or more abstract vector spaces, this shall give the concept of an angle where none is present beforehand. Thus we define the angle beteen two vectors
to the
.
You should have a natural doubt here. The angle from
to
should be the negative of the angle from
to
. Which one is to be called
? Since our dot product is symmetric in the two vectors, this should not matter! Indeed, the cosine function also has the property that
and so we don't have a problem!
For this definition to be meaningful, we need that the argument of the arccos function is less than
in the absolute. This is a verifiable fact, known as the Cauchy-Schwartz inequality. Specifically, the inequality says that:
.
For plane vectors, this amounts to proving that
. Taking
as above, this becomes
Expanding and moving everything to the right, we are reduced to proving that
and this is easily verified since the RHS is a complete square of
.
Indeed, the above proof even says that the inequality becomes and equality iff
, i.e. the two vectors are along the same line. In this case the angle comes out to be
or
, since
becomes
or
.
There are many interesting proofs which work without getting into such algebraic manipulations.
This gives a simple test for vectors
to be perpendicular, namely
. For them to be parallel (or antiparallel) we need
or equivalently
.
Some examples:
> v:=[3,4,1];w:=[2,-1,2];
> dotprod(v,w);
> simplify(angle(v,w));
> dotprod(v,w),norm(v,2),norm(w,2);
> arccos(dotprod(v,w)/(norm(v,2)*norm(w,2)));
> dotprod([3,4,1],[2,-1,k]);
Why do we have this bar over
in
? That is the case of Maple being extra careful. If we accept complex numbers into our number field, then our dot product has to be updated, otherwise it has unpleasant properties (like the length of a nonzero vector can become zero!). So, maple is allowing for the possibility that
may be complex and calculating accordingly. We will be assuming real numbers only and hence need not worry about it. However, while using Maple, you might wish to use the command
norm(v,2)
rather than
, to avoid getting into complex numbers.
> dotprod([3,4,1],[2,-1,-2]);
>