Matrices
Matrices
39
40 MODULE 2. MATRICES AND ITS APPLICATIONS
2.1.1 Matrix
A matrix (plural matrices) is a rectangular array of numbers, symbols, or ex-
pressions, arranged in m rows and n columns is called an m × n matrix or m
by n matrix, where m and n are called the matrix dimensions. Also, we can
denote a matrix using a capital letter usually from the English alphabet. Below
is an illustration of an m × n:
Matrix Dimensions
The dimensions of a matrix tells its size based on the number of rows and
columns of the said matrix. For example, the size of the matrix above is m × n.
Just remember that when working with matrix dimension it should be rows ×
columns.
Example 1. What are the dimensions of matrix A?
1 2 3
A=
0 5 6
Solution:
The number of rows and columns of matrix A are 2 and 3, respectively. Thus,
matrix A is a 2 × 3 matrix.
−1 3
2.1. INTRODUCTION TO MATRICES 41
Solution:
The number of rows and columns of matrix B are 4 and 2, respectively. Thus,
matrix B is a 4 × 2 matrix.
Matrix Elements
The entries that appear in the rows and columns of a matrix are called elements
of a matrix. Each element in a matrix is identified by naming the row (i) and
column (j) in which it appears.
Example 3. Consider the matrix C, identify the element in a13 .
1 2 4
C = 0 5 1
1 −2 0
Solution:
The element in a13 is the entry in the 1st row and 3rd column, i.e. i = 1 and
j = 3. Thus, a13 = 4.
Example 4. Consider a 3 × 2 matrix D and a21 = 4. Construct the matrix
that satisfies the given conditions.
Solution:
The matrix D is a 3 × 2 matrix then it must have two rows and three columns.
Also, the matrix must have an entry of 4 in the 2nd row and 1st column,
a21 = 4. Thus, it may correspond to the matrix below:
1 0 2
C=
4 5 1
(Note: There could be infinitely many matrices that can satisfy the given
conditions in this example.)
Types of Matrices
Some of the types of matrices that will be enumerated here will be discussed in
a more detailed manner in the succeeding topics in this reference.
1. Row Matrix
A matrix having only one row is called a row matrix. Generally the size
of this matrix is 1 × n as illustrated below:
a11 a12 a13 ··· a1n
2. Column Matrix
A matrix having only one column is called a column matrix. Generally
the size of this matrix is m × 1 as illustrated below:
42 MODULE 2. MATRICES AND ITS APPLICATIONS
a11
a21
a31
..
.
am1
3. Zero/Null Matrix
A matrix whose entries or elements are all zero is called zero or null
matrix. Zero matrices play a similar role in operations with matrices
as the number zero plays in operations with real numbers. Also, zero
matrices is usually denoted by O from the English alphabet. Below is an
illustration of general form for a zero matrix:
011 012 ··· 01n
021 022 ··· 02n
Omn = .
.. .. ..
.. . . .
0m1 0m2 ··· 0mn
4. Singleton Matrix
A matrix with only one element or entry is called a singleton matrix. The
size of this matrix is 1 × 1 as illustrated below
a11
5. Vertical Matrix
An m × n matrix is called a vertical matrix if the number of rows ex-
ceeds the number of columns, i.e. m > n. An example of this matrix is
illustrated below:
1 0
4 5
2 3
6. Horizontal Matrix
An m × n matrix is called a horizontal matrix if the number of columns
exceeds the number of rows, i.e. m < n. An example of this matrix is
illustrated below:
1 0 1
4 5 2
7. Square Matrix
A matrix with the same number of rows and columns, i.e. m = n is called
2.1. INTRODUCTION TO MATRICES 43
a11 a12 ··· a1n
a21
a22 ··· a2n
.. .. .. ..
. . . .
an1 an2 ··· ann
8. Diagonal Matrix
A square matrix where all the entries outside the main diagonal are all
zero, i.e. aij =0 for i 6= j, is called a diagonal matrix. Below is an
illustration of the general form for a diagonal matrix:
a11 0 ··· 0
0
a22 ··· 0
.. .. .. ..
. . . .
0 0 ··· ann
9. Scalar Matrix
A diagonal matrix where all the entries in the main diagonal are equal,
i.e. a11 = a22 = a33 = · · · = ann , is called a scalar matrix. An example
of a scalar matrix is illustrated below:
2 0 0
0 2 0
0 0 2
111 0 ··· 0
0 122 ··· 0
Inn = .
.. .. ..
..
. . .
0 0 ··· 1nn
a11 a12 ··· a1n
0
a22 ··· a2n
.. .. .. ..
. . . .
0 0 ··· ann
The variables we have in the linear system are x and y . So we can write the
variable matrix as
x
.
y
Finally, the constant matrix whose elements are the constant terms is
2
.
−1
x − 2y = 2
3x − y = −1
Augmented Matrix
An augmented matrix is a matrix form obtained by joining the columns of two
or more matrices having the same number of rows. In this, section we will
use an augmented to solve linear systems by joining the coefficient matrix and
constant matrix. To illustrate,
1 −2 2
3 −1 −1
is the augmented matrix by joining the coefficient matrix and constant matrix
of the linear system
x − 2y = 2
3x − y = −1
Example 1. Write the linear system below as an augmented matrix.
2x − 2y + z = 2
3x − y − z = −1
x + 2y + 3z = 5
Solution:
First, let us build for the coefficient matrix and constant matrix. We have the
coefficient matrix below:
2 −2 1
3 −1 −1
1 2 3
and the constant matrix is
2
−1 .
5
Finally, we have the augmented matrix below by joining the two matrices above:
2 −2 1 2
3 −1 −1 −1 .
1 2 3 5
Solution:
To give us a clearer picture of the linear system, let’s rewrite the system to
show each of the coefficients clearly.
x + 0y + z = 1
3x − y + 0z = −1
−x + 2y − 3z = 2
Next, let us build for the coefficient matrix and constant matrix. We have the
coefficient matrix below:
1 0 1
3 −1 0
−1 2 −3
Finally, we have the augmented matrix below by joining the two matrices above:
1 0 1 1
3 −1 0 −1 .
−1 2 −3 2
Solution:
1. Interchange the first equation and second equation.
3 −1 0
1 Notation
0 1
R1 ↔ R2
−1 2 −3
3. Add 3 times the first row to the third row to produce a new third row.
1 0 1
Notation
3 −1 0 0
3R1 + R3 = R3
2 2 0
2.1. INTRODUCTION TO MATRICES 49
Example 2. Using elementary row operations, solve the linear system below:
4a + 2b − 6c = 4
2a + b − 3c = 2
a+b−c=1
Solution:
First, let us set-up the augmented matrix from the given linear system. We
have,
4 2 −6 4
2 1 −3 2
1 1 −1 1
Now, apply a finite sequence of elementary row operations starting from the
augmented matrix above.
1 1 −1 1
2 1 −3 2 R1 ↔ R3
4 2 −6 4
1 1 −1 1 0
0 −1 −1 0 −2R1 + R2 = R20
0 −2 −2 0 −4R1 + R3 = R3
1 1 −1 1
0
0 1 1 0 −1R2 = R2
0 −2 −2 0
1 0 −2 1 0
0 2R2 + R3 = R3
1 1 0 0
0 0 0 0 −1R2 + R1 = R1
Solution:
First, let us set-up the augmented matrix from the given linear system. We
have,
4 2 −6 5
2 1 −3 2
1 1 −1 1
Now, apply a finite sequence of elementary row operations starting from the
augmented matrix above.
1 1 −1 1
2 1 −3 2 R1 ↔ R3
4 2 −6 5
1 1 −1 1 0
0 −1 −1 0 −2R1 + R2 = R20
0 −2 −2 1 −4R1 + R3 = R3
1 1 −1 1
0
0 1 1 0 −1R2 = R2
0 −2 −2 1
1 0 −2 1 0
0 2R2 + R3 = R3
1 1 0 0
0 0 0 1 −1R2 + R1 = R1
We get a result of 0 = 1 from row 3 which is false, this implies that the given
linear system has no solution.
Example 4. Using elementary row operations, solve the linear system below:
x+y+z =6
2y + 5z = −4
2x + 5y − z = 27
Solution:
First, let us set-up the augmented matrix from the given linear system. We
have,
2.1. INTRODUCTION TO MATRICES 51
1 1 1 6
0 2 5 −4
2 5 −1 27
Now, apply a finite sequence of elementary row operations starting from the
augmented matrix above.
1 1 1 6
0 2 5 −4 − 2R1 + R3 = R30
0 3 −3 15
1 1 1 6
0 2 5 −4 1 R3 = R30
3
0 1 −1 5
1 1 1 6
0 1 −1 5 R2 ↔ R3
0 2 5 −4
1 0 2 1 0
0 1 −1 −1R2 + R1 = R1
5 0
0 0 7 −14 −2R2 + R3 = R3
1 0 2 1
1 0
0 1 −1 5 R3 = R3
0 0 1 −2 7
1 0 0 5 0
0 1 R3 + R2 = R2
0 3 0
0 0 1 −2 −2R3 + R1 = R1
Solution:
2. The given matrix is in reduced row echelon form as it satisfies all its
conditions. Thus, it is also a row echelon form.
3. This matrix is neither row echelon form nor reduced row echelon form as
it does not satisfy a condition that all leading entries must be 1 as seen
in row 2.
2.1. INTRODUCTION TO MATRICES 53
Exercises
A. Consider the matrices below:
1 2 0
1 2 −1 1 2
A= B =3 −1 7 C=
2 −11 5 2 −1
11 0 5
2 3 12 5 1
D = 8 1 E = 2 −1 −3
−1 4 7 −6 4
Identify the following ij-entries:
1. a11 , a13 , a22
2. b13 , b21 , b32
3. c12 , c21 , c22
4. d11 , d22 , d32
5. e12 , e22 , e23
B. True or False. Write T if the statement is true, otherwise write F. If you
answered false, justify your answer.
1. If there are t rows and s columns in the matrix then order of matrix is
s × t.
2. A matrix in which number of rows and number of columns are equal is
said to be a square matrix.
3. The individual quantities like a11 , a21 , a13 , · · · , amn are called the coeffi-
cients of the matrix.
4. The matrix is denoted by small letters like a, b and c.
5. All identity matrices are also scalar matrices.
6. A matrix in which there is only one column and any number of rows is
said to be a column matrix.
7. An n × n matrix is called upper triangular if aij = 0 when i < j.
8. If all the elements of matrix are 1 is known as a unit matrix.
54 MODULE 2. MATRICES AND ITS APPLICATIONS
D. Computations. Solve the following linear systems completely and show all
necessary solutions.
x1 − 3x2 − 5x3 = −1
−2a − 4b + c = −2
x + 4y − z = 2
1. 3x1 − x3 = −2 3. 2a + 2b − c = 4 5. 2x − 2y + 3z = 3
−x1 − 2x2 − 3x3 = 1 a − 3b − 2c = 1 x − y + 2z = 1
3w − 3x − 4y − 2z
=2
x1 − 3x2 + 5x3 = −1
−w + 2x − 3y + 3z
=0
2. 2x1 − x2 − 3x3 = 2 4.
2w − 2x + y − 2z =1
−x1 − 2x2 + 3x3 = 1
+ y − 2z = −1
w
Challenge Yourself
Is row echelon form of a matrix unique? Justify your answer and give an
example to support your explanation.
Solution:
1 2 0 1 2 0 1 0 1
1. (B + D) + E = 2 −1 1 + 3 0 1 + 2 1 −3
11 0 1 0 −1 4 1 −1 4
(1 + 1) + 1 (2 + 2) + 0 (0 + 0) + 1
= (2 + 3) + 2 (−1 + 0) + 1 (1 + 1) + (−3)
(11 + 0) + 1 [0 + (−1)] + (−1)] (1 + 4) + 4
2+1 4+0 0+1 3 4 1
=5+2 −1 + 1 2 + (−3) = 7 0 −1 .
11 + 1 −1 + (−1) 5+4 12 −2 9
1+2 2+2 0+1 3 4 1
=2+5 −1 + 1 1 + (−2) = 7 0 −1 .
11 + 1 0 + (−2) 1+8 12 −2 9
3 4 1
7 0 −1 .
12 −2 9
3.
1 2 1 2 (1 + 1) (2 + 2) 2 4
A+C = 2 −11+ 2 −1 = (2 + 2) −11 + (−1) = 4 −12
0 3 11 0 (0 + 11) (3 + 0) 11 3
2 4
4 −12 .
11 3
4.
1 2 1 2 (1 + 1) (2 + 2) 2 4
C+A = 2 −1+2 −11 = (2 + 2) −1 + (−11) = 4 −12
11 0 0 3 (11 + 0) (0 + 3) 11 3
1. A + B = B + A
2. A + (B + C) = (A + B) + C
3. There is unique m × n matrix O such that
A+O =O+A=A
A+D =D+A=O
Proof.
Next,
2 4 −1 2(−1) + 4(3) 10
(A + B)C = = =
4 1 3 4(−1) + 1(3) −1
10
Thus, (A + B)C = .
−1
2. Both A and B are 2 × 2 matrices, then A + B is defined and is a 2 × 2
matrix. But C is a 2 × 1 matrix. Thus, C(A + B) is not defined under
matrix multiplication.
1. (AB)C = A(BC)
2. (A + B)C = AC + BC
3. C(A + B) = CA + CB
Proof.
Solution:
1 2 0 2(1) 2(2) 2(0) 2 4 0
1. 2A = 2 2 −1 1 = 2(2) 2(−1) 2(1) = 4 −2 2
0 3 1 2(0) 2(3) 2(1) 0 6 2
1 2 0 −1(1) −1(2) −1(0) −1 −2 0
2. −1B = −1 2 −1 1 = −1(2) −1(−1) −1(1) = −2 1 −1
1 0 1 −1(1) −1(0) −1(1) −1 0 −1
3. From (2) −1B = −B,we have
1 2 0 −1 −2 0
A − B = A + (−B) = 2 −1 1 + −2 1 −1
0 3 1 −1 0 −1
1 + (−1) 2 + (−2) 0+0 0 0 0
= 2 + (−2) −1 + 1 1 + (−1) = 0 0 0
0 + (−1) 3+0 1 + (−1) −1 3 0
3. r(A + B) = rA + rB
4. A(rB) = r(AB) = (rA)B
Proof.
1. Let A = [ai ] and r,s be any real numbers. Further, the ij-entry of sA is
saij . So, the ij-entry of r(sA) is r(saij ) and by the associative property of
real numbers (r(saij ) = (rs)aij , where (rs)aij is the ij − entry of (rs)A.
Thus, r(sA) = (rs)A.
2. Let A = [aij ] and r,s be any real numbers. Further, the ij-entry of
(r + s)A is (r + s)aij . By the distributive property of real numbers,
(r + s)aij = raij + saij , where raij + saij is the ij-entry of rA + sA.
Hence, (r + s)A = rA + sA.
2.2. OPERATIONS ON MATRICES 61
Proofs for the remaining scalar multiplication properties are left as an exercise.
Exercises
A. Let
1 2 1 −2 0
1 2
A = 2 −11 B = 2 −1 1 C=
2 −1
0 3 1 0 1
1 2 0 1
D = 3 0 1 E = 0
0 −1 4 −1
1 6. BA
1. BD − B
2
2. BE 7. DA + BA
3. DB 8. −3DE
4. B 2 + 2D 9. BE − DE
5. AC 3 10. E(B + D)
4. How do the results in parts (2) and (3) change when the diagonal entries
of B are all equal?
Challenge Yourself
Show that no 2 × 2 matrices A and B exist that satisfy the matrix equation
1 0
AB − BA = .
0 1
62 MODULE 2. MATRICES AND ITS APPLICATIONS
Solution:
T
1
1. AT = 2 = 1 2 0
0
T 1 2
T 1 2 0
2. B = = 2 1
2 1 1
0 1
T
1 3 1 2
3. C T = =
2 −1 3 −1
T 1
4. DT = 1 2 0 = 2
0
T
1 2
T 1 0 1
5. E = 0
−1 =
2 −1 −1
1 −1
2.3. TRANSPOSE OF A MATRIX 63
1. (AT )T = A
2. (A + B)T = AT + B T
3. (AB)T = B T AT
4. (rA)T = rAT
Proof.
1. Let A be an m × n matrix. The ij-entry of AT is the ji-entry of A, then
the ij-entry of (AT )T is the ji-entry of AT , which is the ij-entry of A.
Thus, (AT )T = A.
2. Let A and B be both m × n matrices. The ij-entry of AT + B T is the
sum of ij-entries of AT and B T , which are the ji-entries of A and B,
respectively. Thus, the ij-entry of AT + B T is the ji-entry of the sum
of A and B which is equal to the ij-entry of the transpose of A + B.
Therefore, (A + B)T = AT + B T .
Proofs for the remaining properties of the transpose of a matrix are left as an
exercise.
Example 2. Let
1 2 1 1 3
A= B= C=
−2 0 2 0 1
Solve:
1. (AB)T 3. 2B T
2. AT + C T 4. A + B T
Solution:
T T
T 1 2 1 5
1. (AB) = = = 5 −2
−2 0 2 −2
T T
1 2 1 3 1 −2 1 0 2 −2
2. AT + C T = + = + =
−2 0 0 1 2 0 3 1 5 1
T
T 1
3. 2B = 2 =2 1 2 = 2 4
2
64 MODULE 2. MATRICES AND ITS APPLICATIONS
Exercises
A. Consider s = 2, t = −1 and
1 2 3 1 1 3 1
A = −2 0 1 B = 2 C = 0 1 0 .
1 2 −1 3 2 1 −2
Solve:
1. (sAtB)T 3. stB T
2. sAT + tC T 4. A − C T
Solution:
Show that AB = I2 = BA. We have,
2 5 3 −5 2(3) + 5(−1) 2(−5) + 5(2) 1 0
AB = = = = I2
1 3 −1 2 1(3) + 3(−1) 1(−5) + 3(2) 0 1
3 −5 2 5 3(2) + (−5)(1) 3(5) + (−5)(3) 1 0
BA = = = = I2
−1 2 1 3 −1(2) + 2(1) −1(5) + 2(3) 0 1
a+c=1 b+d=1
2a + c = 0 2b + d = 0
Let A be an n × n matrix.
1. Create a partitioned matrix A I , i.e. adjoining matrix I to
matrix A.
2. Perform Gauss-Jordan Elimination on the partitioned matrix with
the objective of converting the first part of the matrix to reduced
row echelon form. The result will be the matrix I A−1 . If
1 2 1
Example 3. Find the inverse of A = 0 2 1.
1 1 0
Solution:
0 0 −1 −2 1 2 −2R2 + R3 = R3
1 0 −1 −1 0 2
0
0 1 1 1 0 −1 −R3 = R3
0 0 1 2 −1 −2
1 0 0 1 −1 0 0
0 1 0 −1 1 −R3 + R2 = R2
1 0
0 0 1 2 −1 −2 R3 + R1 = R1
2.4. INVERSE OF A MATRIX 67
1 −1 0
Thus, A−1 = −1 1 1 . To check, we have
2 −1 −2
1 2 1 1 −1 0
AA−1 = 0 2 1 −1 1 1
1 1 0 2 −1 −2
1(1) + 2(−1) + 1(2) 1(−1) + 2(1) + 1(−1) 1(0) + 2(1) + 1(−2)
= 0(1) + 2(−1) + 1(2) 0(−1) + 2(1) + 1(−1) 0(0) + 2(1) + 1(−2)
1(1) + 1(−1) + 0(2) 1(−1) + 1(1) + 0(−1) 1(0) + 1(1) + 0(−2)
1 0 0
= 0 1 0
0 0 1
1 −1 0 1 2 1
A−1 A = −1 1 1 0 2 1
2 −1 −2 1 1 0
1(1) + (−1)(0) + 0(1) 1(2) + (−1)(2) + 0(1) 1(1) + (−1)(1) + 0(0)
= −1(1) + 1(0) + 1(1) −1(2) + 1(2) + 1(1) −1(1) + 1(1) + 1(0)
2(1) + (−1)(0) + (−2)(1) 2(2) + (−1)(2) + (−2)(1) 2(1) + (−1)(1) + (−2)(0)
1 0 0
= 0 1 0
0 0 1
1 −1 0
Indeed, A−1 = −1 1 1 .
2 −1 −2
−1 −2
Example 4. Find the inverse of B = .
1 2
Solution:
Using the Gauss-Jordan elimination method to solve for the inverse matrix of
B, we have
−1 −2 1 0
1 2 0 1
1 2 0 1
R1 ↔ R2
−1 −2 1 0
1 2 0 1 0
R1 + R2 = R2
0 0 1 1
68 MODULE 2. MATRICES AND ITS APPLICATIONS
3. (A−1 )−1 = A
4. (Ak )−1 = (A−1 )k
1 −1
5. (rA)−1 = A
r
Proof.
Proofs for the remaining properties of matrix inverse are left as an exercise.
1. If AC = BC, then A = B.
2. If CA = CB, then A = B.
Proof. 1.
AC = BC
(AC)C −1 = (BC)C −1
A(CC −1 ) = B(CC −1 )
AIn = BIn
A=B
2.4. INVERSE OF A MATRIX 69
2.
CA = CB
−1
C (CA) = C −1 (CB)
(C −1 C)A = (C −1 C)B
In A = In B
A=B
Solution:
1 2 4
The coefficient matrix is A = 2 1 1. Using Gauss-Jordan elimination,
1 1 2
−1 0 2
A−1 = 3 2 −7 (Note: The solution in finding A−1 is left as an exer-
−1 −1 3
cise). Now,
−1 0 2 −1 −1(−1) + 0(2) + 2(1) 3
x = A−1 b = 3 2 −7 2 = 3(−1) + 2(2) + −7(1) = −6
−1 −1 3 1 −1(−1) + −1(2) + 3(1) 2
Solution:
1. The given matrix is elementary. To obtain the matrix from I3 , interchange
the first row and third row.
2. Since the given matrix is not a square, the given matrix is not elementary.
3. The given matrix is not elementary. The given matrix was obtained by
multiplying 0 to the second row. A row must be multiplied by a nonzero
scalar to obtain an elementary matrix.
4. The given matrix is elementary. To obtain the given matrix from I2 ,
multiply the second row by −2.
Theorem 2.4.4. Let E be an elementary matrix obtained by performing an
elementary row operation on In . If the same elementary row operation is per-
formed on an m × n matrix A, then the resulting matrix is equal to EA.
Solution:
1 0 −1 1 1 0 0
0
0 −1 2 1 − 2R1 + R3 = R3 0 1 0 = E1
0 2 3 −2 −2 0 1
1 0 −1 1 1 0 0
0
0 1 −2 −1 − R2 = R2 0 −1 0 = E2
0 2 3 −2 0 0 1
1 0 −1 1 1 0 0
0
0 1 −2 −1 − 2R2 + R3 = R3 0 1 0 = E3
0 0 7 0 0 −2 1
1 0 −1 1
1 0 0
1
R3 = R3 0 1 0 = E
0
0 1 −2 −1 4
7 1
0 0 1 0 0 0
7
Let B an m × n matrix, where B = E4 E3 E2 E1 A. We have
1 0 0 1 0
0 1 0 0
1
0 0 1 0 −1 1
0 1 0 0
B= 1 0 0 −1 0 0 1 0 0 −1 2 1
1
0 0 0 −2 1 0 0 1 −2 0 1 2 2 1 0
7
1 0 −1 1
= 0 1 −2 −1
0 0 1 0
Solution:
1 3 0 1 0
− R1 + R2 = R2 = E1
0 −1 −1 1
1 3 0 1 0
− R2 = R2 = E2
0 1 0 −1
72 MODULE 2. MATRICES AND ITS APPLICATIONS
1 0 0 1 −3
− 3R2 + R1 = R1 = E3
0 1 0 1
2.4.2 LU Decomposition
If an n × n matrix A can be written as the product of a lower triangular matrix
L and an upper triangular matrix U , then A = LU is an LU decomposition of
A.
1 −3
Example 1. Find an LU decomposition of the matrix A, A = .
1 1
Solution:
We begin by applying elementary row operations to matrix A to find an upper
triangular matrix which is row equivalent to matrix A.
1 −3 0 1 0
− R1 + R2 = R2 = E1
0 4 −1 1
1 0
Thus, E1 A = U =⇒ A = E1−1 U , where L = E1−1 . Also, E1−1 =
1 1
(Note: Getting the inverse of E1 is left as an exercise). Therefore, the LU
decomposition of matrix A is
1 0 1 −3
A = LU = .
1 1 0 4
1 2 2
Example 2. Find an LU decomposition of the matrix B, B = 0 −1 2.
1 3 1
Solution:
We begin by applying elementary row operations to matrix B to find an upper
triangular matrix which is row equivalent to matrix B.
1 2 2 1 0 0
0
0 −1 2 − R1 + R3 = R3 0 1 0 = E1
0 1 −1 −1 0 1
2.4. INVERSE OF A MATRIX 73
1 2 2 1 0 0
0
0 −1 2 R2 + R3 = R3 0 1 0 = E2
0 0 1 0 1 1
1 2 2 1 0 0 1 0 0
We have now, U = 0 −1 2 and L = E1−1 E2−1 = 0 1 0 0 1 0 =
0 0 1 1 0 1 0 −1 1
1 0 0 1 0 0 1 2 2
0 1 0. Thus, B = LU = 0 1 0 0 −1 2.
1 −1 1 1 −1 1 0 0 1
Example 3. Solve the linear system below by LU decomposition.
x1 + 2x2 + 2x3 = 1
−x2 + 2x3 = −1
x1 + 3x2 + x3 = 1
Solution:
From Example 2 the LU decomposition of the coefficient matrix B,
1 0 0 1 2 2
B = LU = 0 1 0 0 −1 2. Now, let y = U x and solve the
1 −1 1 0 0 1
system Ly = b for y. We have,
1 0 0 y1 1
0 1 0 y2 = −1 From the matrix equation above, we have
1 −1 1 y3 1
y1 = 1
y2 = −1
y1 − y2 + y3 = 1
Using substitution method, y3 = −1. Thus, the solution for Ly = b is
back
1
y = −1. Next, solve the equation U x = y for x. We have,
−1
1 2 2 x1 1
0 −1 2 x2 = −1
0 0 1 x3 −1
Exercises
1. Find theinverse of the matrix, if it exists.
1 2 2 1 0 −1
(a) 1 −1 0 (c) 2 0 1
2 0 −1 1 0 2
−1 1 −1
1 2 (d) 2 3 1
(b)
4 −1 1 2 −2
(a) (c)
x + 2y + 2z = 1 −a + b + 2c = 2
x − y + 2z = −1 a − b + 3c = −3
x + 2y + z = 1 a − 2b + 4c = 1
(d)
(b)
a + 2b + 2c = 1 −x1 + x2 + 2x3 = 4
a − b + 2c = −1 x1 + x2 + 3x3 = −3
−2b + c = 1 x1 − x2 + 4x3 = 1
(a) (c)
3x + 2y + 2z = 1 −2x1 + x2 + 2x3 = 2
x − y + 2z = −1 x1 + x2 + 3x3 = −3
2x + 2y + z = 1 2x1 − 3x2 + 4x3 = 1
(b) (d)
2a + 3b + 2c = 1 −x1 + x2 + 2x3 = 4
a − 3b + 2c = −1 2x1 + x2 + 3x3 = −3
−2b − c = 3 x1 − x2 + 4x3 = 1
Challenge Yourself
1. Find invertible matrices A and B such that A + B is singular.
• Find the least squares regression line for a given set of data.
2.5.1 Cryptography
Cryptography or cryptology is a method of securing information and communi-
cations through the use of codes. An encrypted message written using a secret
code is called a cryptogram. One method of making cryptogram is using matrix
multiplication. To begin, assign a number to each letter of the English alphabet
as shown below:
A B C D E F G H I J K L M
1 2 3 4 5 6 7 8 9 10 11 12 13
N O P Q R S T U V W X Y Z
14 15 16 17 18 19 20 21 22 23 24 25 26
Solution:
First, write the uncoded message in a 1 × 3 matrix based on the assigned
numbers for each letter in the English alphabet.
G O O D _ M O R N I N G
7 15 15 4 0 13 15 18 14 9 14 7
Solution:
First, use Gauss-Jordan elimination to find A−1 . We have
−2 0 1
A−1 = 8 −1 −2
3 0 −1
(Note: Finding the inverse of A is left as an exercise.)
Next, to decode the message, partition the message into groups of three to form
a 1 × 3 matrices.
82 −15 97 43 0 30 93 −18 115 58 −14 79 .
To obtain the decoded row matrices, multiply each coded matrix by A−1 .
−2 0 1
82 −15 97 8 −1 −2 = 7 15 15
3 0 −1
−2 0 1
43 0 30 8 −1 −2 = 4 0 13
3 0 −1
−2 0 1
93 −18 115 8 −1 −2 = 15 18 14
3 0 −1
78 MODULE 2. MATRICES AND ITS APPLICATIONS
−2 0 1
58 −14 79 8 −1 −2 = 9 14 7
3 0 −1
G O O D _ M O R N I N G
7 15 15 4 0 13 15 18 14 9 14 7
For a set of points (x1 , y1 ), (x2 , y2 ), · · · , (xn , yn ) the least squares regression
line is the linear function f (x) = a0 + a1 x that minimizes the sum of squared
error [y1 − f (x1 )]2 + [y2 − f (x2 )]2 + · · · + [yn − f (xn )]2 .
For the regression model Y = XA+E, the coefficients of the least squares
regression line are given by the matrix equation, A = (X T X)−1 X T Y
and the sum of squared error is E T E.
Example 1. Find the least squares regression line for the points (0, 1), (1, 2),
and (2, 2).
Solution:
Now,
1 0
1 1 1 3 3
XT X = 1 1 =
0 1 2 3 5
1 2
and
2.5. MATRIX APPLICATIONS 79
1
1 1 1 5
XT Y = X = 2 =
0 1 2 6
2
5 1
−
6 2
Using Gauss-Jordan elimination, (X T X)−1 = . Now,
1 1
−
2 2
5 1 7
−
6 2 5 6
A = (X T X)−1 X T Y = 6 =
1 1 1
−
2 2 2
7 1
So, the least squares regression line is f (x) = + x and the graph is shown
6 2
below:
2.5 y
f (x)
2 (1,2) (2,2)
1.5
1 (0,1)
0.5
x
−2 −1 1 2
1 1 1 1
Thus, the sum of squared error is + + = ≈ 0.17.
36 9 36 6
Example 2. Find the least squares regression line for the points (0, 1), (1, 1),
(2, 2) and (3, 2).
80 MODULE 2. MATRICES AND ITS APPLICATIONS
Solution:
The matrices X and Y are
1 0 1
1 1 1
X= 1 2 and Y = 2
1 3 2
Now,
1 0
T 1 1 1 1
1 1= 4 6
X X=
0 1 2 3 1 2 6 14
1 3
and
1
1 1 1 1 = 6
1
XT Y = X =
0 1 2 3 2 11
2
7 3
−
10 10
Using Gauss-Jordan elimination, (X T X)−1 = . Now,
3 1
−
10 5
7 3 9
−
10 10 6 10
A = (X T X)−1 X T Y = 11 =
3 1 2
−
10 5 5
9 2
So, the least squares regression line is f (x) = + x and the graph is shown
10 5
below:
2.5 y f (x)
(2,2)
2 (3,2)
1.5
(0,1)
1 (1,1)
0.5
x
−4 −2 2 4
−0.5
Exercises
1. Encode the following messages:
(a) GOOD JOB
(b) GET WELL SOON
(c) SEE YOU SOON
(d) I LOVE YOU
(e) MEET ME AT CMALL
(f) GET WELL SOON
(g) HAPPY BIRTHDAY
(h) LET US MEET ON MONDAY
(i) THANK YOU
(j) BEST WISHES
2. Write down in sequence the steps in encoding the messages in number 1
and how to decode it.
3. Find the least squares regression line for the following set of points:
(a) (−1, 1), (0, 1), (1, 1), (3, 2)
(b) (−1, 1), (0, 1), (2, 1), (4, 2)
(c) (−1, 1), (0, 1), (1, 2), (2, 2), (3, 2)
(d) (−2, 1), (−1, 1), (0, 2), (1, 2), (3, 3)
(e) (−2, −1), (−1, 1), (0, −2), (1, 1), (2, 3)
(f) (2, −1), (3, 1), (4, −2), (5, 1), (7, 3)
82 MODULE 2. MATRICES AND ITS APPLICATIONS
4. Write down in sequence the steps in finding the least squares regression
line.