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 [Maple Math] and [Maple Math] it is defined as [Maple Math] . If we take taller vectors, then the calculation can obviously extended, provided the vectors have the same size. For instance the dot product of [Maple Math] is calculated as [Maple Math] = [Maple Math] = [Maple Math] .

It is clear that the length of the plane vector [Maple Math] i.e. the length of the segment from (0,0) to (a,b) is [Maple Math] and is easily seen to be the square root of the dot product of [Maple Math] with itself!
Thus, in any dimensions, we may define the length of a vector
[Maple Math] to be the square root of [Maple Math] . It is easy to observe that the length (also denoted as [Maple Math] ) is always nonnegative and is zero iff [Maple Math] the zero vector.

Note that, the notation [Maple Math] 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 [Maple Math] 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 [Maple Math] to be a unit vector (i.e. having length [Maple Math] ) if [Maple Math] is [Maple Math] . Clearly, for a nonzero [Maple Math] , each of the two vectors [Maple Math] and [Maple Math] are unit vectors both along the same line as [Maple Math] ; one is parallel to [Maple Math] and the other is antiparallel to it.

The dot product has a more significant use, namely it satisfies: [Maple Math] , where [Maple Math] is the angle between the two vectors [Maple Math] . 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 [Maple Math] to the [Maple Math] .

You should have a natural doubt here. The angle from [Maple Math] to [Maple Math] should be the negative of the angle from [Maple Math] to [Maple Math] . Which one is to be called [Maple Math] ? Since our dot product is symmetric in the two vectors, this should not matter! Indeed, the cosine function also has the property that [Maple Math] 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 [Maple Math] in the absolute. This is a verifiable fact, known as the Cauchy-Schwartz inequality. Specifically, the inequality says that:
[Maple Math] .

For plane vectors, this amounts to proving that [Maple Math] . Taking [Maple Math] as above, this becomes
[Maple Math]
Expanding and moving everything to the right, we are reduced to proving that
[Maple Math]
and this is easily verified since the RHS is a complete square of
[Maple Math] .

Indeed, the above proof even says that the inequality becomes and equality iff [Maple Math] , i.e. the two vectors are along the same line. In this case the angle comes out to be [Maple Math] or [Maple Math] , since [Maple Math] becomes [Maple Math] or [Maple Math] .

There are many interesting proofs which work without getting into such algebraic manipulations.

This gives a simple test for vectors [Maple Math] to be perpendicular, namely [Maple Math] . For them to be parallel (or antiparallel) we need [Maple Math] or equivalently [Maple Math] .

Some examples:

> v:=[3,4,1];w:=[2,-1,2];

[Maple Math]

[Maple Math]

> dotprod(v,w);

[Maple Math]

> simplify(angle(v,w));

[Maple Math]

> dotprod(v,w),norm(v,2),norm(w,2);

[Maple Math]

> arccos(dotprod(v,w)/(norm(v,2)*norm(w,2)));

[Maple Math]

> dotprod([3,4,1],[2,-1,k]);

[Maple Math]

Why do we have this bar over [Maple Math] in [Maple Math] ? 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 [Maple Math] 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 [Maple Math] , to avoid getting into complex numbers.

> dotprod([3,4,1],[2,-1,-2]);

[Maple Math]

>