ENG1001 Notes Matrices and Vectors
ENG1001 Notes Matrices and Vectors
1 Matrices
(Note: see also the additional sheet of Matrix examples for this module.)
Engineering analysis often produces very large systems of simultaneous equations, sometimes
more than 1,000 equations in 1,000 unknowns. To solve these systematically, we need a method
of recording and calculating that can be programmed on a computer.
A matrix is a rectangular array of numbers, or symbols representing numbers or other quan-
tities.
As a first, simple example, here are three equations in variables x, y, z:
2x +3y +4z = 1
3x −y =2 (1)
x +2y +1.5z = 3
This is a 3 x 3 square matrix (i.e. 3 rows and 3 columns), and two 3x1 matrices, also called
column matrices or column vectors. Note the way they combine to produce the equations.
Here’s some more examples of matrices of various shapes and sizes, with descriptions:
2 5 −1
- a 2 x 3 rectangular matrix
0 3 2
0 0
- a 2 x 2 square matrix, which is also a zero matrix (all entries zero).
0 0
2 0 0
0 3 0 - a 3 x 3 diagonal matrix. (3)
0 0 4
Note: we can use either (..) brackets or [..] brackets. Square brackets are clearer for large
matrices.
The transpose of a matrix is another matrix with rows and columns swapped from the original,
and hence the number of rows and columns is also swapped. For example:
T
2 −1 2 3
=
3 4 −1 4
T 3 2
3 0 −1
= 0 5 (5)
2 5 7
−1 7
For both these examples, (aij )T = aji , as rows and columns have been swapped. If we swap
twice, we get back to where we started: (AT )T = A.
T 1
1 0 −3 = 0 so the transpose of a 1 x 3 matrix is a 3 x 1 matrix.
−3
For a symmetric matrix, AT = A. For an antisymmetric matrix (see eq.(4)), AT = −A.
If
2 3 0 2
A= , B=
−1 4 1 −5
3A or 2B means multiplying every element of that matrix by a number - we call this multi-
plication by a scalar. Note: all the matrices here are of the same order (size). Addition and
subtraction of matrices requires this.
If
2 −1 5 0
A= , B=
3 4 −2 −3
then AB is also a 2 x 2 matrix. Working along the rows of A and down the columns of B, we
get:
2 −1 5 0
AB = =
3 4 −2 −3
1st row of A x 1st col of B 1st row of A x 2nd col of B
=
2nd row of A x 1st col of B 2nd row of A x 2nd col of B
(2)(5) + (−1)(−2) (2)(0) + (−1)(−3) 12 3
= (7)
(3)(5) + (4)(−2) (....)(....) + (....)(....) 7 −12
5 0 2 −1 10 −5
BA = = 6= AB. (8)
−2 −3 3 4 −13 −10
2 1 0 5 10
−3 0 1 2 3
= −3 −6 −9 (9)
−2 1 4
−4 1 −6 .... ....
Note the numbers of rows and columns: [3(a) x 2(b)]x[2(b) x 3(c)] = [3(a) x 3(c) ], where e.g.
(a) means these are equal.
The same two matrices, multiplied in the opposite order:
2 1
1 2 3 −16 4
−3 0 = (10)
−2 1 4 −23 2
−4 1
2 1 1 5 1 2 1
= , but =? (11)
−3 4 3 9 3 −3 4
which can’t even be done! As a general result, AB 6= BA in most cases, even where both are
possible.
2 2 4 6
2 3 = (13) - the scalar product, but 2 3 = . (12)
3 3 6 9
Hence [1 x 2] x [2 x 1] = [1 x 1], whilst [2 x 1] x [1 x 2] = [2 x 2].
T 2
We could also write A = (2 3), then A = and AAT = (13).
3
For any matrices where the multiplications are all possible, (AB)C = A(BC), but the ordering
mustn’t be changed.
The second matrix is labelled I and is called the unit matrix or identity
matrix.
Here it’s a 2x2
1 0 0
matrix, but it can be a 3x3 or any NxN square matrix, e.g. I = 0 1 0 . For any order
0 0 1
of I, we can say: aii = 1, aij = 0 if i 6= j.
1 0 0
1 0 2 3 4 2 3 4 2 3 4 0 1 0 .
= = (14)
0 1 −1 −2 0 −1 −2 0 −1 −2 0
0 0 1
We can always say: IA = A = AI, if I is the right size for each calculation (I is different in
the two sides of this equation!).
pd − qb
(ad − bc)x = pd − qb, x= (20)
ad − bc
a b a b
ad − bc is the determinant of the matrix , written detA =
= ad − bc. If it’s
c d c d
zero, the method fails, the matrix is singular.
In matrix form:
a b x p
= , or Ax = p (21)
c d y q
−→
Note that vectors must be written as underlined or bold symbols or with an arrow, e.g. AB.
a b
det(A) = |A| =
= ad − bc (for a 2 x 2 matrix) (22)
c d
If |A| = 0, the matrix is singular and we can’t find a unique solution to the equations.
Consider a single equation. Which of the following can be solved?
Which of these have a unique solution? Which has many solutions? Which has no solution?
In a general form, if we wish to solve ax = b, there are three possibilities. If a 6= 0, it has a
unique solution. If a = 0, b = 0, it has multiple solutions. If a = 0, b 6= 0, is has no solution.
These outcomes apply to many real-life problems!
For two equations, a graph illustrates these - two lines crossing at one point, two lines coinciding,
two parallel lines.
a−1 (ax) = a−1 (b), (a−1 a)x = a−1 b, (1)x = a−1 b, x = a−1 b (24)
A−1 (Ax) = A−1 (b), (A−1 A)x = A−1 b, Ix = A−1 b, x = A−1 b (25)
Examples:
1.
2 −3 x 2
= , or Ax = b (28)
1 4 y −5
|A| = (2)(4) − (−3)(1) = 11 6= 0 (29)
−1 1 4 3 4/11 3/11
A = = (30)
11 −1 2 −1/11 2/11
−1 1 4 3 2
x=A b= (31)
11 −1 2 −5
1 −7 1 7 −7/11 7/11
x= =− = = − 12 - four valid forms! (32)
11 −12 11 12 −12/11 /11
2.
−1 −4 x1 3
= , or Ax = b (33)
−1/2 3 x2 0
|A| = (−1)(3) − (−4)(−1/2) = −5 6= 0. (34)
1 3 4 3 1 9
x= =− (35)
−5 1/2 −1 0 5 3/2
1 18 3 6 −1.8
=− =− = (36)
10 3 10 1 −0.3
3.
1 1 0 −3 −2 1
1
If A = −3 −1 1 then A−1 = 6 2 −1 (37)
3
0 1 2 −3 −1 2
Check that A−1 A = AA−1 = I by multiplying the matrices. (The method for finding the
inverse of a 3 x 3 matrix is not given in this course and you don’t need to know it!)
Assume all matrices in these statements conform, i.e. have row and column numbers that make
these calculations possible:
For a 2 x 2 matrix, it’s efficient to find A−1 and use this to solve equations. For a 3 x 3 matrix,
it’s also OK. For a 10 x 10 matrix, i.e. 10 equations in 10 variables, about 107 operations are
needed if the ‘explicit’ inverse matrix is used (i.e. a formula producing every element of it).
For a 100 x 100 matrix, using the explicit inverse would take until the end of time! Therefore,
for large systems of equations, we use other methods (to find the inverse, or otherwise).
Example:
x −3y +z = −9
2x +5y +3z = 24 (42)
−x +2y +z =1
Now solve by back-substitution (find last variable first, using last equation).
Solve 3rd equn for z: 23z = −46, z = −2.
Substitute z into 2nd equn: −y + 2z = −8, −y − 4 = −8, y=4
Substitute y, z into 1st equn: x − 3y + z = −9, x = −9 + 3y − z = −9 + 12 + 2 = 5.
Notes:
1. Don’t want zeroes on main diagonal. Ideally maximise diagonal entries to minimise
rounding errors.
2. If the final equn ends up as, e.g. (0 0 0 : 7), there is no solution - the equns are inconsistent.
4. If the number of equns > number of unknowns, either some equns are redundant, or
there is no solution.
Use EROs to convert a matrix to I, and simultaneously do the same to I to turn it into the
inverse. For example:
2 3 2 3 1 0
A= , (A|I) = Divide 1st equn by 2 (47)
−1 4 −1 4 0 1
1 3/2 1/2 0
Add 1st equn to 2nd (48)
−1 4 0 1
1 3/2 1/2 0 2
Multiply 2nd by (49)
0 11/2 1/2 1
11
This method can be used for a square matrix of any size. It’s efficient, but there are neater
ways of doing the same thing!
This is needed for the vector cross product, and works for larger matrices too. (Here we use the
top row, but any row or column can be used if the +/- signs are correct.)
Work along the top row, multiplying each element by the smaller (2 x 2) determinant obtained
by deleting the top row and the current column, and alternating +/- in turn:
2 3 −1
1 2 4 2 4 1
0 3 − (3) −1 3 + (−1) −1 0 = 2(3) − 3(14) − 1(1) = −37 (53)
4 1 2 = +(2)
−1 0 3
2 Vectors
Note: see the videos for diagrams illustrating much of this topic!
2.1 Definitions
A vector has a magnitude and a direction, e.g. force, acceleration, displacement, velocity,
temperature gradient.
A scalar has only a magnitude, e.g. energy, speed, distance, mass, temperature, pressure.
We work with vectors in both ‘overall’ form and in component form. Several notations are
used: a or →
−
a or a (bold - used in print), or .
W = F (d.cosθ) = (F.cosθ)d
- a scalar derived from two vectors. The scalar product of F and d (or dot product), is
π
If θ = 0, F · d = |F||d|. If θ = , F · d = 0. (55)
2
Note that a zero dot product implies the two vectors are at right angles (or one is zero). This
is useful if we want to show that two directions are perpendicular.
i · i = 1 × 1 × 1 = 1, so i·i=j·j=k·k=1 (56)
i · j = 1 × 1 × 0 = 0, so i · j = j · i = i · k = k · i = j · k = k · j = 0. (57)
a · b = 6i · i − 12i · j + 9i · k + 4j · i − 8j · j + 6j · k − 2k · i + 4k · j − 3k · k
= 6 − 0 + 0 + 0 − 8 + 0 − 0 + 0 − 3 = 6 − 8 − 3 = −5 (61)
In general, a · b = a1 · b1 + a2 · b2 + a3 · b3 . (62)
1
a · b = |a||b|cosθ, so cosθ = a·b (64)
|a||b|
The result of cos−1 x is an angle always between 0 and π.
Examples Note: many examples make use of two standard right-angled triangles, one with
angles π/4 = 45◦ and the other with angles π/6 = 30◦ and π/3 = 60◦ - this is half of an
equilateral triangle with angles π/3 = 60◦ . (See video for diagram.)
√ √
1. If a = i + j, b = 3j, then a · b = 0 + 3 + 0 = 3, |a| = 12 + 12 = 2, |b| = 3.
3 1 π
cosθ = √ = √ , θ = .
3 2 2 4
√ √
2. c = 2i − 3j + k, d = i + 2j + 2k c · d = −2, |c| = 4 + 9 + 1 = 14, |d| = 3,
−2
cosθ = √ = ....., hence θ = ....... Note: θ > π/2 as cosθ < 0.
3 14
i, j, k are unit vectors - by definition they have modulus=1 (i.e. |i| = 1).
We can convert any vector to a unit vector by dividing by its modulus.
For example: a = 2 −2 1 , |a| = 3, so we write:
a = 31 2 −2 1 , or 23 i − 23 j + 31 k
b (65)
1
so b
a= a · b.
a, hence cosθ = b b (66)
|a|
There are several possible aims. We can find the component of vector F in the direction given
by vector a as a scalar (i.e. just its size) or as a vector (F1 ). We can also find the component
of F perpendicular to a as a scalar or as vector F2 . To find the scalar component:
1
|F1 | = |F|cosθ = F·a=F·b
a. (67)
|a|
F1 = |F1 |b
a = (F · b
a)b
a. (68)
A position vector gives a displacement relative to an origin, so it’s a fixed vector (not a
free vector). This is important when we find the moment of a force about an axis or a point.
In 2D, the moment of a force about a point as shown is given by M = d|F|. If we don’t know
d, but we do know the position of a point on the line of the force, given by the position vector
d, then we can write M = |F||d|sinθ.
In 3D, we also need to find the direction of the torque, which will be the direction of the axis
if the body is free to turn (ship, satellite, etc.). If the axis is fixed, we can find the moment or
torque about that axis as a later calculation.
We specify a unit vector n
b perpendicular to both d and F, with d, F, n
b in a right-hand set. We
can also use the corkscrew rule - if we turn from d to F, the screw travels along nb . We then
get:
M = d × F = |d||F|sinθ n
b. (69)
From (69), the cross product of parallel vectors is zero (as sinθ = 0), also of any vector with
itself. Hence:
Also, as unit vectors have modulus = 1, and i, j, k are all perpendicular to each other (hence
sinθ = 1) and form a r.h.set:
i × j = −j × i = k, j × k = −k × j = i, k × i = −i × k = j. (71)
We’ll use these results just once, then explain a simpler method for working out cross products.
Example
If a = 2i − k, b = −i + j + 3k, then:
= (2i) × (−i) + (2i) × (j) + (2i) × (3k) + (−k) × (−i) + (−k) × (j) + (−k) × (3k)
= 2k − 6j + j + i = i − 5j + 2k = c (72)
where we’ve given the result a new name c. Now we look at how this result relates to the two
vectors we combined:
As both results are zero, c must be perpendicular to both a and b. That is, the cross product
is perpendicular to both vectors. This can be used to construct a direction perpendicular to
two given directions (e.g. to a plane).
For vectors b × c,
i j k
b2 b3 b1 b3 b 1 b2
b × c = b1 b2 b3 = +i − j
c1 c3 + k c1 c2
(74)
c1 c2 c3 c2 c3
3. a × b = −b × a
6. a × (b + c) = a × b + a × c
7. a × (b × c) 6= (a × b) × c
In fact, a × (b × c) = (a · c)b − (a · b)c As an exercise, choose some vectors for a, b, c
and check by calculating both sides of this.
8. a · (b × c) = (a × b) · c You can check this too using any vectors you’ve chosen (note
that the result is a scalar – this is called the scalar triple product).
3. Charged particles: F ∝ v × H.
4. 3D rigid body rotation: The velocity of a point at position d from the axis is |d|sinθ|ω|,
hence v = ω × d.