Basic Mathematics Notes_2
Basic Mathematics Notes_2
labelled as element a11 ; the element in the 2nd column of row 1, equal to 3, is labelled as a12 .
A general element aij is located in row i and column j (see equation 4 for a further example).
2.1.2 Notation
There are different types of notation for matrices and vectors that you may encounter in text
books. Below are some examples:
Matrix
A italics
A bold, italics
A double underline, italics
Vector
x italics
~x top arrow, italics
x single underline, italics
x bold
2.1.3 Addition
Two matrices (or vectors) of the same size (n × m) may be added together, element by
element. For instance, if we have two matrices A and B:
a11 a12 b11 b12
A= B= (4)
a21 a22 b21 b22
4
then,
a11 + b11 a12 + b12
A+B = (5)
a21 + b21 a22 + b22
2.1.4 Subtraction
Similar to addition, corresponding elements in A and B are subtracted from each other:
a11 − b11 a12 − b12
A−B = (6)
a21 − b21 a22 − b22
If λ is a number (i.e. a scalar) and A is a matrix, then λA is also a matrix with entries
λa11 λa12
(7)
λa21 λa22
This is non-trivial and is governed by a special rule. Two matrices A , where A is of size
n × m, and B of size p × q, can only be multiplied if m = p, i.e. the number of columns in
A must match the number of rows in B. The matrix produced has size n × q, with each entry
being the dot (or scalar) product (see section 2.1.10) of a whole row in A by a whole column in
B.
5
e.g. if
1 2 3
1 3 6
A= and B=
5 6 7
(8)
0 −1 4
9 10 11
then
(1 × 1) (1 × 2) (1 × 3)
+ (3 × 5) + (3 × 6) + (3 × 7)
+ (6 × 9) + (6 × 10) + (6 × 11)
AB =
(0 × 1) (0 × 2) (0 × 3)
+ (−1 × 5) + (−1 × 6) + (−1 × 7)
+ (4 × 9) + (4 × 10) + (4 × 11)
70 80 90
=
31 34 37
Formally, if
AB = C then
m
X
cij = aik bkj (9)
k=1
Aside
When using Matlab (or octave), two matrices can be multiplied in an element-wise sense. This
is NOT the same as described above.
6
2.1.7 Motivation for matrix-matrix multiplication
To understand why we may need to perform matrix-matrix multiplication, consider two cus-
tomers of a repair garage, Peter and Alex, who require a number of car parts for each of their
vehicles. Peter requires 1 × 3 litre engine and 2 doors, whereas Alex requires 1 × 5 litre engine
and 4 doors. All the parts require a certain number of screws and bolts. But how many total
screws and bolts do Peter and Alex need?
We can present the quantity of each car part that Peter and Alex need in a table:
Peter 1 0 2
Alex 0 1 4
or as the matrix, A:
1 0 2
A= . (10)
0 1 4
The number of screws and bolts for each car part are expressed in the table:
bolts screws
3 litre 3 4
5 litre 1 8
doors 2 1
Using simple addition we can find out how many screws and bolts are needed.
7
2. How many bolts are needed for Alex’s car parts?
(0 × 3) + (1 × 1) + (4 × 2) = 9.
Since a vector is a special case of a matrix, this is simply a special case of the matrix-matrix
multiplication we have already discussed. Consider multiplying a column vector of length m
by a matrix of size n × m,
e.g.
2
1 3 6 23
=
1
0 −1 4 11
3