2𝑥 + 𝑦 + 𝑧 = 180
𝑥 + 3𝑦 + 2 𝑧 = 300
2𝑥 + 𝑦 + 2𝑧 = 240
Chapter 2: Introduction to Matrices and Matrix algebra
2.1 Introduction:
Information in science, business, engineering and mathematics is often organized
into rows and columns to form rectangular arrays called “matrices” (plural of
“matrix”). Matrices often appear as tables of numerical data that arise from
physical observations, but they occur in various mathematical contexts as well. For
example, we will see in the coming chapters that all of the information required to
solve a system of linear equations such as
5𝑥 + 𝑦 = 3
2𝑥 − 𝑦 = 4
is embodied in the matrix
5 1 ⋮ 3
( )
2 −1 ⋮ 4
and that the solution of the system can be obtained by performing appropriate
operations on this matrix.
This is particularly important in developing computer programs for solving systems
of equations because computers are well suited for manipulating arrays of
numerical information.
However, matrices are not simply a notational tool for solving systems of
equations; they can be viewed as mathematical objects in their own right, and
there is a rich and important theory associated with them that has a multitude of
practical applications. It is the study of matrices and related topics that forms the
mathematical field that we call “linear algebra and Analysis.” In this chapter we will
begin our study of matrices.
Image and its Matrix:
There is a relation between matrices and digital images. A digital image in a
computer is presented by pixels matrix. On the other hand, there is a need
(especially with high dimensions matrices) to present matrix with an image.
The images you see on internet pages and the photos you take with your mobile
phone are examples of digital images. It is possible to represent this kind of image
using matrices.
For example, the small image of Felix the Cat
can be represented by a
35×35 matrix
whose elements are the numbers 0 and 1. These numbers specify the color of each
pixel: the number 0 indicates black, and the number 1 indicates white. Digital
images using only two colors are called binary images.
Grayscale images can also be represented by matrices. Each element of the matrix
determines the intensity of the corresponding pixel.
Note: A pixel is the smallest graphical element of a metrical image, which can take
only one color at a time
For convenience, most of the current digital files use integer numbers between 0
(to indicate black, the color of minimal intensity) and 255 (to indicate white,
maximum intensity), giving a total of
256 = 28
different levels of gray (gray image).
For example, the image is presented with the matrix
Color images, in turn, can be represented by three matrices. Each matrix specifies
the amount of Red, Green and Blue that makes up the image.
This color system is known as RGB. The elements of these matrices are integer
numbers between 0 and 255, and they determine the intensity of the pixel with
respect to the color of the matrix. Thus, in the RGB system, it is possible to
represent
2563 = 224 = 16777216
different colors
2.1: Definition of Matrix and special Matrices:
The purpose of this section is to introduce the notion of a matrix, give some
motivation and some special matrix and make the basic definitions used in
matrixalgebra and solving linear equations in coming chapters.
Definition: A matrix is a rectangular array of objects or elements, denoted by
The displayed matrix has (m) rows and (n) columns and is called an m by n matrix
or matrix of order (m × n).
1. The size of the matrix is denoted by (m × n).
2. Each entry in the matrix is called the entry or elements of the matrix and is
denoted by (aij ), where (i) is the row number and (j) is the column number
of the element.
Example :
2 1 3 4
A = [1 3 0 2]
4 3 5 6
There are (3) rows and (4) columns, so the size of A is (3×4) and (a23 = 0) ,
(a32 = 3).
1- Square matrix: is a matrix where number of row = number of column.
2- Symmetric matrix: is a square matrix where (aij = aji ) for all(i ≠ j).
Example :
0 3
B=[ ] is (2×2) square matrix but not symmetric.
2 5
Example :
1 4 6
C = [4 1 0] is (3×3) square and symmetric matrix by
6 0 3
(a12 = a21 = 4),(a13 = a31 = 6) and (a23 = a32 = 0).
3- Diagonal( main) of the matrix: are given by the elements (aij ) for i = j
that is all a11 , a22 , a33 ⋯.
4- The trace of a matrix: is define as a sum of the main diagonal elements.
It is denoted by
Tr(A)=∑ni=1 aii ,
where A is an (n×n) square.
5- Column vector (column matrix): A matrix with only one column is called
a column vector (column matrix).
For example
2
A = [7] is (3×1) column vector.
0
6- Row vector (or row matrix): A matrix with only one row is called a row
vector.
For example
A =[4 6 2 1] is (1×4) row vector.
7- A diagonal matrix: is a square matrix with all non-diagonal elements
equal zero. That is (aij = 0) for all (i ≠ j).
Example:
1 0 0
C = [0 5 0] is (3×3) diagonal matrix.
0 0 3
8- Upper triangular matrix: is a square matrix with all elements below the
diagonal are zero, that is (aij = 0) for all i > 𝑗.
Example:
1 50 8
C=[0 5 3] is (3×3) upper triangular matrix.
0 0 3
9- Lower triangular matrix: is a square matrix with all elements above the
diagonal are zero, that is (aij = 0) for all j > 𝑖.
Example :
1 0 0
C = [4 5 0] is (3×3) Lower triangular matrix.
0 3 3
10- A scalar matrix : is a diagonal matrix with the same value in the
diagonal elements.
Example :
5 0 0
C = [0 5 0] = 5 is (3×3) scalar matrix.
0 0 5
11- Identity (unit) matrix: is a scalar matrix with one (1) on the diagonal.
is a matrix denoted by I such that
AI = A for any matrix A.
We can denote the size in the subscript of I as 𝐼2, 𝐼3 and 𝐼4 respectively.
We need the identity matrix in order to define and explain the inverse matrix in
next section.
Example :
1 0 0
C = [0 1 0] = I is (3×3) Identity matrix.
0 0 1
12- Zero (null) matrix: Is the matrix all of whose elements are zero. There
is a zero matrix for every size.
For example
0 0 0
0 0 0
C = [0 0 0] = 0 is (3×3) zero matrix and [ ] is (2×3) zero
0 0 0
0 0 0
matrix.
2.2 matrix operation
1. Equality of two matrices: Two matrices A and B are equal if the size of A
and B is the same . That is ( 𝑎𝑖𝑗 = 𝑏𝑖𝑗 ) for all i and j.
For example
𝑥 4 2 4
If [ ]= [ ] then 𝑥 = 2 and 𝑦 = 1 .
3 𝑦 3 1
2. Addition of matrices: The operation of addition of two matrices is only
defined when both matrices have the same size (dimensions). If A and B are
both (m × n), then the sum
C =A+B
is also (m × n) and is defined to have each element the sum of the
corresponding elements of A and B, thus
𝑐𝑖𝑗 = 𝑎𝑖𝑗 + 𝑏𝑖𝑗 .
The subtraction of two matrices is similarly defined; if A and B have the
same dimensions, then the difference
C =A-B
By the same way of addition, implies that the elements of C are
𝑐𝑖𝑗 = 𝑎𝑖𝑗 − 𝑏𝑖𝑗 .
For example:
−2 4 2 4 −2 + 2 4 + 4 0 8
[ ]+ [ ]=[ ]= [ ]
2 0 3 1 2+3 0+1 5 1
2 4 3 7 2
[ ]+[ ] is not define
3 1 4 5 1
Example:
Basic Properties of Matrices addition
Matrix addition is commutative: A+B=B+A
Matrix addition is associative: A + (B + C) = (A + B) + C
3. Multiplication of a matrix by a number (scalar multiplication): There is also
a natural way of defining the product of a matrix with a number. Using the
2 4
matrix A= [ ] , we note that
3 1
2 4 2 4 4 8
A+A=[ ]+[ ]=[ ] =2 A.
3 1 3 1 6 2
What we see is that 2A (which is the shorthand notation for A+A) is obtained
by multiplying every element of A by 2, where a scalar is a number which is
used to multiply the entries of a matrix
In general if A is an (m × n) matrix with typical element (𝑎𝑖𝑗 ) then the product
of a number k with A written (kA) is the product B = kA is defined to be the
matrix of the same dimensions as A whose elements are simply all scaled by
the constant k
𝑏𝑖𝑗 = 𝑘 × 𝑎𝑖𝑗 .
Example:
Example:
For example:
−2 4 3 × −2 3×4 −6 12
3[ ]=[ ]=[ ].
2 0 3×2 3×0 6 0
The distributive law holds: k(A + B) = k A + k B where k real number.
4. Matrix Multiplication: Two matrices may be multiplied together only if
they meet conditions on their dimensions that allow them to conform as
following.
Let A have dimensions (m × n) and B be (n × p), that is A has the same number
as columns as the number of rows in B,
then the product
C =AB,
is defined to be an (m × p) matrix with elements
𝑐𝑖𝑗 = ∑𝑛𝑘=1 𝑎𝑖𝑘 𝑏𝑘𝑗 .
The element in position (𝑖𝑗) is the sum of the products of elements in the i-th
row of the first matrix (A) and the corresponding elements in the j-th column
of the second matrix (B).
Notice that the product AB is not defined unless the above condition is
satisfied, that is the number of columns of the first matrix must equal the
number of rows in the second.
Example:
Example:
For example:
−2 4 3 1 (−2 × 3) + (4 × 5) (−2 × 1) + (4 × 0) 14 −2
[ ][ ]=[ ]=[ ].
2 0 5 0 (2 × 3) + (0 × 5) (2 × 1) + (0 × 0) 6 2
4 4
−2 4
[ ] [7 2] is not define.
2 0
0 1
Property of multiplication of matrix
Matrix multiplication is associative, that is A (BC)=(AB) C.
Matrix multiplication Distributive over addition A(B + C) = AB + AC
(B + C) A = BA + CA
But is not commutative in general AB ≠ BA.
Consider the
Example:
1 2 0 1
A=[ ] and B=[ ]
1 2 2 0
It is interesting to note that unlike the scalar case, the fact that AB = 0 does not
imply that either A = 0 or that B = 0.
Exercise :
6 3 2 4
Let A=[ ] and B=[ ], then find the followings
2 5 3 1
1- 3A+2B 2- -4A+B2 .
2- Show that by example (𝐴 − 𝐵)2 = 0 does not imply A=B
Example : A computer monitor with (640) row pixels and (480) column can
viewed as a matrix. In order to create an image, each pixel is filled with an
appropriate colure.
The following example demonstrates the practical application of matrix
multiplication.
A local computer office shop sells three types of Laptop : Dell, Lenovo and HP. Dell
costs $260 each, Lenovo $300 each and HP $280 each. The sales of each Laptop
are as shown in Table
Sun Mon Tues Wed Thur
Dell 2 3 1 2 4
Lenovo 3 3 3 2 4
HP 2 3 4 2 4
Of course, you can solve this problem without matrices, but using matrix notation
provides a systematic way of evaluating the sales for each day.
Writing out the matrices and carrying out the matrix multiplication row by column
gives:
2 3 1 2 4
( 260 300 280) (3 3 3 2 4) = (1980 2520 2280 1680 3360)
2 3 4 2 4
Hence the takings for Sunday are:
(2 × 260) + (3 × 300) + (2 × 280) = $1980.
Similarly for the other days, we have Monday $2520 Tuesday $2280, Wednesday
$1680 and Thursday $3360. The matrix on the right hand side gives the takings for
each weekday.
A software package such as MATLAB can be used for computing matrices. In fact,
MATLAB is short for ‘Matrix Laboratory’. It is a very useful tool which can be used
to eliminate the drudgery from lengthy calculations.
There are many mathematical software packages such as MAPLE and
MATHEMATICA, but MATLAB is particularly useful for linear algebra.
Exercise : A factory manufactures three products (laptop , desktop , and table ) and
ships them to two warehouses for storage. The number of units of each product
shipped to each warehouse is given by the matrix.
200 75
A = [ 150 100 ]
100 125
where 𝑎𝑖𝑗 is the number of units of product 𝑖 sent to warehouse 𝑗 and the products
are taken in alphabetical order).
The cost of shipping one unit of each product by truck is $1.50 per doohickey, $1.00
per gizmo, and $2.00 per widget. The corresponding unit costs to ship by train are
$1.75, $1.50, and $1.00.
Organize these costs into a matrix 𝐵 and then use matrix multiplication to show
how the factory can compare the cost of shipping its products to each of the two
warehouses by truck and by train
2.3 Unary Matrix operations:
Thus far, all of the matrix operations we have defined are analogous to operations
on real numbers, although they may not always behave in the same way. The next
operation has no such analogue.
2.3.1 The Transpose of a Matrix
The transpose of an (m×n) matrix A, denoted 𝐴𝑇 , is the (n×m) matrix define by
interchanging the rows and columns of A.
In general, the entry 𝑎𝑖𝑗 (ith row by jth column) of matrix A is transposed to 𝑎𝑗𝑖
(jth row by ith column) in 𝐴𝑇 .
Example:
For example, if
6 3 6 2
A=[ ] then 𝐴𝑇 =[ ]
2 5 3 5
Note: If 𝐴 = 𝐴𝑇 Then A called symmetric Matrix
Example:
Properties of Transposed Matrices
1- (𝐴 + 𝐵)𝑇 = 𝐴𝑇 + 𝐵 𝑇 .
2- (𝐴𝐵)𝑇 = 𝐵 𝑇 𝐴𝑇 .
3- ((𝐴)𝑇 )𝑇 = 𝐴.
Note: There are two important quantities associated with a square matrix. One is
the trace and the other is the determinant.
2.3.2 The Determinant of a Matrix:
determinant functions 𝑓(𝐴) assign a real number to a matrix variable 𝐴. Although
determinants first arose in the context of solving systems of linear equations.
Although they can be useful for solving very small linear systems , our main interest
in them stems from the fact that they link together various concepts in linear
algebra and provide a useful formula for the inverse of a matrix
The determinant of a matrix is a special number that can be calculated from or
defining only for square matrix, denoted by
det(A) or |𝐴|.
We will avoid the formal definition of the determinant (that implies notions of
permutations) for now and we will concentrate instead on its calculation.
Finding the determinant depends on the dimension of the matrix, The determinant
of a matrix of size (n × n) is defined recursively in terms of lower order determinants
((n − 1) × (n − 1)).
i. The determinant of (1×1) matrix or scalar matrix is the only number in
matrix. For example, det ( [2])=2.
ii. The determinant of (2×2) matrix is defined by the relation
a11 a12
A=[a
21 a22 ], then det (A)= a11 a22 − a12a21 .
For example
−2 4
𝐴=[ ], then det (A)=-2×0-4×2=-8.
2 0
iii. The determinant of (3×3) matrix is defined by the relation.
a11 a12 a13
A = [a21 a22 a23 ], then
a31 a32 a33
det (A)= a11 (a22 a33 − a23 a32 ) − a12 (a21 a33 − a23 a31 ) + a11 (a21 a32 −
a22 a31 ).
For example
3 2 1
𝐴 = [0 1 2],then det (A)=3(1×2--4×2)−2(0×2−2×5)+1(0×4−1×5)=18+20-5=33
5 4 2
We can simplify the way for finding determinant of (3×3) matrix as follows.
a) Rewrite the 1-st and 2-nd columns of A on the right (as “Columns 4 and 5”).
b) Add the products along the three main diagonals that extend from upper
left to lower right.
c) Subtract the products along the three secondary diagonals that extend
from lower left to upper right.
a11 a12 a13
That is if A= [a21 a22 a23 ], to find det (A) we rewrite A as
a31 a32 a33
a11 a12 a13 ⋮ a11 a12
[a21 a22 a23 ⋮ a21 a22 ]. Then
a31 a32 a33 ⋮ a31 a32
det (A)= (a11 a22 a33 )+ (a12 a23 a31 )+ (a13 a21 a32 )− (a13 a22 a31 )− (a11 a23 a32 )
− (a12 a21 a33 ).
Note: The determinant helps us find the inverse of a matrix, tells us things about
the matrix that are useful in systems of linear equations.
To finding the determinant in general of (n×n) matrix we need define the
following concepts first.
a/ Minor: The Minor of the element (𝑎𝑖𝑗 ), is denote by 𝑀𝑖𝑗 , is define to be the
determinant of the low dimension matrix (sunmatrix) formed by eliminate the i-th
row and j-th column in the original matrix.
For example: Let
Example
3 2 1
Let 𝐴 = [0 1 2], then find 𝑀22 and 𝑀12
5 4 2
Solution: after eliminate the 2-nd row and 2-nd column in A we obtain
3 1 3 1
𝑀22 =det([ ])=| |=(3×2)−(1×5)=1.
5 2 5 2
0 2 0 2
𝑀12 =det([ ])=| |=(0×2)−(2×5)=−10.
5 2 5 2
b/ Cofactor: The cofactor of the element (𝑎𝑖𝑗 ), is denote by 𝐶𝑖𝑗 , is defined by the
relation.
𝐶𝑖𝑗 = (−1)𝑖+𝑗 𝑀𝑖𝑗 .
Note: You will notice that the cofactor and the minor always have the same
numerical value, with the possible exception of their sign came from element
position.
For example :
In example above find 𝐶33 and 𝐶12
3 2
Solution: 𝐶33 = (−1)3+3𝑀33=| |=(3×1)−(2×0)=3.
0 1
𝐶12 = (−1)1+2𝑀33 =−(−10)=10.
Now we are ready to give general formula for finding determinant of (n×n) matrix
using cofactor.
Let A be an (n×n) matrix, then determinant of A ( by choosing i-row) given by the
relation
det (A)=∑𝑛𝑗=1 𝑎𝑖𝑗 𝐶𝑖𝑗 .
( by choosing j-column) given by the relation.
det (A)=∑𝑛𝑖=1 𝑎𝑖𝑗 𝐶𝑖𝑗 .
For example
3 2 1
Let 𝐴 = [0 1 2], then find det (A) using cofactor
5 4 2
Solution: let us choose the second row, an expansion along the first row, the
determinant would be.
2 1 3 1
Det(A)=𝑎21 𝐶21+𝑎22 𝐶22+𝑎23 𝐶23=0(−1)2+1 | |+1(−1)2+2 | |+2
4 2 5 2
3 2
(−1)2+3 | |=(3×2−5×1) −2(3×4−5×2)=1−2(2)= −3.
5 4
Note: While the choice of row or column may differ, the result of the determinant
will be the same, no matter what the choice we have made.
Basic Properties of Determinants
Suppose that A and B are 𝑛 × 𝑛 matrices and k is any scalar. We begin by
considering possible relationships between det(A) and det(B)
1- det(𝑘𝐴)=𝑘 𝑛 det(A)
2- det(A+B)≠det(A)+det(B)
Example:
3- det(AB)=det(A) det(B)
2.3.3 Inverse of a matrix
We should now be familiar with matrix operations such as addition, subtraction
and multiplication. What about division of matrices? You cannot divide matrices.
The nearest operation to division of matrices is the inverse matrix which we discuss
in this section. We can use the inverse matrix to find solutions of linear systems.
Matrix division is not defined for all matrix, multiplication by an inverse may be
thought of as an analogous operation to the process of multiplication of a scalar
quantity by its reciprocal.
For a square n × n matrix A, the inverse, denoted by 𝐀−1, as that matrix (if it
exists) to give the identity matrix I, satisfies the following.
𝐀−1𝐀 = 𝐀 𝐀−1 = 𝐈𝑛 .
Example:
Example:
2 1 1 −1 1 0
( )( )=( )
1 1 −1 2 0 1
and so these two matrices are inverses of one another:
Note:
1
𝐴−1 ≠
𝐴
Our next theorem provides an important criterion for determining whether a
matrix is invertible. It also takes us a step closer to establishing Formula.
Theorem : A square matrix A is invertible if and only if det(𝐴) ≠ 0
Example:
A matrix that is invertible is called non-singular matrix.
A matrix that is not invertible is called singular matrix.
If the inverse matrix is existing, then it is unique.
To computing the inverse of any square matrix we need define the following
concept.
Adjoint of matrix: The adjoint matrix of a square matrix A, denote by adj(A ), is
defined as the transpose of the matrix of cofactors of the elements of A, that is
𝑎11 𝑎12 … 𝑎1𝑛
𝑎21 𝑎22 … 𝑎2𝑛
Let A= [ ⋮ ⋮ ⋱ ⋮ ], then adjoint of A given by relation
𝑎𝑛1 𝑎𝑛2 … 𝑎𝑛𝑛
𝐶11 𝐶12 … 𝐶1𝑛 𝑇 𝐶11 𝐶21 … 𝐶𝑛1
𝐶 𝐶 … 𝐶2𝑛 𝐶 𝐶 … 𝐶𝑛2
Adj(A)=[ 21 22 ] =[ 12 22 ]
⋮ ⋮ ⋱ ⋮ ⋮ ⋮ ⋱ ⋮
𝐶𝑛1 𝐶𝑛2 … 𝐶𝑛𝑛 𝐶1𝑛 𝐶2𝑛 … 𝐶𝑛𝑛
For example
−2 4
Let 𝐴 = [ ], then find adj(A).
2 0
𝐶 𝐶12 𝑇 0 −2 𝑇 0 −4
Solution: adj(A)= [ 11 ] =[ ] =[ ].
𝐶21 𝐶22 −4 −2 −2 −2
Then the inverse of a square matrix A is found from the determinant
and the adjoint of A, by the relation.
𝑎𝑑𝑗(𝐴) 1
𝐴−1 = = 𝑎𝑑𝑗(𝐴).
det(𝐴) det(𝐴)
Notice that the condition for the inverse to be exist, that is for A to be
non-singular, is that det (A) ≠0.
Example: Not every square matrix has an inverse. For instance
3 2
1- 𝐴 = ( ) has no inverse because det(A)=0
6 4
3 3 1
2- 𝐵 = ( ) has no inverse because it is not square matrix.
2 2 0
Theorem: If A is an invertible matrix, then its inverse is unique.
For example
−2 4
Let 𝐴 = [ ], then find 𝐴−1 if it is exist
2 0
Solution: First we need to find det(A) =(0)(−2) − (4)(2) = −8 ≠ 0 so it is
exist.
−4 1
1 1 −4 0 0 0
−8
𝐴−1 = 𝑎𝑑𝑗(𝐴)= [ ]= [−2 −2 ]=[ 1
2
1]
det(𝐴) −8 −2 −2
−8 −8 4 4
1
4 0
We can cheek 𝐴𝐴−1 = [−2 ][ 2 1
1]=[0
0
]=𝐼 .
2 0 1 1 2
4 4
Example:
Exercise:
3 2 1
2 −3
If 𝐴 = [ ] and B=[0 4 5] , then find 𝐴−1 and 𝐵 −1 if exists.
−4 1
1 0 6
Properties of Inverse Matrix
Let A and B be invertible matrices, then AB is invertible and
(𝐴𝐵)−1 = 𝐵 −1𝐴−1
(𝐴−1)−1 = 𝐴
(𝐴𝑇 )−1 = (𝐴−1)𝑇
Chapter 3: System of linear equations and Matrices
3.1 The Matrix Representation of a System of Linear Equations:
The study and solution of systems of simultaneous linear equations is the main
motivation behind the development of the theory of linear algebra and of matrix
operations.
The system of m linear equation in n variables𝑥1 , 𝑥2 , 𝑥3 ,… …, 𝑥𝑛 is of the form
𝑎11 𝑥1 +𝑎12𝑥2 + ⋯ ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1
𝑎11 𝑥1 +𝑎12𝑥2 + ⋯ ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1
⋮ ⋮ +⋯⋯+⋮ = ⋮
𝑎𝑚1 𝑥1 +𝑎𝑚2 𝑥2 + ⋯ ⋯ + 𝑎𝑚𝑛 𝑥𝑛 = 𝑏𝑚
Can be written as matrix equation by 𝐴𝑋 = 𝑏 or in full