Vectors 2 The METRIC Project, Imperial College. 

advertisement
Vectors 2
The METRIC Project, Imperial College.
 Imperial College of Science Technology and Medicine, 1996.
Instructions for Getting Started
Launch Mathematica.
Type
<<Mathetic`vecpack`
hold down the “shift” key, and press the “return” key. Wait for Mathematica’s response. (Note:
be sure to use the ` symbol rather than the '. You may need to hunt for it on your keyboard: on
most, it’s in the top left corner.)
This essential first step sets up Mathematica for this module. If you omit this bit, the “special
commands” (see below) will not work.
Mathematica Commands
The following Mathematica commands may be useful to you in this module.
Commands that come with Mathematica:
Dot, Clear, ArcCos, ViewPoint (3D graphics option), Simplify
Special commands for this module:
MDDot, GiveQuestion, LastAnswer, AngleBetween, VectorSum3D,
Magnitude, Cross, CrossPlot
For information on, say, the VectorSum3D command, type
?VectorSum3D
hold down “shift”, and press “return”. And, if you wanted a list of all the commands containing
the word “Vector” you could type
?*Vector*
Experiment 1: The scalar product
Preparatory reading
In Vectors 1 (Experiment 3) we looked at what happens when we multiply a vector by a scalar. Now
we want to ask: what does it mean to “multiply” a vector by a vector?
What this means is by no means obvious. We can motivate things with an important physical law.
Newton’s Principle of Work can be stated as:
“The work done by a force F in moving through a displacement r at an angle of θ degrees to its line
of action is F r cosθ .”
This will be our definition for the scalar product. Given two vectors a and b with an angle θ
between them, their scalar product is:
a ⋅b = a b cos θ
The product is denoted by a dot, we say “a dot b”, and so it is often also called the dot product. It’s
called a product because it behaves in some ways like the product operation in arithmetic. And it’s
called the “scalar product” rather than just the product of vectors because there’s another kind of
product, the “vector product”, which will appear with three-dimensional vectors in a later experiment.
We’ve defined the special command MDDot to calculate dot products. The vectors are input to
the command in magnitude–direction form using the curly bracket notation that we used in the
Vectors 1 module:
MDDot[{1,0}, {2,45}]
The answer in this case is a simple form involving a square root. In other cases, you’ll need to
get things into decimals; you can apply the N command thus:
MDDot[{2.3,47}, {5,119}] //N
The command:
??MDDot
reveals how it actually works. What do you think the Abs command does?
1)
Try out the MDDot command on some vectors of your choice. In particular, try it out on some
equal vectors, parallel vectors, negative vectors and perpendicular vectors (e.g. i and j).
2)
For a general vector a, use the definition to find a·a. What are the following: i·i, j·j, i·j, j·i? Note
down these results for use in the next experiment.
3)
If a·b = 0 but neither a nor b is equal to 0 (the zero vector) what must be the angle between a and
b?
4)
Try to answer the following questions about the properties of the scalar product:
(i) is the scalar product commutative: that is, is it true that a·b = b·a for all vectors a and b?
(ii) is the scalar product distributive: that is, is it true that a·(b + c) = a·b + b·c for all vectors a, b
and c?
(iii) [careful!] is the scalar product associative: that is, is it true that (a·b)·c = a·(b·c) for all
vectors a, b and c?
This section uses this module’s special functions. If they fail to work try going back to the
Instructions for Getting Started at the beginning,
Post-experiment reading
If a·b = 0 and neither a nor b is zero then the angle between a and b must be 90 degrees.
The properties of the scalar product:
(i) the scalar product is a number,
2
(ii) a ⋅a = a ,
(iii) a·b = b·a (commutativity),
(iv) a·(b + c) = a·b + b·c (distributivity).
What about associativity? That is meaningless for the scalar product, since a.b is a scalar and so
(a·b)·c cannot be performed.
Practice Questions
This module includes a feature which allows you to get Mathematica to generate practice
questions and their answers. There is a set of questions for practising the calculation of dot
products. To generate a question, type:
GiveQuestion["dot product"]
not forgetting to “shift-return”. To generate the answer for checking, type:
LastAnswer["dot product"]
You can do this as often as you want: the questions are randomly generated, and repetitions
should be rare. Note: You don’t need to retype these commands for another question; simply
click the mouse on the previously-typed command and “shift-return”.
This section uses this module’s special functions. If they fail to work try going back to the
Instructions for Getting Started at the beginning.
Experiment 2: The scalar product by components, and
angles between vectors
Preparatory reading
It is often important to find the angles between two vectors. In two dimensions, it’s not hard to
convert the vectors into magnitude–direction form and then subtract the angles, but in three
dimensions, which we move to in the next experiment, there is no single angle for direction and the
problem is harder. In both cases we can do the whole thing easily in component form by making use
of the scalar product.
Mathematica has a built-in command for doing scalar products of vectors in component form, for
example:
{1, 3}.{4, -1}
Using the “dot” (full stop) character like this is a shorthand for the full command:
Dot[{1, 3}, {4, -1}]
If you like to work with the i, j Cartesian notation you can define the two unit vectors like this:
i={1, 0}; j={0, 1};
Then you can write vectors as i + 3j, 4i - j and so forth.
1)
Considering that the scalar product is defined in terms of magnitudes and angles, you may not
expect it to work very elegantly in component form. Let’s take a look at that now. Try out
various scalar products using the Dot command and look for a pattern. In particular try things
like:
{3, 4}.{1, 0}
{0, 1}.{5, 1}
You can obtain the general formula by doing the following (the Clear command removes any
values previously assigned to the symbols):
Clear[a, b, c, d]
{a, b}.{c, d}
2)
It’s not difficult to prove the formula. Remembering that the scalar product is distributive,
“expand” out the brackets in
(a i + b j)·(c i + d j) .
Now simplify this using the results you obtained above for i·i, i·j etc. This proof is given in the
Post-experiment Reading.
3)
Can you rearrange the scalar product formula from Experiment 1 into a formula for the angle
between two vectors? Try out your new formula on vectors where you know what the angle is
(something simple like 0° or 90°). You can use Mathematica to help: the relevant commands are
Dot, Magnitude and ArcCos. You may also need to use N to get answers into decimal form.
We’ve defined a special command called AngleBetween to do this calculation. For example:
AngleBetween[{1,3}, {3,-1}]
4)
Considering the “angle between” formula, can you see a quick way for spotting that two vectors
are perpendicular (that is, the angle between them is 90 degrees)?
Post-experiment reading
Given any two vectors whose components are a = a 1 i + a 2 j, b = b 1 i+ b 2 j, then
a ⋅b = (a1i + a2 j) ⋅ (b1 i + b2 j)
= a1 b1i ⋅i + a1b2 i⋅ j + a2 b1 j ⋅ i + a 2 b2 j⋅ j
= a1 b1 (1)+ a1 b2 (0) + a2 b1 (0) + a 2 b2 (1)
= a1 b1 + a2 b2 .
In words, then, the rule for doing scalar products in component form is: multiply together the
corresponding components, and add up the answers.
The formula for the angle between two vectors is a simple rearrangement of the scalar product
formula:
a ⋅b = abcos θ
cos θ =
a ⋅b
ab
 a ⋅b 
θ = arccos

 ab 
It is often very important to know whether two (non-zero) vectors are perpendicular or not (whether
the angle between them is 90 degrees). To do this, we only need to check if a·b = 0—we need not go
to the trouble of finding out the vector magnitudes as well.
Practice Questions
There is a set of questions on the calculation of angles between vectors (expressed in component
form). To get a question type:
GiveQuestion["angle between"]
and to generate the answer type:
LastAnswer["angle between"]
You can do this as often as you want: the questions are randomly generated, and repetitions
should be rare. Note: You don’t need to retype these commands for another question; simply
click the mouse on the command and “shift-return”.
Experiment 3: Vectors in three dimensions—i, j and k
Preparatory reading
You should be familiar with the fact that any point in three-dimensional space can be represented by
three coordinates, (x, y, z). In a similar way, vectors in three dimensional space can be represented by
three perpendicular components in the directions of the x, y and z axes. We can write down a 3-D
vector in column form, for example:
 2
 
 3
 
 4
The Cartesian basis (see Vectors 1, Experiment 6) can be extended from two into three dimensions by
introducng a third basis vector, k, which is one unit long in the z direction, in addition to i and j. This
diagram shows the vector 2i + 3j + 4k:
We won’t here be using any magnitude–direction form for 3-D vectors, although it is possible to do
so: the complication is that two angles are required to specify the direction of a vector, which makes
the trigonometry pretty hard.
Adding vectors in three dimensions works in just the same way as in two: simply add the components.
For example:
(2i + 3j + 4k) + (3i – 5j + k) = 5i – 2j + 5k .
The same geometrical constructs for vector addition, the Triangle Rule and Parallelogram Rule, can
be applied in three dimensions as in two. Since we will always be working in component form for 3D vectors we won’t (fortunately) need to use the Rules for calculating vector additions, but it’s still
important to be aware geometrically of what’s happening in the addition process.
The command VectorSum3D is the 3-D equivalent of the command VectorSum. It only
works with vectors in component form, for reasons discussed in the Preparatory Reading.
Example:
VectorSum3D[{{2,0,0}, {0,3,0}, {0,0,4}},
ResultQ->True]
It is convenient to define the i, j and k unit vectors in Mathematica:
i={1,0,0}; j={0,1,0}; k={0,0,1};
Then you can use these to write vectors in the form 2i + 3j + 4k, for example. We will
assume that these definitions are in effect from now on.
You can look at how the Triangle and Parallelogram Rules work in 3-D by specifying the
following options:
VectorSum3D[{2i + 3j + 4k, 3i - 5j + k},
ResultQ->True]
VectorSum3D[{2i + 3j + 4k, 3i - 5j + k},
AddRule->Parallelogram]
1)
The following command draws a cube (with labels and box removed for clarity):
VectorSum3D[{i,j,-i,-j,k,i,j,-i,-j,i,-k,j,k,-i,-k},
LabelQ->False, Boxed->False]
Use VectorSum3D to draw: a cube whose diagonals are connected; a pyramid; a tetrahedron.
Try drawing some other shapes that take your fancy.
2)
We often need to view 3-D pictures from different viewpoints. To do this, Mathematica provides
an option called ViewPoint, which can be used with all the 3-D plotting commands we’ll be
using in this module. Here’s an example:
VectorSum3D[{i, j, -i-j}, ViewPoint->{0,0,2}]
Make a sketch of the output. Try to work out what ViewPoint is doing by substituting
different values into the command above, making a sketch for each. Try these
other“viewpoints”: {0,0,-2}, {2,0,0}, {2,0,0.5}, {-2,0,0.5}, {0,2,0.5}. Try
some more “viewpoints”, and other 3D plots, of your own.
Here’s how it works: ViewPoint defines the point in space from which the 3-D object is to be
viewed, using a coordinate system in which {0, 0, 0} is the centre of the viewing box (hence these
are not the actual coordinates of the image). Some useful values:
{-2,0,0}
{4,0,0}
{0,-2,0}
{0,0,2}
{1.3,-2.4,2}
from the side, looking in the positive x direction
in the negative x direction, and further away
in the positive y direction
from above (i.e. in the negative z direction)
the default (standard) viewpoint
3)
Use VectorSum3D to investigate: (i) can you find two non-zero vectors in 3-D which add up to
give 0? (ii) Can you find three non-zero vectors in 3-D which add up to give 0?
4)
Given any two vectors a and b, investigate the set of vectors made by adding scalar multiples of
a and b (3a + 7b for example). Do these vectors all lie on the same surface in space? If so, what
is that surface? Begin your investigation with the special cases in which a and b are two of the
Cartesian basis vectors i, j or k.
5)
Can you work out the magnitude of the vector 2i + 3j + 4k? (Hint: you need to construct two
right-angled triangles and use Pythagoras’ theorem in each.) The answer is given in the Postexperiment Reading. Check your answer with:
Magnitude[2i + 3j + 4k]
Can you devise a general formula for the magnitude of any vector x i + y j + z k? You can get the
answer by doing:
Clear[x, y, z];
Magnitude[x i + y j + z k]
Post-experiment reading
This diagram shows the geometrical construction required to determine v, the magnitude of the vector
2i + 3j + 4k:
In the lower right-angled triangle, with sides of length 2, 3 and w, Pythagoras’ theorem tells us:
w2 = 22 + 32
and then in the upper right-angled triangle, with sides of length w, 4 and v, again by Pythagoras’
theorem:
v2 = w2 + 42 = 22 + 32 + 4 2 = 29.
Hence the magnitude is v = 29 .
The magnitude of any vector having components xi + yj + zk is x 2 + y 2 + z 2 . (You could verify
this simply by replacing the numbers 2, 3 and 4 in the above diagram with x, y and z.)
Experiment 4: The scalar product and angles between
vectors in three dimensions
Preparatory reading
In this experiment we look at the scalar product in three dimensions. The definition for the scalar
product of two three-dimensional vectors a and b is, as it was in two dimensions:
a ⋅b = a b cos θ
where θ is the angle between the vectors. One way to think about this is that a and b lie in a (unique)
plane in 3-D space, and within that plane we are once again in a 2-D space. The formula for the angle
between two three-dimensional vectors is, as before, a simple rearrangement of the scalar product
formula:
 a ⋅b 
θ = cos −1

 ab 
where a and b denote the magnitudes of a and b.
This formula gives us a quick test for perpendicularity of vectors: if the dot product of two (non-zero)
vectors is zero, those vectors are perpendicular, otherwise they cannot be.
Mathematica’s Dot command will calculate the scalar product of 3-D vectors in the same way
as it did for 2-D vectors:
{1,3,2}.{4,-1,0}
You should define i, j and k in Mathematica (see the last experiment) so that the above product
may be written:
(i + 3j + 2k).(4i - j)
1)
Using the Dot command, try to identify the general formula for dot products in 3-D, bearing in
mind the 2-D formula. Consider inputs like:
i.(j + k)
(3i).(4i + j + k)
Try out some inputs of your own along these lines. The following command will reveal the
general formula (you will need to Clear the variables x1, etc. if you have used any of them
already):
(x1 i + y1 j+ z1 k).(x2 i+ y2 j+ z2 k)
You may like to prove the formula by expanding out the brackets in the expression
( x1i + y1 j + z1 k ) ⋅ ( x2 i + y2 j + z 2 k )
and simplifying according to the values of i·i, i·j, i·k etc.
2)
Given any two (non-zero) vectors a and b, draw a diagram to illustrate how the angles between
the vectors a, b, –a and –b are related. Confirm your findings using the AngleBetween
command, which may be used to determine the angle between two 3-D vectors—for example:
AngleBetween[i, i+k]
AngleBetween[-i, i+k]
3)
The following command constructs the figure of a tetrahedron by specifying its edges as vectors:
VectorSum3D[{i+Sqrt[3]*j, i-Sqrt[3]*j, -2i,
i+j/Sqrt[3]+2k*Sqrt[2/3],
2j/Sqrt[3]-2k*Sqrt[2/3], i-Sqrt[3]*j,
-i+j/Sqrt[3]+2k*Sqrt[2/3]},
Boxed->False, LabelQ->False]
Confirm that this is indeed a tetrahedron by checking, using Magnitude, that the lengths of all
the edges are equal, and, using AngleBetween, that the angles between intersecting edges are
all 60°. (Using the copy-and-paste feature of the Mathematica notebook will save you a lot of
repeated typing here.)
Post-experiment reading
The general rule for calculating the scalar product of 3-D vectors in component form is the same as it
was for 2-D vectors: multiply together the corresponding components, and add up the answers.
The following diagram shows how the angles between the vectors a, –a, b and –b are related:
One can read off that, for example,
(angle between a and –b) = 180 – (angle between a and b).
Practice Questions
There are three sets of questions which revise topics from two dimensions for the case of threedimensional vectors. To generate a question from the first set, type
GiveQuestion["addition 3D"]
And to generate the answer for checking, type
LastAnswer["addition 3D"]
The other sets of questions are accessed using
GiveQuestion["dot product 3D"]
GiveQuestion["angle between 3D"]
Experiment 5: The vector product
Preparatory reading
In this experiment we return again to the question of the possible meaning of multiplying a vector
with a vector. This time we’ll define a product whose outcome is a vector rather than a scalar, hence
it is called the “vector product”. As with the scalar product we’ll motivate the definition with a
situation in mechanics where the product appears naturally.
You may recall from your work in mechanics this definition for the moment of a force in two
dimensions:
Given a force F which acts through a point P, whose position vector is r, the moment of F about the
origin O is defined to be
r F sin θ
where θ is the angle between r and F.
P
θ
F
r
O
In two dimensions we need to state whether the moment is a clockwise or anticlockwise one. In the
above diagram a clockwise moment is shown, one which would cause a clockwise rotation if the
system were pivoted at O. In three dimensions the situation is more complicated because we need to
state not only the sense (clockwise or anticlockwise) of the moment, but also the direction of the axis
about which it acts: that is, the axis about which the system would rotate if it were able to do so
freely.
Hence a moment in three dimensions possesses both a magnitude, r F sin θ , and a direction: the
direction of the axis of rotation. In short, it must be a vector quantity.
In the above diagram, if a three-dimensional moment is represented then we can say that it shows a
moment T of magnitude r F sin θ which is directed at right angles to the paper.
Our argument so far is deficient in one vital respect: consider what the problem is, and how it might
be solved, before reading any further.
The problem is: there are two directions at right angles to the paper: into it, and out of it. We have to
specify which. How can we do that?
That’s a bit of a trick question, because there is no natural solution to the problem. We simply have to
make a choice — an arbitrary one — and stick to it from here on.
The universally-accepted rule is this: choose the direction of T so that the triple of vectors (r, F, T)
forms a right-handed system.
This is a difficult idea; here’s what it means:
(i) Imagine yourself with a screwdriver in your right hand.
(ii) Approach the vectors r and F in such a way that when you turn the screwdriver in the
tightening (clockwise) direction it turns from r to F.
(iii) Then the direction in which the screwdriver is pointing is the direction of T.
So, then, according to this rule what is the direction of the moment T in the diagram above?
Answer: into the paper, as the following diagram demonstrates:
P
r
from r to F
O
F
The vector moment is one example of a general product of vectors. In general, given two vectors a
and b, at an angle θ from one another, we define their vector product as:
a × b = ( a b sin θ )nˆ
where nˆ denotes the unit vector which is perpendicular to both a and b in such a way that the triple of
vectors (a, b, nˆ ) forms a right-handed system.
Vector product is often also called the cross product, because of the “cross” symbol used in its
notation. Another notation you may sometimes see, which means exactly the same thing, is a ∧ b .
We offer two special commands for doing vector, or cross, products in Mathematica. The first
simply calculates the vector product, with i × j written as:
Cross[i, j]
The second command both calculates the answer and draws a 3-D graph:
CrossPlot[i, j]
The input vectors are shown in red and blue, the product vector in purple, and the plane in which
the input vectors lie marked in grey, to emphasise that the product vector is perpendicular to
both of the inputs.
1)
Calculate, by hand, all the possible vector products involving the Cartesian basis vectors i, j and
k: i × i, i × j, j × i, i × k, etc. Remember that the angle between any two of the basis vectors is 90
degrees, which simplifies things a lot. You’ll also need to know that the vector triple (i, j, k)
forms a right-handed system. Be warned: there is a difference between i × j and j × i! Check
your answers using Cross or CrossPlot.
2)
Use Cross or CrossPlot to try to answer these question about the vector product:
(i) What is the vector product of any vector a with itself, a × a?
(ii) Is the vector product commutative: that is, is it true that a × b = b × a for all vectors a and b?
Your work in part 1 should answer both of these straight away. The next two are harder though
(iv especially):
(iii) Is the vector product distributive: that is, is it true that a × (b + c) = a × b + b × c for all
vectors a, b and c?
(iv) Is the vector product associative: that is, is it true that (a × b) × c = a × (b × c) for all vectors
a, b and c?
[Hint: if you want to answer these questions in general using Mathematica, it is useful to define
three general vectors, such as:
a = a1 i + a2 j + a3 k;
b = b1 i + b2 j + b3 k;
c = c1 i + c2 j + c3 k;
Then you can easily build-up expressions like Cross[a,b] + Cross[b,c]. The
Simplify command will perform almost all of the algebraic simplifications that are possible
for a given input expression.]
Post-experiment reading
The result that i × j = –j × i shouldn’t be too surprising, since in the Preparatory Reading we spoke
about the vector moment T = r × F having a direction defined by turning an imaginary screwdriver
from r to F. If instead we wanted to turn from F to r we must be describing the vector –T = F × r.
There’s another way to look at the results for i × j etc. We know that the Cartesian basis (i, j, k) is a
right-handed system. So when we seek the vector i × j we’re looking for a vector of magnitude 1 (a
unit vector) in the direction which forms a right-handed system with i and j—that’s got to be k. If we
consider now the permutations (“shufflings”) of (i, j, k), then just two of them are right-handed:
(j, k, i) and (k, i, j). These imply a couple more cross product results. The other permutations,
(j, i, k), (k, j, i) and (i, k, j), are not right-handed which tells us immediately that j × i can’t be the
same as i × j.
General properties of the vector product:
(i) the outcome of the vector product is always a vector;
(ii) for any vector a, a × a = 0;
(iii) the vector product is not commutative, because for any a and b,
a × b = –b × a
We say that the vector product is anti-commutative, because the product one way around is the
negative of the product the other way around.
(iv) the vector product is distributive: a × (b + c) = a × b + b × c for all vectors a, b and c.
(v) the vector product is not associative: the relation (a × b) × c = a × (b × c) is not generally true.
The fact that the vector product is distributive is really the thing which justifies our calling it a
“product” in the first place.
Experiment 6: The vector product in component form
Preparatory reading
In this experiment we seek a general formula for the vector product of vectors expressed in
component form. The distributivity property found in the last experiment is key for this, because it
means we can expand out the brackets in the general expression:
(a x i + a y j + az k) × (b x i + by j + bz k)
where we’re writing any vector a as a x i + a y j + az k with a x denoting the x component of a, and so
forth.
1)
Perform by hand the expansion of the brackets in this general expression for a vector product:
(a x i + a y j + az k) × (b x i + by j + bz k)
Use the results about i × j etc. from Experiment 5 to simplify the expanded expression.
Check your answer with Mathematica by doing, for example:
Cross[Ax i + Ay j + Az k, Bx i + By j + Bz k]
2)
If you have studied matrices and determinants, find out the relationship between a × b and the
following determinant:
i
j
k
ax
bx
ay
by
az .
bz
Compare your answer with the result from part 1.
Post-experiment reading
The general formula for the vector product in component form is:
a × b = (a yb z − az b y )i + (a z bx − a x bz ) j + (a x by − a y bx )k .
It turns out that the formula can also be written as a determinant of a matrix:
i
j
k
a × b = ax
bx
ay
by
az .
bz
Practice Questions
There is a set of questions for you to practice doing cross products in component form. To
generate a question type:
GiveQuestion["cross product"]
not forgetting to "shift-return". To generate the answer for checking, type:
LastAnswer["cross product"]
Download