In this section we discuss the geometry of addition, scalar multiplication, and dot product of vectors. We also use MATLAB graphics to visualize these operations.

Geometry of Addition

MATLAB has an excellent graphics language that we shall use at various times to illustrate concepts in both two and three dimensions. In order to make the connections between ideas and graphics more transparent, we will sometimes use previously developed MATLAB programs. We begin with such an example — the illustration of the parallelogram law for vector addition.

Suppose that and are two planar vectors. Think of these vectors as line segments from the origin to the points and in . We use a program written by T.A. Bryan to visualize . In MATLAB type1 :

x = [1 2];
 
y = [-2 3];  
addvec(x,y)

The vector is displayed in blue, the vector in green, and the vector in red. Note that is just the diagonal of the parallelogram spanned by and . A black and white version of this figure is given in Figure ??.


PIC

Figure 1: Addition of two planar vectors.

The parallelogram law (the diagonal of the parallelogram spanned by and is ) is equally valid in three dimensions. Use MATLAB to verify this statement by typing:

x = [1 0 2];
 
y = [-1 4 1];  
addvec3(x,y)

The parallelogram spanned by and in is shown in cyan; the diagonal is shown in blue. See Figure ??. To test your geometric intuition, make several choices of vectors and . Note that one vertex of the parallelogram is always the origin.


PIC

Figure 2: Addition of two vectors in three dimensions.

Geometry of Scalar Multiplication

In all dimensions scalar multiplication just scales the length of the vector. To discuss this point we need to define the length of a vector. View an -vector as a line segment from the origin to the point . Using the Pythagorean theorem, it can be shown that the length or norm of this line segment is: MATLAB has the command norm for finding the length of a vector. Test this by entering the -vector

x = [1 4 2];

Then type
norm(x)

MATLAB responds with:
ans =
 
    4.5826

which is indeed approximately .

Now suppose and . A calculation shows that

See Exercise ??. Note also that if is positive, then the direction of is the same as that of ; while if is negative, then the direction of is opposite to the direction of . The lengths of the vectors and are each three times the length of — but these vectors point in opposite directions. Scalar multiplication by the scalar produces the vector, the vector whose entries are all zero.

Dot Product and Angles

The dot product of two -vectors and is an important operation on vectors. It is defined by:

Note that is just , the length of squared.

MATLAB also has a command for computing dot products of -vectors. Type

x = [1 4 2];
 
y = [2 3 -1];  
dot(x,y)

MATLAB responds with the dot product of and , namely,
ans =
 
    12

One of the most important facts concerning dot products is the one that states

Indeed, dot product also gives a way of numerically determining the angle between -vectors, as follows. It follows that if and only if . Thus (??) is valid.

Proof
Theorem ?? is just a restatement of the law of cosines. Recall that the law of cosines states that where are the lengths of the sides of a triangle and is the interior angle opposite the side of length . In vector notation we can form a triangle two of whose sides are given by and in . The third side is just as , as in Figure ??.
PIC

Figure 3: Triangle formed by vectors and with interior angle .

It follows from the law of cosines that We claim that Assuming that the claim is valid, it follows that which proves the theorem. Finally, compute

to verify the claim.

Theorem ?? gives a numerically efficient method for computing the angle between vectors and . In MATLAB this computation proceeds by typing

theta = acos(dot(x,y)/(norm(x)*norm(y)))

where acos is the inverse cosine of a number. For example, using the -vectors and entered previously, MATLAB responds with
theta =
 
    0.7956

Remember that this answer is in radians. To convert this answer to degrees, just multiply by and divide by :
                                                                  

                                                                  
360*theta / (2*pi)

to obtain the answer of .

Area of Parallelograms

Let be a parallelogram whose sides are the vectors and as in Figure ??. Let denote the area of . As an application of dot products and (??), we calculate . We claim that

We verify (??) as follows. Note that the area of is the same as the area of the rectangle also pictured in Figure ??. The side lengths of are: and where is the angle between and . A computation using (??) shows that
which establishes (??).
PIC

Figure 4: Parallelogram beside rectangle with same area.

Exercises

In Exercises ?? – ?? compute the lengths of the given vectors.

. The length of is .
. The length of is .
. The length of is .
. The length of is .

In Exercises ?? – ?? determine whether the given pair of vectors is perpendicular.

and .
The vectors are perpendicular. The vectors are not perpendicular.
Vectors and are perpendicular if and only if . In this case, .
and .
The vectors are perpendicular. The vectors are not perpendicular.
Compute: .
and .
The vectors are perpendicular. The vectors are not perpendicular.
Compute: .
and .
The vectors are perpendicular. The vectors are not perpendicular.
Compute: .
Find a real number so that the vectors are perpendicular.
The vectors and are perpendicular when .
This means that .
Find the lengths of the vectors and , and the angle in radians between them.
.
.
So .

In Exercises ?? – ?? compute the dot product for the given pair of vectors and the cosine of the angle in radians between them.

and .
and .
and .
and .
and .
and .

Using the definition of length, verify that formula (??) is valid.

Use addvec and addvec3 to add vectors in and . More precisely, enter pairs of -vectors x and y of your choosing into MATLAB, use addvec to compute x+y, and note the parallelogram formed by . Similarly, enter pairs of -vectors and use addvec3.
Determine the vector of length that points in the same direction as the vector
Determine the vector of length that points in the same direction as the vector

In Exercises ??– ?? find the angle in degrees between the given pair of vectors.

and .
and .
and .

In Exercises ?? – ?? let be the parallelogram generated by the given vectors and in . Compute the area of that parallelogram.

and .
and .