Linear algebra part 1 - Adding and subtracting vectors
Vectors are the building blocks of linear algebra. Where a number can only
represent a single quantity, a vectors can hold lots of piece of information at
once. Say I want to describe an aeroplane in flight. Using a number I can tell
you how heigh it is or what speed it is travelling, but never more than one thing
at once. Using a vector I can describe the planes latitude, longitude, height,
speed and direct at once. This ability to convey and manipulate lots of pieces
of information about an object at once makes them powerful tools of mathematics
and fundimental to the maths that underpins quantitative finance.
Vector notation
Vectors are normally denoted using a bold letter, v, in
pure maths and finance, and a letter with an arrow over the top,
v, in physics. I will use the maths and finance notation,
but be aware you may see other notation elsewhere.
A vector is normally written as vertical set of components, surrounded by square
brackets. This is known as vertical notation.
v=v1v2v3⋮vn
You might also see vectors written horizontally. This is normally done to save
space or so they can be written inline with text. In horizontal notation vectors
are surrounded by parentheses. Each component of the vector is separated by
a comma.
v=(v1,v2,v3,⋯,vn)
The components of a vector (v1,v2,v3) are denoted in
italic letters with subscript numbers to show their location in the vector. Each
individual component of the vector represents a a different quantity. For
example, in finance each component might represent the price of a different
stock. You cannot just add up the individual components of a vector.
The ⋯,vn the the end of vector v
mean it can have as many elements as you like. When we are talking about the
general form of vectors you will commonly see this at the end of each row. It is
there to let you know that the number of components displayed is not important
and that the same idea would be true for a vector of any length.
Dimensions of a vector
The dimensionality of a vector refers to the number of components it has. A
vector with two components is two dimensional, a vector with three components is
three dimensional, and so on. In the example below v is
a two dimensional vector and w is a three dimensional
vector.
v=[v1v2],w=w1w2w3
The dimensionality of a vector is denoted as Rn
where n is the number of dimensions. For example, a three
dimensional vector would be denoted as R3 and a seven
dimensional vector as R7.
Adding vectors
Vectors are added together by adding their components. The result is a vector
with the same length as the original vectors.
v=[v1v2],w=[w1w2]
v+w=[v1+w1v2+w2]
You can add together as many vectors as you like, with as many components as you
like.
Subtracting vectors works in exactly the same way. To subtract two vectors you
subtract the individual components. The results is a vector of the same length
as the original vectors.
v=[v1v2],w=[w1w2]
v−w=[v1−w1v2−w2]
Just like with addition, you can subtract as many vectors as you like with as
many components as you like.
You can only add or subtract vectors with the same number of dimensions. In the
following example it is not possible to add v and
w.
v=[47],w=013
Order of operation
Just like with normal numbers, we have to be careful to add and subtract vector
in the specified order. This means that v−w
is not the same as w−v. Let us prove that is
the case with this example:
v=[15],w=[37]
v−w=[15−−37]=[−2−2]
w−v=[37−−15]=[22]
Problems
If you can solve these problems you have understood how to add and
subtract vectors.
Add v and w, where:
v=[47],w=[8−3]
Subtract v and w, where:
v=470,w=8−31
Calculate v+v−x, where:
v=470,w=8−31,x=12−5
Solutions
To add the vectors v and w
we add their components together to end up with a single vector with the same
dimensionality as v and w:
v+w=[47++8−3]=[124]
To subtract the vectors v and w
we subtract their components to end up with a single vector with the same
dimensionality as v and w:
v−w=470−−−8−31=−410−1
We can add and subtract the vectors in order in the same way we would add or
subtract multiple vectors: