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];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 ??.
y = [-2 3];
addvec(x,y)
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];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.
y = [-1 4 1];
addvec3(x,y)
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 =which is indeed approximately .
4.5826
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];MATLAB responds with the dot product of and , namely,
y = [2 3 -1];
dot(x,y)
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 ??.
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
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 =Remember that this answer is in radians. To convert this answer to degrees, just multiply by and divide by :
0.7956
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 thatExercises
In Exercises ?? – ?? compute the lengths of the given vectors.
In Exercises ?? – ?? determine whether the given pair of vectors is perpendicular.
In Exercises ?? – ?? compute the dot product for the given pair of vectors and the cosine of the angle in radians between them.
In Exercises ??– ?? find the angle in degrees between the given pair of vectors.
In Exercises ?? – ?? let be the parallelogram generated by the given vectors and in . Compute the area of that parallelogram.