16 Matrix Algebra 1: Basic Operations
Tony U
University of Macau
Outline
1 Introduction to Matrices
2 Special Types of Matrices
3 Matrix Operations
4 Properties of Matrix Operations
5 Applications
6 Power of Matrix
Introduction to Matrices
Introduction to Matrices
A matrix is a rectangular array of elements. It
represented in the form:
a11 a12 a1n
a21 a22 a2n
A = ..
..
..
..
.
.
.
.
am1 am2
amn
is usually
where A is the matrix name and amn are the matrix elements.
-1-
Introduction to Matrices
aij represents the i th-row and jth-column element in the
matrix, sometimes we denote A = [aij ]
Dimension or size: the number of rows and columns in the
matrix. For example in the previous slide, the dimension of A
is m n (dim(A) = m n)
Main (leading) diagonal: Elements aii of the matrix
Equal matrix: all the corresponding elements (entries) in both
matrices are equal.
Transpose of a matrix: Transport of A, denoted by A or AT ,
is the n m matrix whose (i , j)th element is equal to aji .
Note (AT )T = A.
-2-
Special Types of Matrices
Special Types of Matrices
Row vector: A matrix with just one row
Column vector: A matrix with just one column.
Square matrix: A matrix having the same number of rows and
columns.
Identity matrix: A square matrix in which elements on the main
diagonal are all equal to 1 and all remaining entries
are zero. An identity matrix is also called a unit
matrix.
-3-
Special Types of Matrices
Zero matrix: All the elements in the matrix are 0.
Symmetric matrix: A square matrix A is said to be symmetric if it
is symmetric about the main diagonal, that is,
aij = aji . Obviously, A is symmetric AT = A.
Diagonal matrix: A square matrix is called a diagonal matrix if all
the elements off the main diagonal are 0.
Upper/Lower Triangular matrices: A square matrix A is said to be
an upper (lower) triangular matrix if all entries below
(above) the main diagonal are zero.
-4-
Special Types of Matrices
Example 1.
1 4
Given A = [aij ] = 2 0 .
3 6
a. Find a12 , a22 and a31 .
b. Find the transpose of A, AT . [Note that dim(A) = 3 2 while
dim(AT ) = 2 3.]
-5-
Special Types of Matrices
(a) Find a12 , a22 and a31 .
-6-
Special Types of Matrices
(a) Find a12 , a22 and a31 .
Sol.: a12 = 4, a22 = 0 and a31 = 3
(b) Find the transpose of A, AT .
-6-
Special Types of Matrices
(a) Find a12 , a22 and a31 .
Sol.: a12 = 4, a22 = 0 and a31 = 3
(b) Find the transpose of A, AT .
Sol.:
AT =
1 2 3
4 0 6
-6-
Matrix Operations
Matrix Operations
Addition and Subtraction
Two matrices A and B can be added or subtracted if they have
exactly the same dimensions.
A + B is calculated by adding corresponding elements.
A B is calculated by subtracting corresponding elements.
Scalar multiplication
If A = [aij ] is an m n matrix and k is a real number (also called a
scalar), then kA denotes the matrix [kaij ] .
-7-
Matrix Operations
Inner Product
The inner product of a 1 n row matrix A = [a1 a2 an ] and an
n 1 column matrix B = [b1 b2 bn ]T is
b1
b2
A B = [a1 a2 an ] .. = a1 b1 + a2 b2 + + an bn .
.
bn
Note: the row and column matrix should contain same number of
elements. The inner product is a real number.
-8-
Matrix Operations
Matrix multiplication
The matrix product of A and B, is a matrix whose element in the
i th row and jth column is the inner product of the i th row of
matrix A and the jth column of matrix B.
b1j
ai 1 ai 2 ain
cij
b2j
bnj
In the matrix product AB: then number of columns of A
should be equal to the number of rows of B.
If the dim(A) = a b and dim(B) = c d, the matrix product
AB is well defined if and only if b = c, the dim(AB) = a d.
-9-
Matrix Operations
Example 2 (Matrix Operations).
Let
A=
1 2
3 4
1 0
B = 2 3 ,
1 2
and
D=
1 2
1 2
C=
1 0 1
2 3 1
Find (i) 3A, (ii) A + B, (iii) A + D, (iv) AB and (v) AC .
-10-
Matrix Operations
Sol.: (i) Since 3A = [3aij ],
3A =
3 6
9 12
-11-
Matrix Operations
Sol.: (i) Since 3A = [3aij ],
3A =
3 6
9 12
(ii) Since dim(A) = 2 2 and dim(B) = 3 2, they dont have the
same dimensions, so A + B is undefined
-11-
Matrix Operations
Sol.: (i) Since 3A = [3aij ],
3A =
3 6
9 12
(ii) Since dim(A) = 2 2 and dim(B) = 3 2, they dont have the
same dimensions, so A + B is undefined
(iii)
A+C =
1+1 2+2
3+1 4+2
-11-
2 4
4 6
Matrix Operations
Sol.: (i) Since 3A = [3aij ],
3A =
3 6
9 12
(ii) Since dim(A) = 2 2 and dim(B) = 3 2, they dont have the
same dimensions, so A + B is undefined
(iii)
A+C =
1+1 2+2
3+1 4+2
2 4
4 6
(iv) Since the number of columns of A is not equal to the number
of rows of B, the matrix product AB is undefined
-11-
Matrix Operations
Sol.: (i) Since 3A = [3aij ],
3A =
3 6
9 12
(ii) Since dim(A) = 2 2 and dim(B) = 3 2, they dont have the
same dimensions, so A + B is undefined
(iii)
A+C =
1+1 2+2
3+1 4+2
2 4
4 6
(iv) Since the number of columns of A is not equal to the number
of rows of B, the matrix product AB is undefined
-11-
Matrix Operations
(v)
AC =
1 2
3 4
1 0 1
2 3 1
1 1 + 2 2 1 0 + 2 3 1 1 + 2 1
=
3 1 + 4 2 3 0 + 4 3 3 1 + 4 1
5 6 1
=
11 12 1
-12-
Properties of Matrix Operations
Properties of Matrix Operations
Assuming that all sums and products are defined, then:
1. Commutative law of matrix addition: A + B = B + A
2. Associative law of matrix addition: (A + B) + C = A + (B + C )
3. Associative law of matrix multiplication: A(BC ) = (AB)C
4. Left distribution law: A(B + C ) = AB + AC
5. Right distribution law: (B + C )A = BA + CA
6. k(AB) = (kA)B = A(kB)
-13-
Properties of Matrix Operations
Example 3.
Compute BC and CB if
2 1
B=
1 1
and
-14-
C=
3 1
2 2
Properties of Matrix Operations
Sol.:
3 1
2 2
BC =
2 1
1 1
23+12
2 1 + 1 2
1 3 + 1 2 1 1 + 1 2
CB =
3 1
2 2
3 2 + (1) (1) 3 1 + (1) 1
2 2 + 2 1
21+21
8 0
1 3
2 1
1 1
Note: BC 6= CB.
-15-
7 2
2 4
Applications
ApplicationsExample 4.
A grocery store carries three brands of detergent: Brand x, Brand
y and Brand z. The row matrix below represents the number of
units of each of these brands sold during the month of June.
Brand
Number of units
x
[100
y
500
z
300]
The column matrix below represents the unit selling price of each
brand:
$2
Brand x
P = $1 Brand y
$1.5
Brand z
Find the total sales revenue for all these products during the
month of June.
-16-
Applications
Sol.: The total sales revenue is the inner product of the row matrix
and column matrix:
2
[100 500 300] 1 = 100(2) + 500(1) + 300(1.5) = $1, 150
1.5
-17-
Applications
Example 5.
A company manufactures two models of a product: Model A and
Model B. Each model must pass through department I (Assembly)
and department II (Polishing). The unit time requirements (in
hours) for each model in each department are given by matrix T :
T =
Model
A
3
2
Model
B
5
1
Department I
Department II
The production requirements of each model are given by matrix P:
500
Model A
P=
700
Model B
Find the matrix that expresses the total time requirements for each
department
-18-
Applications
Sol.: The total time requirements for each department:
3 5
500
TP =
2 1
700
3(500) + 5(700)
=
2(500) + 1(700)
5, 000 (hrs)
Department I
=
1, 700 (hrs)
Department II
-19-
Power of Matrix
Power of Matrix
Given a square matrix A
An = |A A{z A} .
n
By default: A0 = I , where I is an identity matrix.
Moreover, (AT )n = (An )T for non-negative integer n.
-20-