W2 Lesson 2 - Matrices - Module
W2 Lesson 2 - Matrices - Module
1
Matrices
Module 02 Matrices
Matrix
A matrix is a rectangular array of elements (either numbers or symbols), which are
arranged in rows and columns. Figure 1 shows an example of a matrix.
Column 1
A matrix is denoted by an uppercase letter. The entries inside the bracket are called
the elements, in this example, denoted by the lowercase letter. Each element has a
unique address, in this example denoted by its letter and subscript aij (for i = 1, 2, …
m and j = 1, 2, …n) . The element a21 (simply read as “a two-one”), is located at row 2,
column 1The order of the subscript is described by row first then column address.
The size of the matrix is determined by the dimension of the matrix. In this example,
A is an m by n or (m x n) matrix.
Course Module
A matrix that has the same number of columns as rows is called a square matrix. In
this case where m = n, all the elements in a11, a22, a33 up amn is called the main
diagonal.
Example
3 0.5 2
B=[ 2 1 0.75]
−1 0 1.5
1. B is a 3 by 3 matrix.
2. B is a square matrix.
3. The element at row 2 column 3 (or simply “two-three”) is 0.75.
Types of Matrices
Below are the types of matrices that could represent values .
1. Row vector is a special type of matrix which has only one row. A row vector is a
1 x n matrix. It is denoted by a boldface lowercase letter.
Example
f = fi = [ f1 f2 f3]
2. Column vector is another special type of matrix which has only one column. A
column vector is a n x 1 matrix. It is also denoted by a boldface lowercase letter.
Example
𝑔1
𝑔2
g = gj = [𝑔 ]
3
𝑔4
Example
𝑎11 𝑎12
H = [𝑎 𝑎22 ]
21
H is a 2 x 2 square matrix.
4. Diagonal matrix is a square matrix with all elements equal to zero except the
elements in the main diagonal.
Example
𝑎11 0 0
K=[ 0 𝑎22 0 ]
0 0 𝑎33
K is a diagonal matrix.
5. Identity matrix is a matrix whose diagonal elements are equal to 1 and the rest
equal to 0.
Example
1 0 0 0
0 1 0 0
I=[ ]
0 0 1 0
0 0 0 1
6. Triangular matrix is a square matrix in which all of the elements on one side of
the main diagonal are zero. The remaining elements may be zero or not. If the
elements below the main diagonal are all zero, the matrix is called the upper
triangular matrix. If the elements above the main diagonal matrix are all zero,
the matrix is called the lower triangular matrix.
Example
𝑎11 𝑎12 𝑎13 𝑎14
0 𝑎22 𝑎23 𝑎24
U= [ 0 0 𝑎33 𝑎34 ]
0 0 0 𝑎44
Arithmetic of Matrices
Arithmetic of matrices involves operations such as matrix addition, subtraction and
multiplication. An operation called the inverse of a matrix is used in place of the
matrix division since division of matrices is not defined.
2 −2 5
A+B=[ ]
1 3 4
Subtraction of matrices is just as easy, just check on the signs (positive or negative)
to avoid human error.
Example
Find A - B.
2 4 1
A-B=[ ]
−3 1 0
Matrix Multiplication
Numerical Methods
5
Matrices
Example
Find 3A.
2 1 3
A=[ ]
−1 2 4
The answer is just a scaled version of A which is simply 3 multiplied by each
element of A.
6 3 9
3A = [ ]
−3 6 12
Multiplication of matrices
The first thing that must be checked when trying to multiply two matrices is that,
the number of column of the first matrix should be equal to the number of the rows
of the second matrix.
Example
Find AB.
1 2
2 1
A = [1.5 0] ; B = [ ]
0.5 −1
−1 3
Again, check if the number of columns of the first matrix, is the same as the numbers
of rows in the second. Since A is a 3 x 2 matrix and B is a 2 x 2 matrix, therefore,
matrix multiplication may proceed. Each element of the column will be multiplied to
the corresponding row then added. Matrix multiplication would be demonstrated
below.
The resulting dimension of the product of the two matrices is the product of the row
and column of the first and second matrices, respectively which is illustrated in
Figure 2 below.
Course Module
3x2 2x2
1 3
2 1
A = [1.5 0] ; B = [ ]
0.5 −1
−1 3
(1 ∗ 2) + (3 ∗ 0.5) (1 ∗ 1) + (3 ∗ (−1))
AB = [(1.5 ∗ 2) + (0 ∗ 0.5) (1.5 ∗ 1) + (0 ∗ −1) ]
(−1 ∗ 2) + (3 ∗ 0.5) (−1 ∗ 1) + (3 ∗ −1)
Inverse of a Matrix
Suppose a matrix A is given as
𝑎11 𝑎12
A =[𝑎 𝑎22 ]
21
𝑎22 −𝑎12
A -1= [−𝑎 𝑎11 ]
21
It is important to note the requirements for the size of the matrix to perform
certain operations. In matrix addition and subtraction, the dimension of the
matrices should be the same; otherwise, the operations cannot be performed.
Multiplying matrices, the columns and rows must be checked first before
trying to proceed with element by element multiplication, otherwise, the
operations cannot be performed
Determinants of a Matrix
Determinants are mathematical objects that are very useful in the analysis and
solution of systems of linear equations. Determinants are defined only for square
matrices.
The determinant can be illustrated for a set of three linear equations given as
𝑎11 𝑥 + 𝑎12 𝑦 + 𝑎13 𝑧 = 0
𝑎21 𝑥 + 𝑎22 𝑦 + 𝑎23 𝑧 = 0
𝑎31 𝑥 + 𝑎32 𝑦 + 𝑎33 𝑧 = 0
The determinant D of this system is formed from the coefficients of the equation, as in
𝑎11 𝑎12 𝑎13
D = |𝑎21 𝑎22 𝑎23 |
𝑎31 𝑎32 𝑎33
Notice that the notation uses as symbol | | which is also similar to the symbol of absolute
value. Although the elements of both the coefficient matrix and determinant are the same,
the mathematical concept of the two is different.
𝑎11 𝑎12
D = |𝑎 𝑎22 |
21
is computed by
D = 𝑎11 𝑎22 - 𝑎12 𝑎12
Course Module
For the third-order case, or a 3 x 3 matrix,
𝑎22 𝑎23 𝑎21 𝑎23 𝑎21 𝑎22
D =𝑎11 |𝑎 | - 𝑎12 | | + 𝑎13 | 𝑎32 |
32 𝑎33 𝑎31 𝑎33 𝑎31
For a 2 x 2 matrix
𝑎11 𝑎12
D = |𝑎 𝑎22 |
21
The blue arrow which starts from a11 going downward right to a22 is positive and the red
arrow which starts from a12 going downward left to a22 is negative giving,
D = 𝑎11 𝑎22 - 𝑎12 𝑎12
For a 3 x 3 matrix
𝑎11 𝑎12 𝑎13
D = |𝑎21 𝑎22 𝑎23 |
𝑎31 𝑎32 𝑎33
Again blue arrows signify the positive and red ones negative.
𝑎11 𝑎12 𝑎13
D=| 𝑎22 𝑎23 | - |𝑎 21 𝑎23 | + |𝑎21 𝑎22 |
𝑎32 𝑎33 𝑎31 𝑎33 𝑎31 𝑎32
Distribute the value of a11, a12 and a13 for their respective matrices and perform the usual
operation for finding the determinant of a 2 x2 matrix as denoted by the | | sign.
Notice that those elements in the row and column of a11. The same goes to a12 and a13. The
operation between the matrices also takes an alternate sign of positive and negative. The
pattern will continue to any square matrix.
Example
2 −1 3
D = |6 1 4|
5 2 1
Numerical Methods
9
Matrices
Solution
1 4 6 4 6 1
D =2 | | - (−1) | | + 3| |
2 1 5 1 5 2
Course Module
The Editors of Encyclopædia Britannica. Matrix. Encyclopædia Britannica. Encyclopædia
Britannica, inc. January 16, 2017. https://www.britannica.com/topic/matrix-
mathematics. 05 August 2017
Matrices and Arrays.https://www.mathworks.com/help/matlab/learn_matlab/matrices-
and-arrays.html. Date accessed: September 27, 2017