You are on page 1of 21

MATH1031 Mathematics for Life Sciences

Term 3, 2021

Matrix Algebra

Dr. Joshua Capel


Red Centre Room 5107

Based on the slides provided by Dr. Chi Mak

School of Mathematics and Statistics


University of New South Wales
j.capel@unsw.edu.au

Joshua Capel (UNSW) MATH1031 1 / 21


Matrix Algebra

This lecture, we will meet matrices: a tool that is very useful for
manipulating inter-related quantities. They give us a completely new
algebra known as matrix algebra.

Matrix addition
Matrix subtraction
Scalar multiplication – multiplying a matrix by a scalar1
Matrix multiplication – multiplying a matrix by another matrix

1
e.g. a real or a complex number.
Joshua Capel (UNSW) Matrix Algebra 2 / 21
Uses of Matrices

Some common uses of matrices:


conservation biology (population modelling).
data analysis (almost ALL forms of data analysis use matrix algebra
behind the scenes)
computer graphics.
deep learning algorithms.

Joshua Capel (UNSW) Matrix Algebra 3 / 21


What is a Matrix and what is it good for?

A matrix is a useful shorthand way of representing inter-related quantities.


We can use the shorthand representation of the problem to simplify and
solve it.

Example. Suppose we have a delivery service who carries four products:


milk, bread, butter, and eggs. They record their orders in a table:

Monday Milk Bread Butter Eggs


Customer A 2 1 0 12
Customer B 4 2 1 0
Customer C 1 1 1 6

Joshua Capel (UNSW) Matrix Algebra 4 / 21


What is a Matrix and what is it good for?

To save time, they don’t bother to set up the table every time, so the
following page looks like:
Tuesday
3 0 2 6
1 3 0 0
4 2 1 24
To an outsider this is just a jumble of numbers, but they do mean
something to the person who set it up.

We draw brackets around the array to form a single object — a matrix.

Example.  
1 0 0 6
Wednesday  2 1 1 0 
4 0 1 0
Joshua Capel (UNSW) Matrix Algebra 5 / 21
So what is a matrix?

A MATRIX is a rectangular array of numbers.


The numbers in the array are called the ENTRIES of the matrix.

We denote the entry at the ith row and jth column in A by Aij .

Example.  
3 −1 2
π 7 13
The element in the 2nd row, 1st column is A21 = π.
The element in the 1st row, 3rd column is A13 = 2.

Note the pattern: First row number, then column number.

Joshua Capel (UNSW) Matrix Algebra 6 / 21


Matrix Order

The ORDER or SIZE of a matrix is a description of its size.


It is the number of rows × the number of columns.

Example.  
2 1
3 2  is a 3 × 2 matrix.
1 6

Again we see the pattern first row, then column.

Two matrices are said to be EQUAL if they have the same order
and all the entries are correspondingly equal.
       
3 2 3 2 3 2 3 2 0
Example. = , but 6= .
1 1 1 1 1 1 1 1 0
Joshua Capel (UNSW) Matrix Algebra 7 / 21
Square Matrices

If the number of rows = the number of columns, the


matrix is said to be SQUARE.
 
3 2
Example. The matrix is a square matrix.
1 1
 
3 2 4
Example. The matrix  2 1 1 is a square matrix.
−4 0 4
 
3 2
Example. The matrix 1 1 is not a square matrix.
2 2

Joshua Capel (UNSW) Matrix Algebra 8 / 21


Square Matrices

If the number of columns = 1 the matrix is said to be


a COLUMN MATRIX.
If the number of rows = 1, the matrix is said to be
a ROW MATRIX.
Example. The matrix  
1
 4 
2
has order 3 × 1 and is called a COLUMN MATRIX.

Example. The matrix 


2 1 3 4
has order 1 × 4 and is called a ROW MATRIX2 .
2
You may hear these called ’vectors’ in other contexts.
Joshua Capel (UNSW) Matrix Algebra 9 / 21
Transpose of a Matrix

The transpose of an m × n matrix A is the n × m matrix


AT whose ros are columns of A, in order.

In the delivery matrix for Wednesday, each row represents the order of a
customer.  
1 0 0 6
W = 2 1 1 0
4 0 1 0

We can use each column to represent order of a customer:


 
1 2 4
0 1 0
WT =  0 1 1

6 0 0

Joshua Capel (UNSW) Matrix Algebra 10 / 21


Matrix Addition

If two matrices are the same order they can be added together by adding
the elements in the same position.

Example. Suppose the delivery service needs to know the total amount
of groceries to be delivered on Monday and Tuesday.
     
2 1 0 12 3 0 2 6 5 1 2 18
 4 2 1 0 + 1 3 0 0  =  5 5 1 0 
1 1 1 6 4 2 1 24 5 3 2 30
| {z } | {z } | {z }
Monday Tuesday Monday and Tuesday

Joshua Capel (UNSW) Matrix Algebra 11 / 21


Matrix Addition

Example.
   
2 1 1 −2
 3 2 + 4 0 =
1 6 −1 7

Example.
 
2 1  
 3 2 + 2 0
0 4
1 6

Joshua Capel (UNSW) Matrix Algebra 12 / 21


Matrix Subtraction

If two matrices are the same order they can be subtracted by


subtracting the elements in the same position.
Example.
     
2 1 1 −2 1 3
 3 2 − 4 0  =  −1 2 
1 6 −1 7 2 −1

Example.
   
2 1 0 12 3 0 2 6
 4 2 1 0 − 1 3 0 0 =
1 1 1 6 4 2 1 24

Joshua Capel (UNSW) Matrix Algebra 13 / 21


Scalar Matrix Multiplication

Scalar Multiplication of a matrix by a scalar is performed by


multiplying each entry of the matrix by the scalar.

Example. If the Monday order of the delivery service is repeated every


Monday for 4 weeks, then the total delivered on Monday is
   
2 1 0 12 8 4 0 48
4  4 2 1 0  =  16 8 4 0 
1 1 1 6 4 4 4 24
| {z }
Monday

 
2 −1
Example. 3 3 2 =
−1 4

Joshua Capel (UNSW) Matrix Algebra 14 / 21


Some Problems

Exercise.
   
1 0 3 4  
0 1 4
A =  −3 4  , B =  2 6 , C=
2 3 2
1 2 1 −5

1 State the order of each matrix


2 Calculate 3A, B T .
3 Calculate A + C , 3A − B and A + C T

Joshua Capel (UNSW) Matrix Algebra 15 / 21


Combining Matrices
Suppose we return to the delivery service.
 
2 1 0 12
Monday Order  4 2 1 0 
1 1 1 6
If we also know the following prices for the items:
Milk $1.00
Bread $3.00
Butter $5.00
Eggs $0.30
which we can write as a matrix:
 
1
 3 
 
 5 
0.3
Joshua Capel (UNSW) Matrix Algebra 16 / 21
Matrix Multiplication
Then we can easily calculate
Customer A’s Bill = 2×1 +1×3 + 0×5 + 12×0.3 = 8.6
Customer B’s Bill = 4×1 + 2×3 + 1×5 + 0×0.3 = 15
Customer C’s Bill = 1×1 + 1×3+ 1×5 + 6×0.3 = 10.8
and write the result as a matrix:
 
8.6
 15 
10.8

So we have combined matrices:




  1  
2 1 0 12  8.6
 4 2 1 0   3  =  15 

 5 
1 1 1 6 10.8
0.3

Joshua Capel (UNSW) Matrix Algebra 17 / 21


We did multiplication of a row of the first matrix with the column of the
second matrix three times. For instance, the first time:
 
1
 3  
2 1 0 12   5 
 = 8.75

0.3

This is called MATRIX MULTIPLICATION.


The order and sizes of the matrices in multiplication is important.

(1 × 4) (4 × 1) = (1 × 1)

Joshua Capel (UNSW) Matrix Algebra 18 / 21


Matrix Multiplication

Multiplication of Matrices is the combining together of a


row and a column by multiplying the two 1st entries, multiplying the two
2nd entries and so on and then
adding these to give one entry in the product.

Example.
 
 1
2 1 3  1  = 2 × 1 + 1 × 1 + 3 × 4 = 15
4

Joshua Capel (UNSW) Matrix Algebra 19 / 21


Matrix Multiplication

If the matrices contain many rows and columns then each row is paired
with each column:
Example.  
  1 2 1
2 1 3 
1 1 5 
1 4 2
| {z } 4 3 2
2×3 | {z }
3×3
 
2×1+1×1+3×4 2×2+1×1+3×3 2×1+1×5+3×2
= 1×1+4×1+2×4 1×2+4×1+2×3 1×1+4×5+2×2
| {z }
2×3
 
15 14 13
=
13 12 25
| {z }
2×3

Joshua Capel (UNSW) Matrix Algebra 20 / 21


Matrix Multiplication

Example.
  
1 3 −1 0
=
2 4 1 −1
| {z } | {z }
2×2 2×2

 
  −1 0
1 3 
1 −1  is undefined because
2 4
2 3

Joshua Capel (UNSW) Matrix Algebra 21 / 21

You might also like