Vectors For Beginners
Vectors For Beginners
Leo Dorst
September 6, 2007
2 Vector properties
What are vectors?
• geometric: For now, vectors are like arrows starting from a common point
(the origin) in an n-dimensional space. In our examples we use 2-D and
3-D. A vector has a direction, and a length. That length is called its norm.
• symbolic: We will denote a vector as a variable with an arrow overhead:
the vector ~x. The norm is written as k~xk. We can only specify the direction
relative to standard vectors. In n dimensions, you need n standard vectors,
called a basis. We will denote those standard vectors as ~e1 , · · · ~en . We
often choose them perpendicular and of unit length; then they point in
the direction of the coordinate axes that in high school you used to call
1
the x-axis, y-axis, et cetera. Since we run out of the alphabet soon, and
because programs typically run over the indices of the dimensions, we will
use ~ei instead, with i running from 1 to n.
• computational : You can think of an n-D vector as n numbers. These
numbers give the components relative to the standard vectors. Adding
these components (see below) gives the vector. It is traditional to write
the n numbers in a column, with square brackets, and label then with the
basis vector they refer to. So
x1
~x 7→ x2 (1)
x3
2
Figure 1: Addition of the vectors ~x and ~y to form the vector ~x + ~y . (In these
figures, we label the vectors with bold font, rather than overhead arrows.)
distributivity: (λ + µ) ~x = λ ~x + µ ~x (3)
3.2 Addition
You can also add two vectors ~x and ~y to make a new vector which is called their
sum.
• geometric: Vector addition is done by completing the parallelogram of
which ~x and ~y are the sides, and using the diagonal from the origin as the
resulting sum vector (see Figure 1).
• symbolic: We denote the sum as ~x + ~y .
• computational : We compute the sum as:
x1 + y1
~x + ~y 7→ x2 + y2 . (4)
x3 + y3
commutativity: ~x + ~y = ~y + ~x
(5)
associativity: (~x + ~y ) + ~z = ~x + (~y + ~z)
Prove this for yourself, and also draw the geometry of these properties.
3
The scaling of a vector behaves nicely relative to the addition:
3.4 Linearity
In linear algebra, we are going to be interested in operations on vectors. For
example, rotating a vector, to point in another direction. For the moment, we
denote the rotation of a vector ~x as R(~x). We are not going to define it com-
putationally yet, but you may check geometrically that this rotation operation
has the properties:
4
• computational : The dot product of two 3-D vectors ~x and ~y is defined as:
x1 y1
x2 · y2 = x1 y1 + x2 y2 + x3 y3 . (9)
x3 y3
• symbolic: From the computational definition, you can prove for yourself
the following properties at the symbolic level:
symmetry: ~x · ~y = ~y · ~x
scaling: (λ ~x) · ~y = λ (~x · ~y ) (10)
distributivity: (~x + ~y ) · ~z = (~x · ~z) + (~y · ~z)
The dot product therefore behaves very much like multiplication of num-
bers.
However, it is not associative. We cannot even express associativity, for in
(~x · ~y ) · ~z is not defined: (~x · ~y ) is a scalar, and we do not know how to take
the dot product of a scalar and a vector ~z. Because of such difficulties,
you should be very accurate in your notation of the products. Do not use ·
for scalar multiplication. Do not use × (we will give it a different meaning
later). Just use a space for regular multiplication of scalars, and reserve ·
for a true dot product, of vectors.
• geometric: It turns out that the geometric interpretation of the dot prod-
uct is an interesting combination of angles and lengths. Let the length
(norm) of the vector ~x be k~xk, similar for ~y , and let the angle from ~x to
~y be φ. Then it can be shown that: 1
and from (11), since the angle between ~x and itself is zero:
~x · ~x = k~xk2 . (13)
1 But we will not show this here, we just give the result. We will encounter it later in
Bretscher. You may attempt a proof now...
5
Combined, this gives us a formula to compute the norm of a vector ~x:
√ q
k~xk = ~x · ~x = x21 + x22 + x23 . (14)
This is of course Pythagoras’ theorem, applied to the coordinates of ~x, now in
3-D. Since ~x · ~x can be computed in n-D, the symbolic formula is valid in n-D,
and the computational formula can be extended simply to that case.
Another special case of (11) is when ~x and ~y are perpendicular. Then φ =
±π/2 (in high school, you called this ±90 degrees but from now on you should
work in radians), so cos(φ) = 0. Conversely, if the dot product of two non-null
vectors is zero, they must be perpendicular. So we get:
~x perpendicular to ~y ⇔ ~x · ~y = 0.
This is rather unlike what we know of multiplication of numbers: if the product
of numbers satisfies x y = 0, then x = 0 or y = 0 (or both). Vectors can have a
zero dot product without being zero.
We can also use (11) to make a formula for the angle φ between two vectors:
~x · ~y x1 y1 + x2 y2 + x3 y3
cos(φ) = =p 2 p . (15)
k~xk k~y k x1 + x22 + x23 y12 + y22 + y32
This can also be extended to n-dimensional space.
A useful special case is if ~y is a unit vector ~e, which is a vector with unit
norm k~ek = 1. Then we get:
~x · ~e = k~xk cos(φ). (16)
This is precisely the length of the perpendicular projection of ~x on ~e, see Fig-
ure 2. Therefore, if we multiple the unit vector ~e by this length, we get the
component (~x · ~e) ~e of ~x along the ~e direction. If you write all this out in coordi-
nates by the computational method (even in 2-D), you will realize the advantage
of the symbolic notation, which moreover holds for n dimensional space as well.
6
Figure 2: Projection of ~x onto a unit vector ~e using the inner product, resulting
in (~x · ~e) ~e.
(a) (b)
7
Figure 3(b).
When we express that geometric insight symbolically, we simple get:
~x · ~e = δ (18)
as the characterization of the line. Now we can get back to the original
vector d~ by multiplying both sides by δ. The left hand side then gives ~x · d~
(why?), the right hand side δ 2 , which is the same as d~ · d~ (why?).
So ~x points to a point on the line characterized by d~ if and only if:
~x · d~ = d~ · d.
~ (19)
Actually, (18) is a bit more general, for it still works when δ = 0, whereas
(19) then has problems. How would you characterize the problem geomet-
rically (take a line through the origin; what property of the line can (19)
not encode?).
In either (18) or (19), the vectors ~e or d~ are called a normal vector for the
line. This is jargon, ‘normal’ here means ‘perpendicular’. Since ~e is a unit
vector, it is called a unit normal (vector) for the line, and since d~ ‘carries’
the line it is sometimes called the support vector of the line.
• computational : Now let us look at his computationally, taking (18) in 2-D.
Then the unit vector ~e can be specified relative to some fixed coordinate
basis {~e1 , ~e2 }. Let us have it make an angle φ with ~e1 , then its components
are:
cos(φ)
~e 7→ (20)
sin(φ)
Verify this, using your high school knowledge of a right-angled triangle
with angle φ! Then (18) becomes, computationally:
x1 cos(φ) + x2 sin(φ) = δ. (21)
You may not recognize that yet. But in high school, you called x1 (which
is the component of ~x in the ~e1 -direction) the x-coordinate of the point ~x
points to, and x2 the y-coordinate. So we get:
x cos(φ) + y sin(φ) = δ. (22)
Also in high school, you were used to having things of the form y = f (x),
since you were dealing with functions. We are dealing with geometry, but
let us write our equation in the same form:
cos(φ) δ
y=− x+ , (23)
sin(φ) sin(φ)
though we can only do this when sin φ 6= 0. This is clearly something of
the form
y = a x + b, (24)
if we make the correct identifications by defining a and b in terms of φ and
δ. So indeed, the original (18) defines a line in its more classical form.
8
(a) (b)
Yet (24) has problems. It is not defined when sin φ = 0, i.e. when the normal
vector is in the y-direction. The line is then vertical, and a would have to be
infinite, or we would have to switch over to a line of the form x = c. For
hand computations that is OK, but in a computer we would prefer to have a
representation that always works. So (18) is much better, for it has no problems
with lines in any direction or location. Verify that for the example of a vertical
line!
Exercises
3. Give the vector equation (18) of the line y = x + 1.
4. Give vector equation (18) of the line y = −x − 1, but using ~e =
√ the √
(1/ 2, 1/ 2).
√ √
5. Draw the line with ~e = (1/ 2, 1/ 2) and δ = 1.
9
• geometric: They then are still the equations for the perpendicular pro-
jection of ~x along ~e to have the length δ. That suggests the picture of
Figure 4(b). It therefore seems to characterize a plane in space, with
support vector d~ as in Figure 4(a).
• computational : It is more difficult to define directions and angles in space,
and we will not do that here. But it is simple to verify that the symbolic
equation resulting from the dot product has the form:
a1 x1 + a2 x2 + a3 x3 = c. (25)
at a distance
c
δ=p 2 . (27)
a1 + a22 + a23
Of course, it does not stop with 3-D. The equation (18) defines a hyperplane
an n-dimensional space, i.e. a flat element of dimensionality (n − 1). In 2-D, the
hyperplane is 1-D, and we are used to calling it a line; in 3-D, the hyperplane
is 2-D and we call that a plane.
Exercises:
11. Derive the formula (27) for the distance of a plane with equation (25) to
the origin.
1
12. Give the equation of a plane with normal vector −1 at distance −1
2
from the origin.
13. Where does the plane with equation 2x1 + 3x2 − 5x3 = 6 cut the ~e1 -axis?
14. The plane with equation 2x1 + 3x2 − 5x3 = 6 cuts the plane with equation
x3 = 0 in a line. What is the equation of that line?
10