You are on page 1of 2

Notes02

Review of vectors and matrices


Vector: a math entity characterized by its magnitude and direction. In mathematics, a
vector is just a list of numbers. In my notation, the underscore (the short horizontal
line under a letter/symbol) means a vector. For example, a row vector a can be defined
as a = [2, 9, 6, 3, 1]. We can also create column vectors by separating the numbers
using semicolons (i.e. each semicolon means going to the next row). For example, b =
[2; 9; 6; 3; 1]. It is clear that the transpose of b =a , or vice versa.

Matrix: a matrix can be viewed as a two-dimensional vector. For example, suppose a1


= [6, 4, 24] and a2 = [1, -9, 8], and suppose matrix Ma=[a1; a2]. Then, Ma =

Note: 1. In Matlab (or Octave), vectors and matrices are expressed in the same way as
the above. However, in Python, column vectors and matrices are expressed in a
different way. See the Python files (pmath01.py and pmath02.py) for more detail.
2. Vectors can have physical meanings. For example, the position of an object P on a
plane can be expressed as a vector. Suppose we use the x and y axes to denote the
position, and suppose P is located at x=3 and y=4. That is, the position vector of P
(relative to the origin) is [3, 4]. It is clear that this position vector is characterized by
its magnitude (which is the squared root of 32+42 in this case) and direction (the angle
measured relative to x or y axis).
3. Two vectors are equal as long as they have the same magnitude and direction.
Usually they don’t have to be coincident. In some cases, as in force application, we
may need to consider whether two vectors are coincident.

In 3-dimensional (3D) Cartesian coordinates, a vector is usually expressed as the


summation of the vector’s components in 3 mutually perpendicular directions.
That is, a vector a in 3D can be expressed as a = a1 + a2 + a3 , where × = ,
× = , × =
· = 1 if i=j; · = 0 if i≠j.
Also, the 3 components of this vector can be calculated as: a1 = a· , a2 = a· , and a3
= a·

The unit vector of vector a is usually denoted as â and is defined as a/|a|, where |a|2 is
(a1)2 + (a2)2 + (a3)2.

Vector addition is commutative (a + b = b + a) and associative (a + b) + c = a + (b +


c). If we use the format of column vectors, a = [a1; a2; a3] and b = [b1; b2; b3], then a +
b = [a1+b1 ; a2+b2 ; a3+b3]

Dot product:
The dot product of two vectors is a scalar. For example, a·b = |a||b|cosθ, where θ is the
angle between the two vectors. Thus, a·b = a1b1 + a2b2 + a3b3
The dot product is commutative and distributive. That is, a·b = b·a , and a·(b + c) =
a·b + a·c

Cross product:
The cross product of two vectors is a vector. For example, a×b = c, where |c| = |a||b|
sinθ. The direction of c is perpendicular to both a and b, and is obtained using the
right-hand rule.
a×b = -b×a
a×(b × c) = (a·c)b – (a·b)c
a·(b × c) = b·(c × a) = c·(a × b)

Also, a cross product between two vectors can be written as the product of a skew-
symmetric matrix and a column vector. That is, let a = [a1; a2; a3] and b = [b1; b2; b3].
Then, a×b (expressed as a column vector) =

Note that matrix multiplication is to perform dot products for the corresponding rows
and columns. If you are not familiar with matrix multiplication, some examples can
be found here: How to Multiply Matrices (mathsisfun.com)

Example: Vector a = 2 + + 2 . Please calculate its unit vector â, which is defined


as a/|a|. Vector b = 5 + 4 + 3 . Calculate the dot product and cross product of a ,
b.
Sol: |a|= sqrt(2*2+ 1*1 + 2*2)=3. Thus, â = a/|a| = (2/3) + (1/3) + (2/3) .
Dot product of a , b is 2*5+1*4+2*3=20.
Cross product is (1*3 – 2*4) + (2*5 – 2*3) + (2*4 – 1*5) = -5 + 4 + 3 .
Please also use computer coding to perform the calculation.

You might also like