Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
com
Page:
Bharathiar University
SDE, Coimbatore 46.
Page:
Unit-I
Lesson 1
Matrix, Determinants and Inverse
Contents:
1.0 Aims and objectives
1.1 Introduction
1.2 Matrices
1.2.1 Applications of matrices
1.2.2 Definition of a Matrix
1.2.3 Matrix types
1.3 Determinant
1.3.1 Definition
1.3.2 Properties of determinants
1.3.3 Determinant of a 3 x 3 matrix by Matrix Enhancement
1.3.4 Leibnitz formula to compute determinant of a Matrix
1.3.5 Laplace's formula to compute determinant of a Matrix
1.4 Inverse of a Matrix
1.4.1 Cofactors
1.4.2 Adjoint of a Matrix
1.4.3 Inverse of a Matrix Definition
1.4.4 Properties of invertible matrices
1.4.5 Matrix inverses in real-time simulations
1.4.6 Analytic solution
1.5 Problems and Solutions
1.6 Let Us Sum Up
1.7 Lesson End Activities
1.8 References
Page:
How to find matrix Inverse? And to solve linear equations using inverse.
1.1 Introduction
J. J. Sylvester coined the term matrix in 1848. A matrix is a rectangular table of
elements. Matrices are used to describe linear equations, keep track of the coefficients of
linear transformation and to record data that depend on multiple parameters. The
determinant notation is now employed in almost every branch of applied science.
Matrix inversion plays a significant role in computer graphics and to solve system of
linear equations.
Page:
1.2 Matrices
The study of matrices is quite old. A 3-by-3 magic square appears in Chinese
literature dating from as early as 650 BC. Matrices have a long history of application in
solving linear equations. After the development of the theory of determinants by Seki
Kowa and Leibniz in the late 17th century, Cramer developed the theory further in the
18th century, presenting Cramer's rule in 1750. Carl Friedrich Gauss and Wilhelm Jordan
developed Gauss-Jordan elimination in the 1800s. Cayley, Hamilton, Grassmann,
Frobenius and von Neumann are among the famous mathematicians who have worked on
matrix theory. Olga Taussky-Todd (1906-1995) used matrix theory to investigate an
aerodynamic phenomenon called fluttering or aeroelasticity during WWII.
In mathematics, a matrix (plural matrices) is a rectangular table of elements (or
entries), which may be numbers or, more generally, any abstract quantities that can be
added and multiplied. Matrices are used to describe linear equations, keep track of the
coefficients of linear transformation and to record data that depend on multiple
parameters. Matrices can be added, multiplied, and decomposed in various ways, making
them a key concept in linear algebra and matrix theory.
1.2.1 Applications of matrices
Encryption
Matrices can be used to encrypt numerical data. Multiplying the data
matrix with a key matrix does encryption. Simply multiplying the encrypted
matrix with the inverse of the key does decryption.
Computer graphics
44 transformation matrices are commonly used in computer graphics.
The upper left 33 portion of a transformation matrix is composed of the new X,
Y, and Z-axes of the post-transformation coordinate space.
a 21 a 22 a 23 . . a 2 n
a
a32 a33 . . a3n
31
m rows
.
. . . .
.
.
.
. . . .
a
a n 2 a n 3 . . a nn
n1
14
4444244444
3
n columns
in which each entry, ai,j, of the matrix is a real number. An m n matrix has m rows
(horizontal lines) and n columns (vertical lines).
Page:
Page:
(or)
The mathematical expression a1 b2 -a2 b1 can be expressed as
a 1 b1
a 2 b2
The above form is called a determinant of the second order. Each of the numbers a1, b1 , a2,
b2 is called an element of the determinant.
Thus
2 5
= (2)(9) - (3)(5) = 18 - 15 = 3.
3 9
a 2 b2 c2
a 3 b3 c3
is called a determinant of the third order.
Thus
3 1
3
2 2 - 1 = 3(4 - 3) - 1(4 + 1) + 3(-6 - 2) = 3 - 5 - 24 = -26
1 -3 2
In general, a determinant of the nth order is denoted by
a1 b1 . . l1
a 2 b2 . . l 2
- - - - - - - -(1)
.
. . . .
.
. . . .
a n bn . . l n
The determinant in (1) have n rows and n columns; thus having n2 elements. The diagonal
through the left hand top corner which contains the elements a1 , b2 , c3 , ---, ln is called the
leading or principal diagonal.
Page:
a 21 a 22 a 23
a33 a31 a32 a33 a31
From the enhanced matrix we can now define three positive diagonals, shown below by
solid lines and three negative diagonals, shown below by broken lines.
a13
a33
a11
a 21
a31
a12
a 22
a32
a13
a 23
a33
a11
a31
a13
a33
a11
a 21
a31
a12
a 22
a32
a13
a 23
a33
a11
a31
Multiplying along the diagonals, we can calculate the determinant as the sum of the three
positive diagonals less the three negative diagonals. The complete expression is then
a13 a21 a32 + a11 a22 a33 + a12 a23 a31 a33 a21 a12 a31 a22 a13 a32 a23 a11.
The above expression gives Leibniz formula for a (3 x 3) matrix.
Page:
Example 1
Calculate the determinant of the
method.
1 2 2
2 1
2 1
1 1 1
3 1 -1 3 1
and its determinant will be
= (2).(1).(-1) +(1).(1).(3)+ (2).(1).(1) - (3).(1).(2) - (1).(1).(2) (-1).(1).(1)
= -2+3+2-6-2+1
= -4
1.3.4 Leibniz formula to compute determinant of a Matrix
Here the sum is computed over all permutations of the numbers {1,2,...,n} and sgn()
denotes the signature of the permutation : +1 if is an even permutation and - 1 if it is
odd.
This formula contains n! (factorial) summands, and it is therefore impractical to use it to
calculate determinants for large n.
For small matrices, one obtains the following formulas:
Page:
det(A) = a i , j C i , j = a i , j (-1) i + j M i , j
j=1
j=1
where the Ci,j represent the matrix cofactors, i.e. Ci,j is ( - 1) i + j times the minor Mi,j,
which is the determinant of the matrix that results from A by removing the i-th row and
the j-th column.
Example 2
Page:
10
Alternatively, we can use Laplace's formula to expand the determinant along a row or
column. It is best to choose a row or column with many zeros, so we will expand along
the second column:
-1 3
- 2 - 3
+ (-1) 2+ 2 .1. det
In order to compute the determinant of a given matrix, we are using the Laplaces
Formula.
Page:
11
a1
b1
c1
a2
a3
b2
b3
c2
c3
is the
2 x 2 determinant obtained by deleting the row and column containing that element and
multiplying by +1 or 1 according to the pattern:
+ - +
- + + - +
A cofactor is always designated by the capital letter corresponding to the element to
which it belongs.
The nine cofactors are as given below:
b2
b3
c2
c3
a2
a3
c2
c3
a2
a3
b2
b3
b1
b3
c1
c3
a 1 c1
a 3 c3
a b1
The cofactor of(c 2 ) = C 2 = - 1
a 3 b3
b1
b2
c1
c2
a1
a2
a1
a2
c1
c2
b1
b2
Page:
12
A1
A2
B2
C2
A3
The standard notation for the adjoint of matrix A is adj(A). Notice that adj(A) is the
transpose of the matrix formed by replacing each element of A by its cofactor. The
product A adj(A) is always a diagonal matrix.
D 0 0
i.e.
A adj( A) = 0 D 0 = D I
0 0 D
AB = IAAN
Page:
for
square
matrices A a n d
B,
then
also B A
13
Matrix inversion is the process of finding the matrix B that satisfies the prior equation for
a given invertible matrix A.
Remark: The symbol A-1 is read A inverse.
If a matrix A has an inverse, then A is invertible (or nonsingular); otherwise, A is
singular. A nonsquare matrix cannot have an inverse. Moreover not all square matrices
possess inverse. If, however, a matrix does possess an inverse, then that inverse is unique.
Page:
14
Page:
a b
2 2
and
.
1) Find the inverse of
c d
3 5
Solution :
i)
a b
Let A =
c d
\| A | = ad - cb
a c
A T =
b d
d - b
adj A =
- c a
1 d - b
A -1 =
ad - bc - c a
ii)
Q A -1 =
2 2
Let A =
3 5
\| A | = 10 - 6 = 4
2 3
A T =
2 5
5 - 2
adj A =
- 3 2
A -1
5
1 5 - 2 4
=
=
4 - 3 2 - 3
1
-
2
1
1
adj A
|A|
15
Page:
16
1 0 -1
Solution :
i)
1 0 -1
Let A = 3 4
5
0 - 6 - 7
4 5
= - 28 + 30 = 2
-6 -7
3 5
= - (-21 - 0) = 21
0 -7
Cofactor of 0 = B1 = -
Cofactor of - 1 = C1 = +
3 4
= -18 - 0 = -18
0 -6
Cofactor of 3 = A 2 = -
0 -1
= - (0 - 6) = 6
-6 -7
Cofactor of 4 = B 2 = +
1 -1
= - 7 + 0 = -7
0 -7
Cofactor of 5 = C 2 = -
1 0
=-6+0 = 6
0 -6
0 -1
Cofactor of 0 = A 3 = +
Cofactor of - 6 = B 3 = -
A2
B2
C2
=0+4 = 4
1 -1
= 5 + 3 = -8
3 5
Cofactor of - 7 = C 3 = +
A1
adj A = B1
C
1
1 0
3 4
=4-0 = 4
A3 2
6 4
6 4
2
1
1
-1
B 3 = 21 - 7 - 8 \ A =
adj A =
21 - 7 - 8
|A|
20
C 3 - 18 6 4
- 18 6 4
Page:
17
5 0 0
3) If 10 A - 50 I = 0 and A = 0 5 0 find A -1 .
0 0 5
Solution :
Consider 10A - 5I = 0
Post multiplying by A -1
10 A A -1 - 50 I A -1 = 0
10 I - 50 A -1 = 0
50 A -1 = 10 I
1
A -1 = [10 I]
50
1
0 0
1
1
-1
A = I= 0
0
5
5
1
0 0
1 2 2
and "0" denotes the zero matrix and hence find the inverse of A.
Solution :
1 2 2
Let A = 2 1 2
2 2 1
1 2 2 1 2 2
2
A = A.A = 2 1 2 2 1 2
2 2 1 2 2 1
1 + 4 + 4 2 + 2 + 4 2 + 4 + 2
= 2 + 2 + 4 4 + 1 + 4 4 + 2 + 2
2 + 4 + 2 4 + 2 + 2 4 + 4 + 1
9 8 8
= 8 9 8
8 8 9
Page:
= A 2 - 4A - 5I
9 8 8 1
= 8 9 8 - 4 2
8 8 9 2
9 8 8 4
= 8 9 8 - 8
8 8 9 8
2 2 5
1 2 - 0
2 1 0
8 8 5
4 8 - 0
8 4 0
0 0
5 0
0 5
0 0
5 0
0 5
5 0 0 5 0 0
= 0 5 0 - 0 5 0
0 0 5 0 0 5
0 0 0
= 0 0 0
0 0 0
1
= 2 1 2 - 0 4 0 = 2 - 3 2
5
5
2 2 1 0 0 4
2 2 - 3
2
-3 2
5
5 - 0.6 0.4
0.4
5
2 -3 2
-1
A =
= 0.4 - 0.6 0.4
5
5
5
0.4 - 0.6
2
2 - 3 0.4
5
5
5
18
Page:
19
adj(A)
det(A)
Page:
a h g
1) Find the value of h b f
g f c
5 3
3
2) Evaluate 2 6 - 3
8 -3 2
a b
3) Without expanding, verify that a 2 b 2
bc ca
c 1 a2
c2 = 1 b2
ab 1 c 2
a3
b3
c3
5 4 3
4) Find the cofactor of ' a' in the determinant 2 6 a
8 -7 2
5) Compute the adjoint of
1 2 3
a)
1 3 5
1 5 12
b)
2 0 7
-1 4 5
3 1 2
-1 - 2 - 2
2 1 - 2
2 -2 1
- 4 - 3 - 3
1
1 1
7) Define the inverse of a matrix and prove that, if a matrix has an inverse, it has
only one inverse.
20
Page:
1.8. References
1)
Frank Ayres,Jr,Matrices.
2)
3)
4)
5)
21
Page:
22
Unit-I
Lesson 2
Rank of a Matrix
Contents:
2.0 Aims and objectives
2.1 Introduction
2.2 Rank of a Matrix
2.2.1 Rank-Definitions
2.2.2 Properties
2.2.3 Computations of the rank Method 1
2.2.4 Solved Problems
2.3 Elementary row operations
2.3.1 Row-Echelon Form
2.3.2 Computations of the rank Method 2
2.3.3 Applications of the Rank
2.4 Let Us Sum Up
2.5 Lesson End Activities
2.6 References
2.0 Aims and objectives
In this lesson, we have discussed the rank of a matrix and its computation
methods. Elementary row operations in matrices are also discussed in this lesson.
After reading this lesson, you should able to understand
2.1 Introduction
The maximum number of independent rows (and therefore columns) that can be
found in a matrix is called the rank of a matrix. One useful application of calculating the
rank of a matrix is the computation of the number of solutions of a system of linear
equations. The system is inconsistent or having at least one solution or unique solution
can be found using its rank.
In control theory, the rank of a matrix can be used to determine whether a linear system is
controllable, or observable.
Page:
23
The rank of an m n
matrix is at most
min(m,n). A matrix that has as large a rank as possible is said to have full rank;
otherwise, the matrix is rank deficient.
Page:
24
2.2.2 Properties
1 0 0 1
Both factors have rank 1, but the product has rank 0.
The rank of a matrix plus the nullity of the matrix equals the number of columns
of the matrix (this is the "rank theorem" or the "rank- nullity theorem").
A= 2
3
1
- 2 - 3 - 1
2
3
1
| A |= 2
3
1 r3 r3 + r2
- 2 - 3 - 1
=0
2 3
But there is at least one non-zero minor of order 2, namely
which is = -7.
3 1
Hence r(A) =2.
Page:
Other non- vanishing determinants of order 2 might be written but a single one is a
sufficient to establish that the rank is 2.
Example 2.
Let
1 2 3
A = 2 3 1
3 1 2
|A| =1(6-1)-2(4-3)+3(2-9)
= 5 2 21 = -18 0
It is square matrix with det(A)0. Hence r(A) = 3
25
Page:
Example 3.
Let
6
2 4
A = 4 2
3
6 - 6 - 9
|A| = 0
Also each of the second order minor is also = 0.
But the matrix is non- zero, hence r(A) = 1.
26
Page:
1 2 3
Solution :
1 2 3
Let A = 2 4 5
3 5 6
1 2 3
| A |= 2 4 5
3 5 6
= 1(24 - 25) - 2(12 - 15) + 3(10 - 12)
= 1(-1) - 2(-3) + 3(-2)
= -1 + 6 - 6
= -1 0
Hence the rank of the matrix is 3.
3 2 - 1
Solution :
3 2 - 1
Let A = 7 8 0
4 6 1
3 2 -1
| A |= 7 8 0
4 6
27
Page:
28
3 2
Solution :
- 2 1 3 4
Let A = 0 1 1 2
1 3 4 7
1 2
4 7
Page:
2
3
1
Solution :
2
3
1
Let A = 2
4
6
- 3 - 6 - 9
1
2
3
| A |= 2
4
6
-3 -6 -9
= 1(4 (-9) - (-6) 6) - 2(2 (-9) - (-3) 6) + 3(2 (-6) - (-3) 4)
= 1(0) - 2(0) + 3(0) = 0
Therfore the rank of the matrix is not 3.
The submatrices of the given matrix are
1 2 1 3 2 3
,
,
,
2 4 2 6 4 6
2 1
3 2
3
1
,
,
,
- 3 - 6 - 3 - 9 - 6 - 9
4 2
6
6
2
4
,
and
.
- 3 - 6 - 3 - 9
- 6 - 9
The determinant of all the above submatrices are all equal to 0(zero).
Since the determinant of all the second order mionors are zero, the rank is not 2.
But the matix A is non - zero, so its rank, r(A), is 1.
29
Page:
30
R 2 -1 2 0 3
-1 2 0 3
2 - 3 4 1
2 - 3 4 1
2
1
1 3 - 3 0
1 3 - 3 0
5 - 2 1
5 - 2 1
2
2
-3 0
1 3 - 3 0
1 3
5 - 2 1
2
- 2R 1 + R 3 1 6 - 11 6
Page:
31
A. 0 1 0
3
0 0 1 - 2
B.
1 - 5
0 0
C.
0 0
0 0
0
D.
0
2 -1 3
1 3 - 2
0 1 4
0 0 1
1 2 -1 4
3
0 1 0
0 0 1 - 2
0
1
0
0
0 - 1
0 2
1 3
0 0
The matrices on (B) and (D) also happen to be in reduced row - echelon form.
The following matrices are not in row - echelon form.
1 2 - 3 4
E. 0 2 1 - 1
0 0 1 - 3
F.
1 2 -1 2
0
0 0 0
0 1 2 - 4
Rank:
The number of non-zero rows in a Row- Echelon Form of a matrix after the
elementary row operations gives its rank.
Page:
32
1 1 - 1
Solution :
1 1 - 1
Let A = 2 - 3 4
3 - 2 3
1 1 - 1
R R 2 - 2R 1
~ 0 - 5 6 2
0 - 5 6 R 3 R 3 - 3R 1
1 1 - 1
~ 0 - 5 6 R3 R3 - R 2
0 0 0
The given matrix is reduced to its equivalent matrix by elementary row operations
and it is in the row - echelon form. The number of non - zero rows is 2.\ r(A) = 2.
3 1 - 5 -1
Solution :
3 1 - 5 -1
Let A = 1 - 2 1 - 5
1 5 - 7 2
1 - 2 1 - 5
~ 3 1 - 5 -1 R1 R 2
1 5 - 7 2
1 - 2 1 - 5
R R 2 - 3R 1
~ 0 7 - 8 - 14 2
0 7 - 8 - 7 R 3 R 3 - R1
1 - 2 1 - 5
~ 0 7 - 8 - 14 R 3 R 3 - R 2
0 0 0 - 7
Page:
33
1 2 3 -1
Solution :
1 2 3 -1
Let A = 2 4 6 - 2
3 6 9 - 3
1 2 3 - 1
R R 2 - 2R 1
~ 0 0 0 0 2
0 0 0 0 R 3 R 3 - 3R 1
Page:
34
All rows consisting entirely of zeros occur at the bottom of the matrix.
For each row that does not consist entirely of zeros, the first nonzero entry
is 1 (a leading 1).
For two successive (nonzero) rows, the leading 1 in the higher row is
farther to the left than the leading 1 in the lower row.
Page:
2)
3)
4)
5)
6)
7)
8)
9)
1 2 3
2 3 4
0 2 2
2 3 4
3 1 2
-1 2 2
3
1
2
6
2
4
- 6 - 9 - 3
3 -1 2
- 6 2 4
- 3 1 2
1 2 3
1 4 2
2 6 5
1 2 3
2 3 4
3 4 5
3 1 2 0
1 0 -1 0
2 1 3 0
4
1 -2 3
4 - 1 - 3
2
-1 2
7
6
6 1 1 1
16 1 - 1 5
7 2 3 0
35
Page:
2.6 References
1. Frank Ayres,Jr,Matrices.
2. Prof. A.Singaravelu,Engineering Mathematics I.
3. Dr. M.K Venkataraman, Engineering Mathematics Vol. II.
4.
36
Page:
37
Unit-I
Lesson 3
Eigenvaules and Eigenvectors
Contents:
3.0 Aims and objectives
3.1 Introduction
3.2 Linear Transformation
3.2.1 Characteristic equation
3.2.2 Characteristic Matrix
3.2.3 Characteristic Polynomial
3.3 Eigenvalues and Eigenvector
3.3.1 Eigenvalues - Definition
3.3.2 Properties of eigenvaules
3.3.3 Eigenvectors - Definition
3.3.2 Properties of eigenvectors
3.4 Problems and Solutions
3.5 Let Us Sum Up
3.6 Lesson End Activities
3.7 References
3.0 Aims and objectives
In this lesson, we have discussed about the Linear Transformation, Eigenvalues and
Eigenvectors.
After reading this lesson, you should able to
3.1 Introduction
Eigenvalues are a special set of scalars associated with a linear system of
equations (i.e., a matrix equation) that are sometimes also known as characteristic roots,
characteristic values (Hoffman and Kunze 1971), proper values, or latent roots (Marcus
and Minc 1988, p. 144).
The determination of the eigenvalues and eigenvectors of a system is extremely
important in physics and engineering, where it is equivalent to matrix diagonalization and
arises in such common applications as stability analysis, the physics of rotating bodies,
and small oscillations of vibrating systems, to name only a few. Each eigenvalue is paired
with a corresponding so-called eigenvector.
Page:
38
.
.
y n = a n1 x1 + a n 2 x 2 + .... + a nn x n
The above set of equations is said to form a linear transformation i.e. the
equations (1) transform the n variables x1 ,x2 ,x3 , , xn into n variables y1 ,y2 ,, yn .
Rewriting (1) as Y = A X
Where
a11 a12 . a1n
x1
y1
a 21 a 22 . a 2 n
x2
y
A=
, X = and Y = 2
.
. . .
x
y
a
a
.
a
n2
nn
n
n
n1
The equation (2) is said to be a linear transformation of vector X into another vector Y; A
is called the matrix of transformation and |A| is called the modulus of the transformation.
If |A| = 0 the transformation is singular; otherwise non-singular.
3.2.1 Characteristic equation
The characteristic equation of the matrix A is |A-lI| = 0. It is a polynomial equation in l.
A matrix A satisfies its own characteristic equation (Cayley-Hamilton theorem)
3.2.2 Characteristic Matrix
The characteristic matrix of A is (A-lI) and is a function of the scalar l.
3.2.3 Characteristic Polynomial
The characteristic polynomial, p(t), of a matrix A is p(t) = |A-lI|.
The characteristic polynomial of A nn is of the form: ln -tr(A)* ln-1 + ... + -1n |A|.
Page:
39
1 1
1
, ,...., .
1 2
n
Page:
A =
3 2
Solution
The characteristic equation is | A - lI | = 0
4-l
3
1
=0
2-l
(4 l) (2 l) 3 = 0
l2 6l+5 = 0
(l 1) (l 5)
=0
\l = 1 or 5.
\ The eigenvalues are 1 and 5.
Eigenvectors: When l =1, the equation
x1
Where X = becomes
x2
(A - I )X = 0
4-1
2-1
X1
=
X2
3x1 + x2 = 0
3x1 + x2 = 0
(or)
x2 = 3x1
- 3k
eigenvectors. Therefore,
for k = 1 the eigenvector is 1
- 3
to l = 1 is
40
Page:
x1
When l= 5, the equation (A - lI) X = 0, where X = , becomes
x2
1 x1 0
4 - 5
=
2 - 5 x 2 0
3
- 1 1 x1 0
=
3
3
x 2 0
-x1 + x2 = 0 x1 = x2
i.e.,
3x1 3x2 = 0 x1 = x2
By giving x2 = k, we have x1 =k and therefore for different values of k we get different
eigenvectors.
\ The general eigenvector can be
k
k
1
1
Hence
1
When = 1 the eigenvector is
- 3
1
When l = 1 the eigen vector is
1
41
Page:
42
2)
Find the e igenvalues and eige nvectors o f
4 - 20
- 2 10
6 - 30
- 10
4
- 13
Solution :
Let A be the giv en matrix and | A - I | = 0 be its charac teristic e quation .
4 - 20
A = - 2 10
6 - 30
i.e.,
i.e.,
4-
- 20
-2
6
10 -
- 30
- 10
4
- 13
- 10
4
=0
- 13 -
i.e.,
3 - 2 - 2 = 0
i.e.,
i.e.,
( 2 - - 2) = 0
= 0,
( - 2)( + 1) = 0
= 0, = -1, = 2.
\ the eigenv alues are = 0, - 1, 2.
The equation (A - I) X = 0 gives the eigenvecto rs X for each eigenvaule s ( ).
i.e.,
i.e.,
4 - - 20
- 2 10 -
6
- 30
- 10 x 1 0
4 x 2 = 0
- 13 - x 3 0
( 4 - )x 1 - 20 x 2 - 10 x 3 = 0
- 2x 1 + (10 - ) x 2 + 4 x 3 = 0
6x 1 - 30 x 2 - (13 + ) x 3 = 0
- - - - - - - -- >
For a given value of , the components x 1 , x 2 , x 3 of the eigenvecto r can be computed from
the above set of equatio ns.
Case (i) : When = 0, the above equation becomes
4 x 1 - 20 x 2 - 10 x 3 = 0
- 2x 1 + 10 x 2 + 4 x 3 = 0
6x 1 - 30 x 2 - 13 x 3 = 0
Page:
5
1
By taking k = , we get the eigenvector X 1 = 1 .
4
0
Case (ii) : When = -1, the equations (1) becomes
5x 1 - 20 x 2 - 10 x3 = 0
- 2x 1 + 11x 2 + 4 x3 = 0
6x 1 - 30 x 2 - 12 x3 = 0
From the first two equations, we have by the cross rule method
x1
x2
x3
- 20
- 10
5
- 20
11
4
-2
11
x3
x1
x2
i.e.,
=
=
- 80 + 110 20 - 20 55 - 40
x1 x 2 x3
i.e.,
=
=
=k
30 0 15
i.e.,
x1 = 30k, x 2 = 0, x3 = 15k
30k
2
1
By taking k = , we get the eigenvector X 2 = 0 .
15
1
43
Page:
0
1
By taking k = , we get the eigenvector X 2 = 1 .
12
- 2
The eigen vector correponding to = 0 is (5,1,0)
The eigen vector correponding to = -1 is (2,0,1)
The eigen vector correponding to = 2 is (0,1,-2)
The three eigenvectors are linearly independent.
44
Page:
45
14
7
-6 5
- 13 10
- 6 4
Solution :
Let A be the given matrix and | A - I | = 0 be its characteri stic equation .
-6 5
- 13 10
- 6 4
6-
-6
14
- 13 -
A = 14
7
i.e.,
7
i.e.,
-6
5
10 = 0
4-
6 -
14
7
-6
- 13 -
-6
10
4 -
x1 0
x 2 = 0
x 0
3
(6 - )x 1 - 6 x 2 + 5 x 3
=0
14x 1 - (13 + ) x 2 + 10 x 3 = 0
7x 1 - 6 x 2 + ( 4 - ) x 3 = 0
- - - - - - - -- >
For a given value of , the components x 1 , x 2 , x 3 of the eigen vector can be computed from
the above set of equations .
When = -1, the above system of equations become
7 x 1 - 6 x 2 + 5x 3 = 0
14x 1 - 12 x 2 + 10 x 3 = 0
7x 1 - 6 x 2 + 5 x 3 = 0
Since the three equations are same, the eigen vectors can be obtained by giving arbitrary values
to any two of the quantities x 1 , x 2 and x 3 .
Page:
x1 =
6
5
k1 - k 2
7
7
where x 2 = k 1 .x 3 = k 2 .
5
6
k1 - k 2
7
7
\ the general eigenvector is
k1
k
2
Putting k 1 = 0, k 2 = 7, we get,
x 1 = -5
i.e., first eigen vector is (-5,0,7).
Putting k 2 = 0, k 1 = 7, we get,
x1 = 6
46
Page:
47
2 1 1
A = 1 2 1
0 0 1
2 1 1
Product of the eigen values = 1 2 1 = 2(2) - 1(1) = 3
0 0 1
3 10 5
2) If 2 and 3 are the eigen values of A = - 2 - 3 - 4 , find the eigen values of A -1 and A 3 .
3 5 7
[Since l1 = 2, l2 =3]
2+3+l3 = 7
l3 = 2
1 1 1
\ the eigen values of A -1 are , , .
2 2 3
3
The eigen values of A are 2 3 ,2 3 ,33
-1 0 0
[Property: The characteristic roots of a triangular matrix are the diagonal elements
of the matrix.]
Since the given matrix is a triangular matrix, the diagonal elements -1, -3, 2 of A will be
the eigen values of A.
\The eigenvalues of A2 are 12 , (-3)2 , (2)2 , i.e., 1, 4, 9.
Page:
a 21 a 22 . a 2 n
x2
y
A=
, X = and Y = 2
.
. . .
x
y
a
a
.
a
n2
nn
n
n
n1
is said to be a linear transformation of vector X into another vector Y.
Characteristic equation
The characteristic equation of the matrix A is |A-lI| = 0. It is a polynomial
equation in l.
Cayley-Hamilton theorem
A matrix A satisfies its own characteristic equation
Characteristic Matrix
The characteristic matrix of A is (A-lI) and is a function of the scalar l.
Characteristic Polynomial
The characteristic polynomial, p(t), of a matrix A is p(t) = |A-lI|.
Properties of eigenvaules
48
Page:
1 1
1
, ,...., .
1 2
n
49
Page:
50
1) Find the sum and product of the eigen values of A = 2 3 4 ( Use property).
3 6 7
3 1 4
3) Define characteristic equation, eigen values and eigen vectors of a square matrix A.
4) State Cayley - Hamilton theorem.
1 3
2 - 1
a) 10 - 12 6
b) 0 2 6 c)
- 8 4
20 - 4 2
0 0 5
d) 2 3 2
e) 1 2 1 f) 0 2 1
3 3 4
0 0 1
0 0 2
1 2
.
7) Find A 8 , if A =
2 - 1
2 -1 1
9) Find the characteristic equation of the following matrix and verify that it is satisfied by the matrix.
1 2
a)
0 2
3 1 - 1
b) 1 3 1
-1 1 3
2 - 2
7
10) Using Cayley - Hamilton theorem find the inverse of the matrix - 6 - 1 2 .
6
2 - 1
Page:
3.7 References
1) Frank Ayres,Jr,Matrices.
2) Prof. A.Singaravelu,Engineering Mathematics I.
3) Dr. M.K Venhataraman, Engineering Mathematics Vol. II.
4) Prof. P.Kandasamy, K.Thilagavathy, and K.Gunavathy, Engineering
Mathematics.
5) Wikipedia, the free encyclopedia.
51
Page:
52
Unit II
Lesson 4
Set Theory
Contents:
4.0 Aims and objectives
4.1 Introduction
4.2 Set and its elements
4.3 Set Description
4.4 Types of Sets
4.5 Venn-Euler Diagrams
4.6 Let Us Sum Up
4.7 Lesson End Activities
4.8 References
4.0 Aims and objectives
In this lesson, we have discussed about set theory and Venn-Euler Diagrams.
After reading this lesson, you should able to
4.1 Introduction
The concept of set theory, originated in 1895 by the German mathematician
G.Cantor, is used in various disciplines. This chapter introduces the notation and
terminology of set theory.
Page:
53
Examples:
i)
ii)
iii)
iv)
Elements of a set:
The objects of a set are called its elements or members conventionally, capital
letters A, B, C, D, etc. are used to denote sets and lower case letters a, b, c, d, etc. are
used to denote its members.
The symbol is used to indicate belongs to. The statement p is an element of
A is written as p A. The symbol is used to indicate does not belongs to. The
statement q is not an element of A is written as q A.
Some standard sets
Some sets occur very often in the text and so we use special symbols for them. They are
i)
The set of Natural numbers i.e. N = { 1, 2, 3, 4, }
ii)
The set of Integers (or countable numbers) i.e. I = { ,-3, -2, -1, 0, 1, 2, 3, }
iii)
The set of Positive Integers i.e. I+ = { 1, 2, 3, }
iv)
The set of rational numbers
p
i.e. Q = {x : x = , where p and q are integers and q 0 }
q
Remark
1) The quantitative attributes like honest persons, rich person, beautiful women,
etc do not form sets.
4.3 Set Description
There are two different ways for describing a set. They are
1) Roster method and
2) Set Builder method.
Page:
54
1) Roster Method
In this method the members are represented as a list. For example,
V = {a, e, i, o, u}
denotes the set V whose elements are the letters a, e, i, o, u. Note that the elements
of the set are separated by commas and enclosed in braces {}.
2) Set Builder method
Sometimes we cannot list the elements of a set explicitly. In this method, the
set is defined by stating the properties which characterizing the members. For
example,
V = {x : x is a vowel in English alphabet}
B = {x : x is an even integer, x > 0 }
4.4 Types of Sets
Finite set
A set having finite number of elements or members is known as finite set.
Examples:
1) The set of months in a year.
2) The set of vowels in the English alphabet.
Infinite set
A set having infinite number of elements or members is known as infinite set.
Examples:
3) The set of all natural numbers i.e. N = { 1, 2, 3, 4, }
4) The set of integers, I = { , -3, -2, -1, 0, 1, 2, 3, }
Null set
A set with no elements is called the empty set or null set and is denoted by
(read as phi) or {}.
For example,
A = {x : x3 + 4 = 0, x is real }
Equality of sets
Two sets A and B are said to be equal if every element of A is an element of B
and also every element of B is an element of A. If the sets A and B are equal, they are
denoted by A = B.
Page:
55
For example,
i)
If A = {4, 3, 2, 1} and B = {1, 3, 4, 2} then A=B, because both have same
and equal number of elements.
ii)
If A = set of all integers whose square is 9,
B = set of all roots of the equation, x2 9 = 0 and
C = {-3, +3}
then A = B.
Equivalent Sets
Let A and B are two sets. The sets A and B are said to be equivalent sets if and
only if there exists a one-to-one correspondence between their elements. By one-toone correspondence we mean that for each element in A, there exists and match with
one element in B and vice versa.
The symbol , ~ or is used to denote equivalent sets.
Illustration
A = {x : x is a letter in the word BOAT}
B = {x : x is a letter in the word CART}
Thus A B.
Subset
Let A and B be two non-empty sets. If every element of A is also an element of B,
then A is called a subset of B. This relationship is written as A B or B A.
If A is not a subset of B, i.e. if at least one element of A does not belong to B, we
write A B.
Theorem
i)
ii)
iii)
iv)
Page:
56
Power Set
If A is any set, then the family of all the subsets of A is called power set of A and
is denoted by P(A), i.e. P(A) = { B : B A}. Obviously, and A are both members of
P(A).
Illustrations
i)
ii)
iii)
Number of subsets
The number of subsets of a set with n elements is 2n -2 (leaving and the full set)
,A are called improper subsets of A.
Number of proper subsets
The number of proper subsets of a set with n elements is 2n 1.
Universal set
In every problem there is either a stated or implied universe of discourse. The
universe of discourse includes all things under discussion at a given time. In the
mathematical theory of sets, the universe of discourse is called the universal set. The
letter U is typically used for the universal set. The universal set might well change from
problem to problem.
4.5 Venn-Euler Diagrams
In most areas of mathematics, our reasoning can be aided and clarified by
utilizing various kinds of drawings and diagrams. In set theory, we commonly use Venn
diagrams, developed by the logician John Venn (1834-1923). In these diagrams, the
universal set is represented by a rectangle, and other sets of interest within the universal
set are depicted by oval regions, or sometimes by circles or other shapes.
If the sets A and B are equal, then the same circle represents both A and B. If the
sets A and B are disjoint, i.e. they have no elements in common, then circles representing
A and B are drawn in such a way that they have no common area as shown in figure(a).
However if few elements are common both in A and B, then sets A and B are in general
represented as in figure(b).
Page:
57
Page:
58
Power Set
If A is any set, then the family of all the subset of A is called power set of A
and is denoted by P(A), i.e. P(A) = { B : B A}. Obviously, and A are both
members of P(A).
Number of subsets
The number of subsets of a set with n elements is 2n .
Number of proper subsets
The number of proper subsets of a set with n elements is 2n 2.
Universal set
The universe of discourse is called the universal set. The letter U is used for the
universal set.
Venn-Euler Diagrams
In these diagrams, the universal set is represented by a rectangle, and other sets of
interest within the universal set are depicted by oval regions, or sometimes by circles
or other shapes.
Page:
59
6. For each of the sets in Exercise 5, determine whether {2} is an element of that
set.
7. Use a Venn diagram to illustrate the relationship A B and B C.
8. Suppose that A, B, and C are sets such that A B and B C. Show that A C.
9. Find two sets A and B such that A B and A B.
10. What is the cardinality of each of these sets?
a) {a}
b) {{a}}
c) {a,{a}}
d) {a,{a},{a,{a}}}
11.What is the cardinality of each of these sets?
a)
b) {}
c) {, {}}
d) {,{},{,{}}}
Page:
60
Page:
4.8 References
1) J K Sharma, Discrete Mathematics
2) Kenneth H.Rosen, Discrete Mathematics and its Applications
3) Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4) Charles D.Miller and Others, Mathematical Ideas
5) Wikipedia, the free encyclopedia.
61
Page:
62
Unit II
Lesson 5
Set operations and laws of set theory
Contents:
5.0 Aims and objectives
5.1 Introduction
5.2 Set operations and laws of set theory.
5.2.1 Union of sets
5.2.2 Intersection
5.2.3 Disjoint
5.2.4 Difference of two sets
5.2.5 Complement of a set
5.3 Algebra of sets and Duality
5.3.1 Set Identities
5.3.2 Duality
5.3.3 Proofs using set builder notation, membership tables and Venn diagrams
5.4 Partitions of sets
5.5 Minsets
5.6 Let Us Sum Up
5.7 Lesson End Activities
5.1 Introduction
In this section we will discuss the various operators that are used to combine two
or more sets and how to work with sets using set algebra and duality.
.
Page:
63
Page:
64
AA=
A =A
ABA
A B, A B and B-A are mutually disjoint
(A B) B =
(A B) A = A
Example 2
1. If N = { 1,2,3,4,} is the universal set and
let A = {1,3,5,7, }, then A = N A = { 2,4,6,8,}
2. U = and = U
Properties
1. A A = U
2. A A =
3. U =
4. = U
5. (A) = A
6. (A B) = A B
7. If A B, then A (B A) = B
8. (A B) = A B
9. (A B) = A B
Page:
65
Identity
A=A
AU=A
AU=U
A=
AA=A
AA=A
(A) = A
AB=BA
AB=BA
A (B C) = (A
A (B C) = (A
A (B C) = (A
A (B C) = (A
(A B) = A B
(A B) = A B
A (A B) = A
A (A B) = A
A A = U
A A =
B) C
B) C
B) (A C)
B) (A C)
Associative laws
Distributive laws
De Morgans laws
Absorption laws
Complement laws
5.3.2 Duality
Note that the identities in table 5.1 are arranged in pairs. The principle behind this
arrangement is just the replacement of sets and operators. Suppose E is an equation of set
algebra. The dual E* of E is the equation obtained by replacing each occurrence of , ,
U and in E by , , and U, respectively. For example, the dual of
(U A) (B A) = A is ( A) (B A) = A
Page:
5.3.3 Proofs using set builder notation, membership tables and Venn diagrams
a) Prove the distributive laws using set builder notation and logical equivalence.
1) Prove A (B C) = (A B) (A C)
Proof: Let x is an arbitrary element of A (B C). Then
x A (B C) x A or x (B C)
x A or (x B and x C)
(x A or x B) and (x A or x C)
x (A B) and x (A C)
x (A B) (A C)
Hence A (B C) = (A B) (A C)
2) Prove A (B C) = (A B) (A C)
Proof: Let x is an arbitrary element of A (B C). Then
x A (B C) x A and x (B C)
x A and (x B or x C)
(x A and x B) or (x A and x C)
x (A B) and x (A C)
x (A B) (A C)
Hence A (B C) = (A B) (A C)
b) Prove the distributive laws using membership tables.
Set identities can also be proved using membership tables. To indicate that an
element in a set, a Y is used; to indicate that an element is not in a set, a N is used.
Table: 1
A membership table for the Distributive law A (B C) = (A B) (A C)
A
Y
Y
Y
Y
N
N
N
N
B
Y
Y
N
N
Y
Y
N
N
C
Y
N
Y
N
Y
N
Y
N
BC
Y
Y
Y
N
Y
Y
Y
N
A (B C)
Y
Y
Y
N
N
N
N
N
AB
Y
Y
N
N
N
N
N
N
AC
Y
N
Y
N
N
N
N
N
(A B ) (A C)
Y
Y
Y
N
N
N
N
N
66
Page:
Table: 2
A membership table for the Distributive law A (B C) = (A B) (A C)
67
A
Y
Y
Y
Y
N
N
N
N
B
Y
Y
N
N
Y
Y
N
N
C
Y
N
Y
N
Y
N
Y
N
BC
Y
N
N
N
Y
N
N
N
A (B C)
Y
Y
Y
Y
Y
N
N
N
AB
Y
Y
Y
Y
Y
Y
N
N
AC
Y
Y
Y
Y
Y
N
Y
N
(A B ) (A C)
Y
Y
Y
Y
Y
N
N
N
Fig. 5.2
Here the figures 5.2 (b) and 5.2 (e) are same and hence proved.
Page:
68
Example 3
Let A = {10,11,12,13}. Then A1 ={10}, A2 = {11,12}, A3 ={13} are the partitions
of A.
5.5 Minsets
Let X = {B1 ,B2 ,B3 ,,Bn } where the elements B1 ,B2 , etc are the subsets of a set A.
Then the set of the form C1 C2 C3 Cn, where each Ci may be either Bi or its
complement i.e. Bi is called a minset or minterm, generated by Bi s (i = 1,2,...,n).
Example 4
Let B1 = {1,4,6} and B2 = {1,3,4} be two subsets of A = {1,2,3,4,5,6}. In order to
have a partition of A without repetition of elements, we may describe B1 and B2 a s
follows:
C1 = B1 B '2 = {1,4,6} {2,5,6} = {6}
C 2 = B1 B 2 = {1,4,6} {1,3,4} = {1,4}
C 3 = B1' B 2 = {1,4,6} {2,5,6} = {3}
Page:
69
As shown in fig. 5.4, none of the sets C1 ,C2 ,C3 and C4 have elements in common, the set
generated by B1 and B2 is the partition of A.
Page:
A A =
U =
= U
(A) = A
(A B) = A B
If A B, then A (B A) = B
(A B) = A B
(A B) = A B
70
Page:
71
Set Identities
Set Identities
Name
Identity laws
Identity
A=A
AU=A
AU=U
A=
AA=A
AA=A
(A) = A
AB=BA
AB=BA
A (B C) = (A B) C
A (B C) = (A B) C
A (B C) = (A B) (A C)
A (B C) = (A B) (A C)
(A B) = A B
(A B) = A B
A (A B) = A
A (A B) = A
A A = U
A A =
Domination laws
Idempotent laws
Complementation law
Commutative laws
Associative laws
Distributive laws
De Morgans laws
Absorption laws
Complement laws
Duality
The dual E* of E is the equation obtained by replacing each occurrence of , , U
and in E by , , and U, respectively.
Partitions of sets
Let A be a non-empty set. The partition of A is any set of non-empty, nonoverlapping subsets A1 , A2 , A3 , A4 ,, An such that
A = A1 A2 An
i)
The subsets Ai are mutually disjoint, i.e. Ai Aj = for i = j.
ii)
Page:
b) A = .
d) A A = A.
f) A U =U.
h) - A = .
b) A B = B A.
72
Page:
73
Unit II
Lesson 6
The inclusion-Exclusion Principle
Contents:
6.0 Aims and objectives
6.1 Introduction
6.2 The inclusion-Exclusion Principle
6.3 Problems and Solutions
6.4 Lesson End Activities
6.5 References
6.0 Aims and objectives
In this lesson, we have discussed about the Inclusion- Exclusion Principle.
After reading this lesson, you should be able to
6.1 Introduction
The Inclusion-Exclusion Principle method is used in finding the number of
elements in a finite set (also called cardinal number). While applying this principle some
terms are Included and some terms are excluded from an expression, so the name
Inclusion-Exclusion Principle.
Page:
74
n(A ) - n(A
i
1 i n
Aj)
1 i< j n
n(A
1 i < j < k n
Example 1
i)
ii)
Page:
75
Page:
76
2) A TV survey shows that 60 per cent people see program A, 50 per cent see program B,
50 per cent see program C, 30 per cent see program A and B, 20 per cent see program B
and C, 30 per cent see program A and C, and 10 per cent do not see any program. Find
(a) What per cent see program A, Band C? .
(b) What per cent see exactly two programs?
(c) What per cent see program A only?
Solution Suppose X, Y and Z denote the set of people who see program A, Band C,
respectively. Then it is given that
n(X) = 60, n(Y) = 50, n(Z) = 50, n(X Y) = 30, n(Y Z) = 20, n(X Z) = 30
n[(X Y Z)] = 10
.
(a) Let n( X Y Z) + n[ (X Y Z)] = 100.
Then n( X Y Z ) = 100 - n[ (X Y Z)] = 100 - 10 = 90
But n( X Y Z) = n(X)+n(Y)+n(Z)- n(X Y)-n(Y Z)- n(X Z)+n( XYZ)
90 = 60 + 50 + 50 - 30 - 20 - 30 + n(X Y Z)
or n(X n Y n Z) = 90 - 80 = 10
Thus, 10 per cent people see program A, Band C.
(b) Since the set of people who see program A and B but not C, i.e. X Y Z and the
set of people who see all the program A, Band C, i.e. X Y Z are disjoint sets,
therefore
Page:
77
n( X Y Z) + n( X Y Z)
= n( X Y )
n(X Y Z) = n(X Y) - n(X Y Z)
= 30 - 10 = 20,
n(X Y Z) + n(X Y Z) = n(X n Z)
n(Z Y Z) = n(X Z) - n(X Y Z)
= 30 - 10 = 20,
n(XC n Y n Z) + n(X n.Y n Z)
= n(Y n Z)
n(X Y Z) = n(Y Z) - n(X Y Z) = 20 - 10 = 10.
Thus, the percentage of people who see exactly two program = 20 + 20 + 10 = 50.
(b) Since n(X Y Z) = n(X) n(X Y) - n(X Z) + n(X Y Z)
= 60 - 30 - 30 + 10 = 10
Thus, the percentage of people who see program A only is 10.
3) In a pollution study of 1,500 Indian rivers, the following data were reported: 520 were
polluted by sulphur compounds, 335 were polluted by phosphates, 425 were polluted by
crude oil, 100 were polluted by both crude oil and sulphur compounds, 180 were polluted
by sulphur compounds and phosphates, 150 were polluted by both phosphates and crude
oil and 28 were polluted by sulphur compounds, phosphates and crude oil. How many of
the rivers were polluted by at least one of the three impurities? How many rivers were not
polluted by exactly one of the three impurities? How many of the rivers were not
polluted?
Solution: Suppose S, P and C denote the set of rivers polluted by sulphur compounds,
phosphates and crude oil, respectively. Then it is given that
.
n(S) = 520, n(P) = 335, n(C) = 425, n(C S) = 100,
n(S P) = 180, n(P C) = 150, n(S P C) = 28.
(a) Number of rivers polluted by at least One of the three impurities
n(S P C)
= n(S)+n(P) + n(C)-n(S P)-n(PC)-n(CS) + n(SPC)
= 520 + 335 + 425 - 100 - 180 - 150 + 28 = 878
(b) Number of rivers polluted by exactly sulphur compounds
n(S P C) = n[ S (P C)] = n(S) - n(S P) - n(S C) + n(S P C)
= 520 - 180 - 100 + 28 = 268
Page:
78
Page:
79
6) In a survey concerning the smoking habits of consumers, it was found that 55 per cent
smoke cigarette A, 50 per cent smoke B, 42 per cent smoke C, 28 per cent smoke A and
B, 20 per cent smoke A and C, 12 per cent smoke Band C and 10 per cent smoke all the
three cigarettes.
(a) What percentage does not smoke?
(b) What percentage smokes exactly two brands of cigarettes?
Solution Let A, B, C be the sets of persons who smoke brand A, B, and C, respectively.
It is given that
n(A) = 55; n(B) = 50; n(C) = 42; n(A B) = 28;
n(A C) = 20; n(B C) = 12; and n(A B C) = 10.
(a) Now (A B C) is the set of all person who smoke either A or B or C; or any two
brands or all the brands and (A u B u C) is the set of persons who do not smoke.
Therefore,
n(A B C) = n(A) + n(B) + n(C)-n(A B)- (B C)- n(A C)+n(A B C)
= 55 + 50 + 42 28 12 20 + 10 = 97
But,
n(A B C)= 100 - n(A B C) = 100 - 97 = 3
Hence, 3 per cent persons do not smoke.
(b) A B C is the set of persons who smoke A and B, but not C and (A n B n C) is
the set of persons who smoke all the 3 brands A, B, and C. Therefore
n(A B) = n(A B C) + n(A B C)
28 = n(A B C) + 10 or n(A B C) = 18.
Similarly, n(A B C) = 10 and n(A B C) = 2.
Hence, total required number = 18 + 10 + 2 = 30.
7) In a class of 25 students, 12 have taken economics, 8 have taken economics but not
political science. Find the number of students who have taken economics and political
science and those who have taken politics but not economics.
Solution Suppose A and B denote the set of students who take economics and political
science, respectively. It is given that
n(A) = 12, n(A u B) = 25, and n(A n BC) = 8.
Now we have to find the number of students who have taken economics and
political science, i.e. n(A B) and the number of students who have taken political
science but not economics, i.e. n(B A). Now
n(A) = n(A B) + n(A B)
or
12
= 8 + n(A B)
or
n(A B) = 12 8 = 4
Also n(A B) = n(A) + n(B) n(A B)
25 = 12 + n(B) 4 or n(B) = 17.
Again, n(B) = n(A B) + n(B A).
Therefore
17 = 4+ n(B A) or n(B A)= 17 4 = 13.
Page:
80
Page:
81
n(A ) - n(A
i
1 i n
Aj)
1 i< j n
n(A
1 i < j < k n
Results
Page:
6.5 References
1) J K Sharma, Discrete Mathematics
2) Kenneth H.Rosen, Discrete Mathematics and its Applications
3) Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4) Charles D.Miller and Others, Mathematical Ideas
5) Wikipedia, the free encyclopedia.
82
Page:
Unit III
Lesson 7
Mathematical Logic
Contents
7.0 Aims and objectives
7.1 Introduction
7.2 Propositional calculus
7.2.1 Propositions
7.2.2 Types of Propositions
7.2.3 Basic Logical Operations
7.2.4 Derived Connectives
7.3 Conditional statement
7.3.1 Special characteristics of conditional statements
7.3.2 Converse, Inverse and Contrapositive
7.4 Biconditional statement
7.5 Problems and Solutions
7.6 Let Us Sum Up
7.7 Lesson End Activities
83
Page:
84
Page:
85
--- (1)
--- (2)
and
or
implies
if and only if
Type of statement
Negation
Conjunction
Disjunction
implication or conditional
equivalence or biconditional
Page:
86
Truth Table: It shows the relationship between the truth- value of a compound
proposition and the truth-values of its constituent simple propositions.
7.2.3 Basic Logical Operations
The basic logical operations are conjunction, disjunction and negation.
Conjunction
Let p and q be propositions. The proposition p and q, denoted by p q, is true
when both p and q are true and is false otherwise. The statement p q is called the
conjunction of p and q.
The truth table for the conjunctions of two propositions is given in the table 3.2.
Table 3.2
p
q
T
T
T
F
F
T
F
F
p q
T
F
F
F
Illustration
a) Consider the following four compound statements
1)
2)
3)
4)
Only the first statement is true. Each of the other statements is false, since at least
one of its simple statements is false.
Disjunction
Let p and q be propositions. The proposition p or q, denoted by p q, is false
when both p and q are false and is true otherwise. The statement p q is called the
disjunction of p and q.
The truth table for the disjunctions of two propositions is given in the table 3.3.
Table 3.3
p
q
T
T
T
F
F
T
F
F
p q
T
T
T
F
Page:
87
Illustration
b) Consider the following four compound statements
1)
2)
3)
4)
Only the last statement is false. Each of the other statements is true, since at least one of
its simple statements is true.
The disjunction may be either Inclusive or Exclusive. In the inclusive disjunction
the compound statement p q is true only when at least one of the statement is true. But
in the exclusive disjunction, commonly called inequivalence, the compound statement p
q is true only when either p or q but not both, is true.
Example 1
Let
Page:
88
p-q
F
T
T
T
NOR
It is obtained by negating the result of ORing of two statements.
For example, if p and q are two statements then ORing of these two statements, denoted
by p q, is true when both p and q are false, otherwise false. Its truth table is given in the
table 3.6.
Table 3.6
p
q
T
T
T
F
F
T
F
F
pq
F
F
F
T
XOR
If p and q are two statements then XORing of these two statements, denoted by p
q, is false when both p and q are same, otherwise true. Its truth table is given in the
table 3.7.
Table 3.7
p
q
T
T
T
F
F
T
F
F
pq
F
T
T
F
Page:
89
pq
T
F
T
T
Page:
90
pq
qp
pq
qp
Page:
91
Using this definition, the truth table for the biconditional p q can be determined as
shown in table 3.9.
Table 3.9
p
q
pq
T
T
T
T
F
F
F
T
F
F
F
T
Example 2
Tell whether each biconditional statement is true or false.
(a) 6+9= 15 if and only if 12+4= 16
Both 6 + 9 = 15 and 12 + 4 = 16 are true. By the truth table for the biconditional,
this biconditional is true.
(b) 5 + 2 = 10 if and only if 17 + 19 = 36
.
Since the first component (5 + 2 = 10) is false, and the second is true, the entire
biconditional statement is false.
(c) 6=5 if and only if 1212
Both component statements are false, so by the last line of the truth table for the
biconditional, the entire statement is true. (Understanding this might take some extra
thought!) .
Page:
(b) p - q - r
(c) p q r
Q
T
T
F
F
T
T
F
F
(p q)
F
F
F
F
F
F
T
T
r
T
F
T
F
T
F
T
T
(p r)
F
F
F
F
F
T
F
T
(p q) (p r)
F
F
F
F
F
F
F
T
Q
T
T
F
F
T
T
F
F
p-q
F
F
T
T
T
T
T
T
r
T
F
T
F
T
F
T
F
p- q- r
T
T
F
T
F
T
F
T
q
T
T
F
F
T
T
F
F
r
T
F
T
F
T
F
T
F
pq
F
F
T
T
T
T
F
F
pqr
T
F
F
T
F
T
T
F
92
Page:
93
T
F
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
T
F
F
F
F
T
F
F
T
T
F
Since values in Columns (3) and (8) are same, therefore two compound statements are
equivalent.
4) If p and q are two statements, then show that the statement (p q) (p q) is
equivalent to p-q.
Solution: The equivalence of two compound statements is shown in truth Table 3.15.
Truth table: 3.15 (p q) (p q) and p-q
p
q
(p q)
(p q)
(p q) (p q) p-q
(1)
(2)
(3)
(4)
(5)
(6)
T
T
F
F
F
F
T
F
T
F
T
T
F
T
T
F
T
T
F
F
F
T
T
T
Since values in Columns (5) and (6) are same, therefore two compound statements are
equivalent.
Page:
Symbols
and
or
not
if. . . then
if and only if
Types of
Statements
Conjunction
Disjunction
Negation
Conditional
Biconditional
Truth Tables
p
T
F
p
T
T
F
F
q
T
F
T
F
p q
T
F
F
F
p
F
T
p-q
F
T
T
T
p q
T
T
T
F
pq
F
F
F
T
pq
F
T
T
F
pq
T
F
T
T
pq
qp
pq
qp
pq
T
F
F
T
94
Page:
95
Page:
96
Unit III
Tautology, Contradiction and Arguments
Lesson 8
Contents
8.0 Aims and Objectives
8.1 Introduction
8.2 Tautology
8.3 Contradiction
8.4 Arguments
8.4.1 Valid and Invalid Arguments
8.4.2 Using Truth Tables to Analyze Arguments
8.5 Problems and Solutions
8.6 Chapter Summary
8.7 Lesson End Activities
8.8 References
8.0 Aims and Objectives
The main aim and objective of this lesson is to know about the Tautology,
Contradiction and Arguments.
After reading this unit, students should be able to
Identify the statements that are Tautology or Contradiction.
Test the validity of this argument
8.1 Introduction
In this lesson we are going to discuss about the certain compound propositions
that are always true or false irrespective of the truth values of its component propositions.
The statement that is always true is called a tautology. The statement that is always false
is called Contradiction. We also discussed the method of testing the validity of an
argument.
Page:
97
8.2 Tautology
Definition: A statement that represents the constant T is called a tautology. In other
words, the statement is true for all truth values of the statement variables i.e. a tautology
contain only T in the last column of their truth table.
For example, the proposition p or not p, that is, p p, is a tautology.
Table
p
p
T
F
F
T
p p
T
T
q
T
F
T
F
p
F
F
T
T
q
F
T
F
T
( p) ( q)
F
T
T
T
(( p) ( q)) p
T
T
T
T
8.3 Contradiction
Definition: A statement that represents the constant F is called a contradiction. In other
words, the statement is false for all truth values of the statement variables i.e. a
contradiction contain only F in the last column of their truth table.
.
Example 2: The proposition p and not p, that is, p p, is a contradiction.
Table
p
p
T
F
F
T
p p
F
F
Note that the negation of a tautology is a contradiction since it is always false, and
the negation of a contradiction is a tautology since it is always true.
Page:
98
8.4 Arguments
There are two types of reasoning: inductive and deductive. So far we have concentrated
on using inductive reasoning to observe patterns and solve problems. Now, in this section
and the next, we will study how deductive reasoning may be used to determine whether
logical arguments are valid or invalid. A logical argument is made up of premises
(assumptions, laws, rules, wide ideas, or observations) and a conclusion. Together, the
premises and the conclusion make up the argument. Also recall that deductive reasoning
involves drawing specific conclusions from given general premises. When reasoning
from the premises of an argument to obtain a conclusion, we want the argument to be
valid.
8.4.1 Valid and Invalid Arguments
An argument is valid if the fact that all the premises are true forces the conclusion
to be true. An argument that is not valid is invalid, or a fallacy.
It is very important to note that "valid" and "true" are not the same - an argument can be
valid even though the conclusion is false (See Example below).
Definition
An argument is an assertion that a given set of propositions P1 , P2 , , Pn called
premises, yields ( has a consequence) another proposition Q, called the conclusion. Such
an argument is denoted by
P1 , P2 , , Pn
Q
Several techniques, like Euler diagrams (visual technique) and the method of truth
table, can be used to check whether an argument is valid. In this section the method of
truth tables is shown.
8.4.2 Using Truth Tables to Analyze Arguments
While Euler diagrams often work well for simple arguments, difficulties can
develop with more complex ones. These difficulties occur because Euler diagrams
require a sketch showing every possible case. In complex arguments it is hard to be sure
that all cases have been considered.
In deciding whether to use Euler diagrams to test the validity of an argument look
for quantifiers such as "all," "some," or "no." These words often indicate arguments best
tested by Euler diagrams. If these words are absent, it may be better to use truth tables to
test the validity of an argument.
Page:
99
p]
premise
and
premise
implies
conclusion
pq
(p q) (p)
[(p q) p] q
T
T
F
F
T
F
T
F
T
F
T
T
T
F
F
F
T
T
T
T
Since the final column, indicates that the conditional statement that represents the
argument is true for all possible truth values of p and q, the statement is a tautology.
Thus, the argument is valid.
The pattern of the argument in the example 3 (floor- mopping),
p q
p
-------q
is a common one, and is called modus ponens, or the law of detachment.
Page: 100
In summary, to test the validity of an argument using truth tables, follow the steps in
the box that follows.
Testing the Validity of an Argument with a Truth Table
1. Assign a letter to represent each simple statement in the argument.
2. Express each premise and the conclusion symbolically.
3. Form the symbolic statement of the entire argument by writing the conjunction of all
the premises as the antecedent of a conditional statement, and the conclusion of the
argument as the consequent.
4. Complete the truth table for the conditional statement formed in part 3 above. If it is a
tautology, then the argument is valid; otherwise, it is invalid.
Page: 101
q
T
F
T
F
p
F
F
T
T
q
F
T
F
T
( p) q
T
F
T
T
p ( q)
F
T
F
F
(( p) q) (p ( q))
T
T
T
T
The last column contains only T. Therefore the given statement is a tautology.
2) Determine whether the argument is valid or invalid.
If my check arrives in time, I'll register for the Fall semester.
I've registered for the Fall semester.
-------------------------------------------------------------------------My check arrived in time.
Let p represent "my check arrives (arrived) in time" and let q represent "I'll register
(I've registered) for the Fall semester." Using these symbols, the argument can be written
in the form
p q
q
-------p
To test for validity, construct a truth table for the statement [(p q) q] p.
p
pq
(p q) (q)
[(p q) q] p
T
T
F
F
T
F
T
F
T
F
T
T
T
F
T
F
T
T
F
T
The third row of the final column of the truth table shows F, and this is enough to
conclude that the argument is invalid.
If a conditional and its converse were logically equivalent, then an argument of
the type found in the above example would be valid. Since a conditional and its converse
are not equivalent, the argument is an example of what is sometimes called the fallacy of
the converse.
Page: 102
pq
(p q) ( q)
[(p q) q] p
T
T
F
F
T
F
T
F
T
F
T
T
F
T
F
T
F
F
F
T
F
F
T
T
T
T
T
T
The pattern of reasoning of this example is called modus tollens, or the law of
contraposition, or indirect reasoning.
With reasoning similar to that used to name the fallacy of the converse, the
fallacy
p q
p
-------q
is often called the fallacy of the inverse. An example of such a fallacy is "If it rains, I get
wet. It doesn't rain. Therefore, I don't get wet."
4) Determine whether the argument is valid or invalid.
I'll buy a car or I'll take a vacation.
I won't buy a car.
----------------------------------------I'll take a vacation.
Page: 103
If p represents "I'll buy a car" and q represents "I'll take a vacation," the argument
becomes
p q
p
-------q
We must set up a truth table for
[(p q) p] q
p
p q
(p q) ( p)
[(p q) q] q
T
T
F
F
T
F
T
F
T
T
T
F
F
F
T
T
F
F
T
T
T
T
T
T
The statement is a tautology and the argument is valid. Any argument of this form is
valid by the law of disjunctive syllogism.
5) Determine whether the argument is valid or invalid.
If it squeaks, then I use WD-40.
If I use WD- 40, then I must go to the hardware store.
---------------------------------------------------------------If it squeaks, then I must go to the hardware store.
Let p represent "it squeaks," let q represent "I use WD-40," and let r represent "I must go
to the hardware store." The argument takes on the general form
Make a truth table for the following statement:
p q
q r
-------p r
Page: 104
p q
qr
pr
(p q) (qr)
[(p q) (qr)] (p r)
T
T
T
T
F
F
F
F
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
T
T
F
F
T
T
T
T
T
F
T
T
T
F
T
T
T
F
T
F
T
T
T
T
T
F
F
F
T
F
T
T
T
T
T
T
T
T
T
T
This argument is valid since the final statement is a tautology. The pattern of argument
shown in this example is called reasoning by transitivity, or the law of hypothetical
syllogism. .
Page: 105
Disjunctive
Syllogism
p q
p
------q
Reasoning by
Transitivity
pq
qr
------pr
Page: 106
q: I get A's.
r: I get rich.
Page: 107
In Exercises 16-20, write the given argument in words and determine whether each
argument is valid. Let
p: 4 megabytes is better than no memory at all.
q: We will buy more memory,
r: We will buy a new computer.
16.
p r
p q
---------------\p ( rq)
17.
p (rq)
r q
------------\p r
18.
pr
rq
---------\q
19.
r p
r
----------\p
pr
rq
p
----------\q
20.
Page: 108
8.8 References
1) J K Sharma, Discrete Mathematics
2) Kenneth H.Rosen, Discrete Mathematics and its Applications
3) Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4) Charles D.Miller and Others, Mathematical Ideas
5) Wikipedia, the free encyclopedia.
Page: 109
Unit III
Lesson 9
Method of proof and Predicate Calculus
Contents
9.0 Aims and objectives
9.1 Introduction
9.2 Method of Proof
9.2.1 Direct Proof
9.2.2 Proof by contradiction (or Indirect Proof)
9.3 Predicate Calculus
9.4 Quantifiers
9.5 Mathematics and Predicate Calculus
9.6 Let Us Sum Up
9.7 References
9.0 Aims and objectives
In this lesson, we have discussed method of proofs and predicate calculus. With
the proof methods, one can arrive at a conclusion from the given sequence of premises.
9.1 Introduction
An argument that establishes the truth of a theorem is called a proof. Logic is a
tool for the analysis of proofs. In this lesson, we describe some general methods of proof.
In the previous lesson we have discussed the propositional logic which is not sufficient
for all our logic needs. We need to go beyond the propositional calculus to the predicate
calculus, which allows us to manipulate statements and to express Mathematics. This and
other logics are employed in the design of expert systems, robots and artificial
intelligence. We have discussed predicate calculus in this lesson.
Page: 110
Page: 111
Example 2
Page: 112
The only difference between the assumptions in a direct proof and a proof by
contradiction is the negated conclusion. In a direct proof the negated conclusion is not
assumed, where as in a proof by contraciction the negated conclusion is assumed.
Proof by contradiction may be justified by noting that the propositions p q and
p q r r are equivalent. The equivalence is immediate from a truth table.
p q
p q
r r
p q r r
T
T
T
T
F
F
F
F
T
T
F
F
T
T
F
F
T
F
T
F
T
F
T
F
T
T
F
F
T
T
T
T
F
F
T
T
F
F
F
F
F
F
F
F
F
F
F
F
T
T
F
F
T
T
T
T
Example 4:
We will give a proof by contradiction of the following statement:
For all real numbers x and y, if x+y 2, then either x 1 or y 1.
Proof:
Suppose that the conclusion is false. Then x < 1 and y < 1.
Using a above mentioned theorem, we may add these inequalities to obtain
x+y < 1+1 =2.
At this point, we have derived the contradiction p p, where p: x+y 2.
Thus we conclude that the statement is true.
Example 5 Let the following statements be true.
. If I am lazy, then I do not study.
. I study or I enjoy myself.
. I do not enjoy myself.
Show that the statement 'I am not lazy' is a true statement.
Solution Let p, q and r represent the statements
p : I am lazy
q : I study
r : I enjoy myself
Consider premises that the statements
p q, q r and r
are true. Then we shall prove that the statement p is true.
Assuming that p is true. Since p is true and p q, then q is true. Thus, q is false.
Also, r is false. But either q or r is true. This is not possible This contradiction implies
that the assumption that p is true is false and hence p is true.
Page: 113
Page: 114
then write Px
for the statement form. (It is
traditional to write the predicate before the term; this is related to the convention of
writing function names before variables in other parts of mathematics.) Similarly, if we
use
Q
to
represent
the
predicate
"is
mortal"
then
write
the
statement
"If
is
Page: 115
symbol ""
" to stand for the words "for all"
or "for every." Thus, we can write our complete statement as
Page: 116
"
x [Px
Qx ].
Page: 117
Page: 118
Px
Page: 119
quantifier
we are claiming is true for all x.
Page: 120
Definition (Predicate and truth set) A predicate is any function whose codomain is
statements that are either true or false. There are two things to be careful about:
The codomain is statements not the truth value of the statements.
The domain is arbitrary different predicates can have different domains.
The truth set of a predicate S with domain D is the set of those x D for which S(x) is
true. It is written
{x D | S(x) is true} or simply {x | S(x)}.
Page: 121
Negation
Let us go back for a moment to the statement "All men are mortal":
Page: 122
"
x [Px
Qx ].
Question
Page: 123
x [Px
Page: 124
Qx]
Page: 125
, say?
Answer
Literally, it says: "It is not true that all men are mortal." More succinctly,
"Some men are immortal."
Page: 126
"
x [Px
Qx ].
Page: 127
Page: 128
"
x [(Nx
(x >1))
Page: 129
(x >0)].
Notice that we put the phrases "x>1" and "x>0" in parentheses to make the meaning
clearer.
Page: 130
Page: 131
9.7 References
1) J K Sharma, Discrete Mathematics
2) Kenneth H.Rosen, Discrete Mathematics and its Applications
3) Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4) Charles D.Miller and Others, Mathematical Ideas
5) Wikipedia, the free encyclopedia.
6) Richard JohnsonBaugh, Discrete Mathematics
Page: 132
Unit IV
Relations
Lesson 10
Contents
10.0 Aims and Objectives
10.1 Introduction
10.2 Product of sets
10.3 Binary Relations
10.4 Types of relations
10.5 Problems and Solutions
10.6 Chapter Summary
10.7 References
10.0 Aims and Objectives
In this lesson, we have discussed about the Product of sets, Binary Relations and
Types of relations.
After completing this lesson, you should able to
10.1 Introduction
In mathematics and computer science, there are many relations used to establish a
relation between pair of objects taken in a definite order. For example, less than, is
parallel to, is a subset of, and so on. A relation between two sets can be defined by
listing their elements as ordered pairs. In this lesson, we will discuss relations defined on
sets and the ways of representing finite relations along with their properties.
Relations will be defined by ordered pairs of elements. An ordered pair consists of
two elements a and b is denoted as (a, b). Here the element a is designated as the first
element and b as the second element. In particular
(a, b) = (c, d)
if and only if a = c and b = d. Thus, (a, b) (b, a). This contrasts with sets, where the
order of elements is irrelevant; for example, {3,5} = {5,3}.
Page: 133
A 1 A 2 ... A n or A i
i =1
Important results
1) Let A, B, and C are sets and A B. Then (A C) = (B C).
Proof. Let (a, c) be an arbitrary element of A C. Then
(a, c)(A C) a A and c C
a B and c C
(a, c) B C
Thus, (A C) = (B C).
2) If A B and C D, then prove that (A C) (B D).
Proof. Let (a, c) be an arbitrary element of A C. Then
(a, c)(A C) a A and c C
a B and c D
(a, c) B D
Thus, (A C) (B C).
Page: 134
Page: 135
Page: 136
Page: 137
Course
CompSci
Math
Art
History
CompSci
Math
Y
4
6
3
6
4
The domain of R is the set {2,3,4} and the range of R is the set {3,4,6}.
3) Let R be the relation on X={1,2,3,4} defined by (x,y) R if x y., x,y X. Then
R={{1,1),(1,2),(1,3),(1,4),(2,2),(2,3),(2,4),(3,3),(3,4),(4,5)}
The domain and range of R are both equal to X.
Page: 138
A 1 A 2 ... A n or A i
i =1
Binary Relations
A binary relation or, simply, relation R from set A to set B is a subset of A B.
Number of relations between two sets
The total number of relations from A to B are 2mn, where m and n are the Cardinal
number of the sets A and B respectively, including the empty relation and the
relation A B itself.
Domain and range of a relation
The domain of a relation R is the set of all first elements of the ordered
pairs, which belong to R, and the range of R is the set of second elements.
Types of relations
Inverse relation
Let R be a relation from a set A to set B. The inverse relation from B to A,
denoted by R-1 , is the set of ordered pair {(b, a) : a A, b B, (a, b) R}.
Identity (or Diagonal) Relation
Let A be any set. Then the relation R in a set A denoted by IA is said to be
identity relation if IA={(a, a) : a A}.
Universal Relation
Let A be any set. Then A A which is a subset of A A is a relation on A
called the universal relation.
Empty (or Void) relation
A relation R in a set is said to be an empty relation provided R is a null set
i.e. R=.
Page: 139
10.7 References
1. J K Sharma, Discrete Mathematics
2. Kenneth H.Rosen, Discrete Mathematics and its Applications
3. Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4. Charles D.Miller and Others, Mathematical Ideas
5. Wikipedia, the free encyclopedia.
6. Richard JohnsonBaugh, Discrete Mathematics
Page: 140
Unit IV
Lesson 11
Properties of relation, Partial Order and Equivalence relation
Contents
11.0 Aims and Objectives
11.1 Introduction
11.2 Properties of relations
11.3 Partial order relations
11.4 Equivalence relation
11.5 Composition of relations
11.6 Chapter Summary
11.7 References
11.0 Aims and Objectives
In this lesson, we have discussed about the Properties of relations, Partial order
relations, Equivalence relation, and Composition of relations.
11.1 Introduction
In this lesson we covered some important properties of the relations like Reflexive
relation, Symmetric relation, Anti-symmetric relation and Transitive relation. Using the
above properties we can define an equivalence relation which is also discussed in this
lesson.
Page: 141
Page: 142
Transitive relation
A relation R on a set A is transitive if whenever (a, b) R and (b, c) R, then
(a,c) R, for all a,b,c A.
11.3 Partial order relations
A relation, R on a set A is called a partial order or partial ordering relation if and only if
following three conditions are satisfied
1) R is reflexive, i.e. a R a, for all a A.
2) R is anti-symmetric, i.e. a R b, b R a, if and only if a = b, for all a, b A.
3) R is transitive, i.e. a R b, b R c implies that a R c, for all a, b, c A.
The set A on which a partial order relation, R is defined is called a partially ordered
set or simply a poset, and it is denoted by (A, R).
The relation '=' (equal to) defined on a set A is said to be total order relation provided
for all a, b A, we have a = b. This implies that b = a. In other words, aRb and bRa, and
hence the relation '=' is also a symmetric relation.
11.4 Equivalence relation
An equivalence relation is a binary relation between two elements of a set which groups
them together as being "equivalent" in some way. That a is equivalent to b is denoted as
"a~b" or "a b". An equivalence relation is reflexive, symmetric, and transitive. In other
words, for all elements a, b, and c of the set X, the following must hold for "~" to be an
equivalence relation on X:
Reflexive: a ~ a
Symmetry: if a ~ b then b ~ a
Transitivity: if a ~ b and b ~ c then a ~ c.
"Has the same birthday as" on the set of all people, given navie set theory.
"Is similar to" or "congruent to" on the set of all triangles.
"Is congruent to modulo n" on the integers.
"Has the same image under a function" on the elements of the domain of the
function.
Logical equivalence of statements in logic.
"Is isomorphic to" on models of a set of sentences.
Page: 143
The relation " " between real numbers is reflexive and transitive, but not
symmetric. For example, 7 5 does not imply that 5 7. It is, however, a partial
order.
The relation "has a common factor greater than 1 with" between natural numbers
greater than 1, is reflexive and symmetric, but not transitive. (The natural
numbers 2 and 6 have a common factor greater than 1, and 6 and 3 have a
common factor greater than 1, but 2 and 3 do not have a common factor greater
than 1).
The empty relation R on a non-empty set X (i.e. aRb is never true) is vacuously
symmetric and transitive, but not reflexive. (If X is also empty then R is
reflexive.)
The relation "is approximately equal to" between real numbers or other things,
even if more precisely defined, is not an equivalence relation, because although
reflexive and symmetric, it is not transitive, since multiple small changes can
accumulate to become a big change.
The relation "is a sibling of" on the set of all human beings is not an equivalence
relation. Although siblinghood is symmetric (if A is a sibling of B, then B is a
sibling of A) it is neither reflexive (no one is a sibling of himself), nor transitive
(since if A is a sibling of B, then B is a sibling of A, but A is not a sibling of A).
Instead of being transitive, siblinghood is "almost transitive", meaning that if A ~
B, and B ~ C, and A C, then A ~ C.
Page: 144
Properties
Composition of relations is associative.
The inverse relation of S o R is (S o R)-1 = R-1 o S-1 .
The compose of (partial) functions (i.e. functional relations) is again a (partial)
function.
If R and S are injective, then S o R is injective, which conversely implies only the
injectivity of R.
If R and S are surjective, then S o R is surjective, which conversely implies only
the surjectivity of S.
The binary relations on a set X (i.e. relations from X to X) form a monoid for
composition, with the identity map on X as neutral element.
Page: 145
Symmetric relation
A relation R on a set A is called symmetric if for all a,b A, if (a,b) R,
then (b,a)R.
Antisymmetric relation
A relation R on a set A is called antisymmetric if for all a,b A, if (a,b)
R and a b, then (b,a) R.
Transitive relation
A relation R on a set A is called transitive if for all a,b,z A, if (a,b) and
(y,z) R, then (x,z) R.
Partial order relations
A relation, R on a set A is called a partial order or partial ordering relation
if and only if following three conditions are satisfied
1) R is reflexive, i.e. a R a, for all a A.
2) R is anti-symmetric, i.e. a R b, b R a, if and only if a = b, for all a, b A.
3) R is transitive, i.e. a R b, b R c implies that a R c, for all a, b, c A.
Equivalence relation
A relation that is reflexive, symmetric and transitive on set A is called an
equivalence relation on A.
Composition of relations
Let R1 be a relation from X to Y, and R2 be a relation from Y to Z. The
composition of R1 and R2 , denoted R2 o R1 , is the relation from X to Z defined by
R2 o R1 ={(x,z) : (x,y) R1 and (y,z) R2 for some y Y}
Page: 146
11.7 References
1. J K Sharma, Discrete Mathematics
2. Kenneth H.Rosen, Discrete Mathematics and its Applications
3. Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4. Charles D.Miller and Others, Mathematical Ideas
5. Wikipedia, the free encyclopedia.
6. Richard JohnsonBaugh, Discrete Mathematics
Page: 147
Unit IV
Lesson 12
Functions
Contents
12.0 Aims and Objectives
12.1 Introduction
12.2 Functions as Relations
12.3 Difference Between a Function and its Value
12.4 Types of Functions
12.5 Composition of Functions
12.6 Lesson End Activities
12.7 References
12.0 Aims and Objectives
In this lesson, we have discussed about the Properties of relations, Partial order
relations, Equivalence relation, and Composition of relations.
After completing this lesson, you should able to
12.1 Introduction
Many everyday phenomena involve two quantities that are related to each other
by some rule of correspondence. Such a rule of correspondence is called a function. The
concept of a function is extremely important in discrete mathematics. Functions are used
in the definition of such discrete structures as sequences and strings. Functions are also
used to represent how long it takes a computer to solve problems of a given size.
Recursive functions, which are functions defined in terms of themselves, are used
throughout computer science. This section reviews the basic concepts involving functions
needed in discrete mathematics. The terms such as mapping, transformation, etc., are also
used for functions to depict a relation between two discrete objects.
Page: 148
Definition of a Function
A function f from a set A to a set B is a rule of correspondence that assigns to
each element x in the set A exactly one element y in the set B. The set A is the
domain(or set of inputs) of the function f, and the set B contains the range(or set of
outputs). Symbolically, the function f is expressed as:
f : A B such that y = f(x), for x A and y B.
The following characteristics are true of a function from a set A to a set B.
1. Each element in A must be matched with an element in B.
2. Some elements in B may not be matched with any element in A.
3. Two or more elements of A may be matched with the same element of B.
The converse of the third statement is not true. That is, an element of A (the domain)
cannot be matched with two different elements of B.
In other words, the relation f can be described as the set of elements written as:
{(x, f(x)) : x A, f(x) B}.
Example 1: Testing for functions
Let A={a,b,c} and B={1,2,3,4,5}. Does the set of ordered pairs represent a function from
set A to set B?
i)
iii)
i)
ii)
iii)
ii)
iv)
{(a,4), (b,5)}
{ (a,1), (a,2), (b,3), (b,4), (c,5)}
Page: 149
The relation R2 is not a function because R2(1) = {x, y}. But relation R1 is a function
with Domain = {l, 2} and Range = {x}.
4. Let I be the set of integers and A = {0, 1}. The relation between I and A defined as
f: I A such that
0 if x is even
f (x) =
1 if x is odd
Solution The relation, f = {(1, 2), (1, 3), (3, 4)} implies that f(1) = 2, f(1) = 3 and f(3) = 4.
Page: 150
Page: 151
Page: 152
Illustrations Let A be the set of students sitting on chairs in a classroom and let B be the
set of chairs in the classroom. Let f b e the correspondence, which associates to each
student the chair on which he sits.
Since every student has some chair to sit and no student can sit on two or more than
two chairs, therefore for the function defined as f: A B, the following cases may arise:
1. If every student gets a separate chair and no chair is left vacant, then this is a case of a
one-one onto function.
2. If every student gets a separate chair and still some chairs are left vacant, it is a oneone into function.
3. If every student does not sit on a separate chair, i.e. more than one student sit on a
chair, no chair is left vacant, it is a many-one onto function.
Invertible Functions
The domain and range of any function may be interchanged to form a new function. It is
obtained by
interchanging the position of elements in the ordered pair of original function.
A function f : A B is invertible if its inverse relation f 1 is a function from B to A.
In general, the inverse relation f 1 may not be a function. The following theorem gives
simple criteria which tells us when it is.
Theorem:
onto.
Page: 153
Illustrations
1. Let f : A B such that y or f(x) = x + 1, for all x A and y B be a function.
Since f is everywhere defined as well as one-one onto, therefore f is invertible. Thus f 1 is
also one-one onto function from set B to A.
2. Let f : R R such that y or f(x) =x2 , for all x A and y B be a function.
Since R is the set of real numbers, where f( -2 ) = f(2) = 4, therefore f is not one-one.
Hence f is not invertible.
3. Let j : A B be a function defined everywhere. Let A and B two finite sets containing
equal number of elements. In such a case
(a) If f is one-one, then f is onto.
(b) If f is into, then f is one-one.
Moreover, when A = B we need to prove only that a function is one-one onto to show
that it is bijection.
Remarks
1. A function which possesses an inverse is said to be invertible.
2. Only one-one and onto functions are invertible.
3. The inverse function of the given function f is unique.
4. Inverse function f -1 is onto if and only if f is everywhere defined.
12.5 Composition of Functions
Let g be a function from the set A to the set B and let f be a function from the set B
to the set C. The composition of the functions f and g, denoted by f o g, is defined by
(f o g)(a) = f(g(a)).
In other words, f o g is the function that assigns to the element a of A the element
assigned by f to g(a). Note that the composition f o g cannot be defined unless the range
of g is a subset of the domain of f.
Example: Let g be the function from the set {a, b, e} to itself such that g(a) = b, g(b) = c,
and g(c)=a. Let f be the function from the set {a, b, e} to the set {I, 2, 3} such that f(a) =
3, f(b) = 2, and f(c) = 1. What is the composition of f and g, and what is the composition
of g and f?
Solution: The composition f o g is defined by (f o g) (a) = f(g(a)) = f(b) = 2, (f o g) (b) =
f(g(b)) = f(c) = 1, and (f o g) (c) = f(g(e)) = f(a) = = 3.
Note that g o f is not defined, because the range of f is not a subset of the domain of g.
Page: 154
2.
3.
4.
5.
Define onto function. Give an example of an onto function, Explain how to use
an arrow diagram to determine whether a function is onto.
6.
7.
Define inverse function. Give an example of a function and its inverse. Given
the arrow diagram of a function, how can we find the arrow diagram of the
inverse function?
8.
9.
Page: 155
12.7 References
1) J K Sharma, Discrete Mathematics
2) Kenneth H.Rosen, Discrete Mathematics and its Applications
3) Seymour Lipschutz and Marc Lipson, Discrete Mathematics
4) Charles D.Miller and Others, Mathematical Ideas
5) Wikipedia, the free encyclopedia.
Page: 156
Unit V
Lesson 13
Graph Theory
Contents:
13.0 Aims and objectives
13.1 Introduction
13.2 Graph
13.3 Directed Graph
13.4 Path, trail and walk
13.5 Applications of graphs
13.6 Let Us Sum Up
13.7 Lesson End Activities
13.0 Aims and objectives
There are various types of graphs, each with its own definition. Unfortunately,
some people apply the term graph rather loosely, so you cant be sure what type of
graph theyre talking about unless you ask them. After you have finished this chapter, we
expect you to use the terminology carefully, not loosely.
13.1 Introduction
In mathematics and computer science, graph theory is the study of graphs;
mathematical structures used to model pairwise relations between objects from a certain
collection. The notion of a graph is deceptively simple: It is collection of vertices (or
points or 'nodes') and a collection of edges (or lines) that connect pairs of vertices. A
graph may be undirected, meaning that there is no distinction between the two vertices
associated with each edge, or its edges may be directed from one vertex to another. The
graphs studied in graph theory should not be confused with "graphs of functions" and
other kinds of graph.
Page: 157
13.2 Graph
What is a Graph?
There are various types of graphs, each with its own definition. To motivate the
various definitions, well begin with some examples.
Example 1 (A computer network) Computers are often linked with one another so that
they can interchange information. Given a collection of computers, we would like to
describe this linkage in fairly clean terms so that we can answer questions such as How
can we send a message from computer A to computer B using the fewest possible
intermediate computers?
We could do this by making a list that consists of pairs of computers that are connected.
Note that these pairs are unordered since, if computer C can communicate with computer
D, then the reverse is also true. (There are sometimes exceptions to this, but they are rare
and we will assume that our collection of computers does not have such an exception.)
Also, note that we have implicitly assumed that the computers are distinguished from
each other: It is insufficient to say that A PC is connected to a Mac. We must specify
which PC and which Mac. Thus, each computer has a unique identifying label of some
sort.
For people who like pictures rather than lists, we can put dots on a piece of paper, one for
each computer. We label each dot with a computers identifying label and draw a curve
connecting two dots if and only if the corresponding computers are connected. Note that
the shape of the curve does not matter (it could be a straight line or something more
complicated) because we are only interested in whether two computers are connected or
not. Below are two such pictures of the same graph. Each computer has been labeled by
the initials of its owner.
Fig. 13.1
Computers (vertices) are indicated by dots () with labels. The connections (edges) are
indicated by lines. When lines cross, they should be thought of as cables that lie on top of
each other not as cables that are joined.
In our example, the vertices are the computers and a pair of computers is in E if and only
if they are connected.
Page: 158
The notation Pk (V) stands for the set of all k-element subsets of the set V . Based on the
previous example, we have
Definition 1
Vertices u and v are said to be adjacent if there is an edge e={u, v}. In such a case,
u and v are called the end points of e and e is said to be connecting u and v.
Example 2 (Routes between cities) Imagine four cities named A, B, C and D. Between
these cities there are various routes of travel, denoted by a, b, c, d, e, f and g. Here is
picture of this situation:
Fig. 13.2
Looking at this picture, we see that there are three routes between cities B and C. These
routes are named d, e and f. Our picture is intended to give us only information about the
interconnections between cities. It leaves out many aspects of the situation that might be
of interest to a traveler. For example, the nature of these routes (rough road, freeway, rail,
etc.) is not portrayed. Furthermore, unlike a typical map, no claim is made that the picture
represents in any way the distances between the cities or their geographical placement
relative to each other. The object shown in this picture is called a graph.
Following our previous example 1, one is tempted to list the pairs of cities that are
connected; in other words, to extract a simple graph from the information. Unfortunately,
this does not describe the problem adequately because there can be more than one route
connecting a pair of cities; e.g., d, e and f connecting cities B and C in the figure 13.2.
How can we deal with this? Here is a precise definition of a graph of the type required to
handle this type of problem.
Definition 2 (Graph) A graph is a triple G = (V,E, ) where
V is a finite set, called the vertices of G,
E is a finite set, called the edges of G, and
is a function with domain E and codomain P2 (V ).
Page: 159
E = {a, b, c, d, e, f, g}
and
=
Definition 2 tells us that to specify a graph G it is necessary to specify the sets V and E
and the function . We have just specified V and in set theoretic terms. The picture of
the cities graph specifies the same V and in pictorial terms. The set V is represented
clearly by dots (), each of which has a city name adjacent to it. Similarly, the set E is
also represented clearly. The function is determined from the picture by comparing the
name attached to a route with the two cities connected by that route. Thus, the route name
d is attached to the route with endpoints B and C. This means that (d) = {B,C}.
The function is sometimes called the incidence function of the graph. The two elements
of (x) = {u, v}, for any x E, are called the vertices of the edge x, and we say u and v
are joined by x. We also say that u and v are adjacent vertices and that u is adjacent to v
or , equivalently, v is adjacent to u. For any v V, if v is a vertex of an edge x then we
say x is incident on v. Likewise, we say v is a member of x, v is on x, or v is in x. Of
course, v is a member of x actually means v is a member of (x).
Simple graphs are graphs: We can easily reconcile our two definitions by realizing that
a simple graph is a special case of a graph. Let G = (V,E) be a simple graph. Define
:EE to be the identity map; i.e., (e) = e for all e E. The graph G = (V,E, ) is
essentially the same as G. There is one subtle difference in the pictures: The edges of G
are unlabeled but each edge of G is labeled by a set consisting of the two vertices at its
ends.
13.3 Directed Graph
A graph is said to be the directed graph if it required to associate a direction with
each edge of the graph, that is, edges are ordered pairs of distinct vertices. Before well
begin to define a directed graph let us see the following example.
Example 3 (Flow of commodities) Look again at Example 2. Imagine now that the
symbols a, b, c, d, e, f and g, instead of standing for route names, stand for commodities
(bread, computers, etc.) that are produced in one town and shipped to another town. In
order to get a picture of the flow of commodities, we need to know the directions in
which they are shipped. This information is provided by picture below:
In set-theoretic terms, the information needed to construct the picture 13.3 can be
specified by giving a pair D = (V,E, ) where is a function. The domain of the function
is E = {a, b, c, d, e, f, g} and the codomain is V V. Specifically,
=
Page: 160
Fig. 13.3
The structure specified by this information is an example of a directed graph, which we
now define.
Definition 3 (Directed graph). A directed graph (or digraph) is a triple D = (V, E, )
where V and E are finite sets and is a function with domain E and codomain V V. We
call E the set of edges of the digraph D and call V the set of vertices of D.
Just as with graphs, we can define a notion of a simple digraph. A simple digraph
is a pair D = (V,E), where V is a set, the vertex set, and E V V is the edge set. Just as
with simple graphs and graphs, simple digraphs are a special case of digraphs in which
is the identity function on E; that is, (e) = e for all e E.
There is a correspondence between simple graphs and simple digraphs that is fairly
common in applications of graph theory.
Here is a picture (Fig. 13.4) of a simple graph and its corresponding digraph:
Fig. 13.4
Each, edge that is not a loop in the simple graph is replaced by two edges in opposite
directions in the corresponding simple digraph. A loop is replaced by a directed loop
(e.g.,{A} is replaced by (A,A)).
Indegree
The indegree of a vertex v in a directed graph is the number of edges ending at it
(or) the indegree of a vertex v is the number of edges that have v as the head. It is denoted
as indeg(v).
Page: 161
Outdegree
The outdegree of a vertex v in a directed graph is the number of edges beginning
from it or the outdegree of v is the number of arcs that have v as the tail. It is denoted as
outdeg(v).
Degree of a vertex
The degree of a vertex in a graph is the number of edges that touch it and is
denoted as deg(v) where v is the vertex.
Pendant (or end) vertex
A vertex is said to be pendant (or end) if its degree is one.
Isolated vertex
A vertex is said to be isolated if its degree is zero.
Even Vertex and Odd Vertex
A vertex is said to even or odd according as its degree is an even or an odd
number.
13.4 Path, trail and walk
A basic method for studying graphs and digraphs is to study substructures of these
objects and their properties. One of the most important of these substructures is called
a path.
Definition 4 (Path, trail, walk and vertex sequence) Let G = (V,E, ) be a graph.
Let e 1 , e 2 ,, e n-1 be a sequence of elements of E (edges of G) for which there is a
sequence a1 , a2 , . . . , an of distinct elements of V (vertices of G) such that (ei) = {ai, ai+1}
for i = 1, 2, . . . , n 1. The sequence of edges e1 , e2 , . . ., en-1 is called a path in G. The
sequence of vertices a1 , a2 , . . . , an is called the vertex sequence of the path. (Note that
since the vertices are distinct, so are the edges.)
If we require that e1 , e2 , . . ., en-1 be distinct, but not that a1 , a2 , . . . , an be distinct, the
sequence of edges is called a trail.
If we do not even require that the edges be distinct, it is called a walk.
If G = (V,E, ) is a directed graph, then (ei) = {ai, ai+1} is replaced by (ei ) = (ai, ai+1) in
the above definition to obtain a directed path, trail, and walk respectively.
Page: 162
Note that the definition of a path requires that it does not intersect itself (i.e., have
repeated vertices), while a trail may intersect itself. Although a trail may intersect itself, it
may not have repeated edges, but a walk may. If P = (e1 , e2 ,, en-1 ) is a path in G = (V,E,
) with vertex sequence a1 , a2 , . . . , an then we say that P is a path from a1 to an . Similarly
for a trail or a walk.
In the graph of Example 2 (Fig. 13.2), the sequence c, d, g is a path with vertex
sequence A,C,B,D.If the graph is of the form G = (V,E) with E P2 (V ), then the vertex
sequence alone specifies the sequence of edges and hence the path. Thus, Example 1(Fig.
13.1), the vertex sequence MN, SM, SE, TM specifies the path {MN, SM}, {SM, SE},
{SE, TM}. Similarly for digraphs. Consider the graph of Example 3 (Fig. 13.3). The edge
sequence P = (g, e, c) is a directed path with vertex sequence (D,B,C,A). The edge
sequence P = (g, e, c, b, a) is a directed trail, but not a directed path. The edge sequence P
= (d, e, d) is a directed walk, but not a directed trail.
Note that every path is a trail and every trail is a walk, but not conversely. However,
we can show that, if there is a walk between two vertices, then there is a path. This rather
obvious result can be useful in proving theorems, so we state it as a theorem.
Theorem 2 (Walk implies path) Suppose u v are vertices in the graph G = (V,E, ).
The following are equivalent:
(a) There is a walk from u to v.
(b) There is a trail from u to v.
(c) There is a path from u to v.
Furthermore, given a walk from u to v, there is a path from u to v all of whose edges are
in the walk.
The length l of a walk is the number of edges that it uses. For an open walk, l = n1,
where n is the number of vertices visited (a vertex is counted each time it is visited). For
a closed walk, l = n (the start/end vertex is listed twice, but is not counted twice).
Page: 163
Fig. 13.5
Eulerian path
A path which passes through every edge (once and only once). If the starting and
ending nodes are the same, it is an Euler cycle or an Euler circuit. If the starting and
ending nodes are different, it is an Euler trail.
Hamiltonian path
A path which passes through every node once and only once. If the starting and
ending nodes are adjacent, it is a Hamiltonian cycle.
Finite graph
A finite graph has a finite number of vertices and a finite number of edges.
Observe that a graph with a finite number of vertices must automatically have a finite
number of edges and so must be finite.
Trivial graph
A finite graph with one vertex and no edges, i.e., a single point, is called the
trivial graph.
Order and Size of the graph
If G(V,E) is finite then V(G) denotes the number of vertices in G and is called the
order of G.
If G(V,E) is finite then E(G) denotes the number of edges in G and is called the
size of G.
Page: 164
Cycles or Loops
A loop is an edge that connects a vertex to itself. If a graph contains a cycle, it is
cyclic; otherwise it is acyclic. A directed acyclic graph is called a dag from its acronym.
Page: 165
Page: 166
Page: 167
A graph in which every node is linked to every other node. For a complete digraph,
this means one link in either direction.
route
A sequence of edges and nodes from one node to another. Any given edge or node
might be used more than once.
path
A route that does not pass any edge more than once. If the path does not pass any
node more than once, it is a simple path.
connected
If some route exists from every node to every other, the graph is connected. Note that
some graphs are not connected. A diagram of an unconnected graph may look like
two or more unrelated diagrams, but all the nodes and edges shown are considered as
one graph.
loop, cycle
A path which ends at the node where it began.
tree
A connected graph with no loops.
Eulerian path
A path which passes through every edge (once and only once). If the starting and
ending nodes are the same, it is an Euler cycle or an Euler circuit. If the starting and
ending nodes are different, it is an Euler trail.
Hamiltonian path
A path which passes through every node once and only once. If the starting and
ending nodes are adjacent, it is a Hamiltonian cycle.
Page: 168
1)
2)
3)
4)
5)
6)
7)
8)
9)
(b, b)
(e, d, c, b)
(a, d, c, d, e)
( d. c. b. e, d)
(b, c, d, a, b, e, d, c, b)
(a, d, c, h, e)
(b, c, d, e, b, b)
(d)
(d, c, b)
Page: 169
Unit V
Lesson 14
Subgraphs, Types of Graphs and Graph Representations.
Contents
14.0 Aims and Objectives
14.1 Introduction
14.2 Subgraphs
14.3 Types of Graphs
14.4 Representation of graphs in computer memory
14.4.1 List structures
14.4.2 Matrix structures
14.5 Chapter Summary
14.6 Lesson End Activities
14.7 References
14.0 Aims and Objectives
The main aim and objective of this chapter is know about the subgraphs, various
types of graphs and the different ways of representing the graphs in a computer.
After reading this unit, you should be able to
14.1 Introduction
In this lesson, we first discuss about the subgraphs. A new graph can obtained by
selecting certain edges and vertices from a given graph with certain restrictions. The
graphs so obtained are called subgraphs. Next we discuss about the types of graphs. We
conclude the lesson by discussing the various methods available for representing a graph
in computers.
Page: 170
14.2 Subgraphs
A subgraph G of a graph G is obtained by selecting certain edges and vertices
from G subject to the restriction that if we select an edge e in G that is incident on
vertices v and w, we must include v and w in G. The restriction is to ensure that G is
actually a graph. The formal definition follows.
Definition 1 (Subgraph) Let G = (V,E,) be a graph. A graph G' = (V',E',') is a
subgraph of G if V' V , E' E, and ' is the restriction of to E'.
As we have noted, the fact that G' is itself a graph means that (x) P2 (V ) for each X
E' and, in fact, the codomain of ' must be P2 (V). If G is a graph with loops, the
codomain of ' must be P2 (V') P 1 (V'). This definition works equally well if G is a
digraph. In that case, the codomain of ' must be V V.
Example 1 (Subgraph key information) For the graph G = (V,E,) below, let
G'=(V',E', ') be defined by V' = {A,B,C}, E' = {a, b, c, f}, and by ' being the restriction
of to E' with codomain P2 (V'). Notice that ' is determined completely from knowing
V', E' and . Thus, to specify a subgraph G', the key information is V' and E'.
As another example from the same graph, we let V' = V and E' = {a, b, c, f}. In this case,
the vertex D is not a member of any edge of the subgraph. Such a vertex is called an
isolated vertex of G'.
One way of specifying a subgraph is to give a set of edges E' E and take V' to be
the set of all vertices on some edge of E'. In other words, V' is the union of the sets (x)
over all x. E'. Such a subgraph is called the subgraph induced by the edge set E' or the
edge induced subgraph of E'. The first subgraph of this example is the subgraph induced
by E' = {a, b, c, f}.
Fig. 14.1
Likewise, given a set V' V, we can take E' to be the set of all edges x E such that
(x) V'. The resulting subgraph is called the subgraph induced by V ' or the vertex
induced subgraph of V'. Referring to the picture again, the edges of the subgraph induced
by V' = {C,B}, are E' = {d, e, f}. Look again at the above graph. In particular, consider
the path c, a with vertex sequence C,A,B. Notice that the edge d has (d) = {C,B}. The
Page: 171
subgraph G' = (V ',E', '), where V ' = {C,A,B} and E' = {c, a, d} is called a cycle of G.
In general, whenever there is a path in G, say e1 , . . . , en-1 with vertex sequence a1 , . . . ,
an , and an edge x with (x) = {a1 , an }, then the subgraph induced by the edges e1 , . . . , en1 , x is called a cycle of G. Parallel edges like a and b in the preceding figure induce a
cycle. A loop also induces a cycle.
The formal definition of a cycle is:
Definition 2 (Circuit and Cycle) Let G = (V,E, ) be a graph and let e1 , . . . , en be a trail
with vertex sequence a1 , . . . , an , a1 . (It returns to its starting point.) The subgraph G' of G
induced by the set of edges {e1, . . . , en} is called a circuit of G. The length of the circuit
is n.
If the only repeated vertices on the trail are a1 (the start and end), then the
circuit is
called a simple circuit or cycle.
If trail is replaced by directed trail, we obtain a directed circuit and a directed
cycle.
In our definitions, a path is a sequence of edges but a cycle is a subgraph of G. In actual
practice, people often think of a cycle as a path, except that it starts and ends at the same
vertex. This sloppiness rarely causes trouble, but can lead to problems in formal proofs.
Cycles are closely related to the existence of multiple paths between vertices.
14.3 Types of Graphs
Null Graph
The simplest type of graph is a null graph. It consists of a non-empty finite set of
elements called vertices.
Complete Graph
A complete graph is a graph where every pair of distinct vertices are adjacent i.e., there is
an edge between every pair of distinct vertices. A complete graph on n vertices is denoted
by Kn (or sometimes by K(n) ). So, for example, figure 14.2 is the graph K5 .
Page: 172
Regular Graph
A graph in which every vertex has the same degree is called a regular graph. If every
vertex has degree r then we say the graph is regular of degree r. All null graphs are
regular of degree zero.
Weighted Graph
A graph with numbers on the edges is called a weighted graph. If edge e is labeled
k, we say that the weight of edge e is k. In a weighted graph, the length of a path is the
sum of the weights of the edges in the path.
Bipartite Graph
A graph G=(V, E) is bipartite if there exist subsets V1 and V2 (either possibly
empty) of V such that V1 V2 = , V1 V2 = V and each edge in E is incident on one
vertex in V1 and one vertex in V2.
Example
The graph in fig. is bipartite since if we let
V1 ={v 1 ,v2 ,v3 } and V2 ={v 4 ,v5 },
Each edge is incident on one vertex in V1 and one vertex in V2.
Fig. 14.3
Infinite Graph
A graph is infinite if it has infinitely many vertices or edges or both; otherwise
the graph is finite. An infinite graph where every vertex has finite degree is called locally
finite. When stated without any qualification, a graph is usually assumed to be finite.
Page: 173
Fig. 14.4
The graph pictured above (Fig. 14.4) has this adjacency list representation:
a
b
c
adjacent to
adjacent to
adjacent to
b,c
a,c
a,b
Adjacency matrix
Page: 174
Adjacency matrix
The adjacency matrix of a complete graph is all 1's except for 0's on the diagonal.
Laplacian matrix or Kirchhoff matrix or Admittance matrix
Is defined as degree matrix minus adjacency matrix and thus contains adjacency
information and degree information about the vertices.
Distance matrix
A symmetric n by n matrix an element Mx,y of which is the length of shortest path
between x and y; if there is no such path Mx,y = infinity. It can be derived from
powers of the Adjacency matrix.
Page: 175
A graph G
form subsets
of
the
vertices
and
edges
If
Page: 176
is
subgraph
then
of
Page: 177
is
said
to
be
supergraph
of
Null Graph
It consists of a non-empty finite set of elements called vertices.
Complete Graph
A complete graph is a graph where every pair of distinct vertices are
adjacent i.e., there is an edge between every pair of distinct vertices. A complete
graph on n vertices is denoted by Kn (or sometimes by K(n) ).
Regular Graph
A graph in which every vertex has the same degree is called a regular graph.
Page: 178
Weighted Graph
A graph with numbers on the edges is called a weighted graph. In a weighted graph,
the length of a path is the sum of the weights of the edges in the path.
Bipartite Graph
A graph G=(V, E) is bipartite if there exist subsets V1 and V2 (either possibly
empty) of V such that V1 V2 = , V1 V2 = V and each edge in E is incident on
one vertex in V1 and one vertex in V2.
Infinite Graph
A graph is infinite if it has infinitely many vertices or edges or both; otherwise the
graph is finite.
List structures
Incidence List
The edges are represented by an array containing pairs (ordered if directed) of
vertices (that the edge connects) and possibly weight and other data.
Adjacency List
Much like the incidence list, each vertex has a list of which vertices it is
adjacent to.
Matrix structures
Incidence matrix
The graph is represented by a matrix of E (edges) by V (vertices), where [edge,
vertex] contains the edge's data (simplest case: 1 - connected, 0 - not connected).
Adjacency matrix
There is an n by n matrix, where n is the number of vertices in the graph. If there is
an edge from some vertex x to some vertex y, then the element Mx,y is 1,
otherwise it is 0. This makes it easier to find subgraphs, and to reverse graphs if
needed.
The adjacency matrix of a complete graph is all 1's except for 0's on the diagonal.
Laplacian matrix or Kirchhoff matrix or Admittance matrix
Is defined as degree matrix minus adjacency matrix and thus contains adjacency
information and degree information about the vertices.
Distance matrix
A symmetric n by n matrix an element Mx,y of which is the length of shortest path
between x and y; if there is no such path Mx,y = infinity. It can be derived from
powers of the Adjacency matrix.
Page: 179
Page: 180
17) Write the adjacency matrices of the components of the graphs given by the
adjacency matrices of Exercises 13-16.
Page: 181
In Exercises 24 and 25, draw the graphs represented by the incidence matrices.
Page: 182
14.7 References
1)
2)
3)
4)
5)
Page: 183
Unit V
Lesson 15
Trees
Contents
15.0 Aims and objectives
15.1 Introduction
15.2 Tree
15.2.1 Rooted tree
15.2.2 Other trees
15.2.3 Height of the Tree
15.2.4 Facts and Enumeration
15.3 Binary tree
15.4 Tree traversal
15.4.1 Traversal methods
15.4.2 Sample implementations
15.5 Computer Representation of Trees
15.5.1 Computer Representation of General Trees
15.5.2 Computer Representation of Binary Trees
15.6 Let Us Sum Up
15.7 Lesson End Activities
15.8 References
15.0 Aims and objectives
The main aim and objective of this lesson is know about the trees, its properties,
binary trees, tree traversing and representation of trees in computer.
After reading this unit, you should be able to
Construct a tree.
Perform inorder, preorder and postorder tree traversing
Know about the ways of representing the trees in a computer memory.
15.1 Introduction
Trees play an important role in a variety of algorithms. Trees are widely used in
computer science data structures such as binary search trees, heaps, tries, etc. In this
section, we define trees precisely and look at some of their properties.
Page: 184
15.2 Tree
In graph theory, a tree is a graph in which any two vertices are connected by exactly one
path. Alternatively, any connected graph with no cycles is a tree. A forest is a disjoint
union of trees.
Definition (Tree)
If G is a connected graph without any cycles then G is called a tree. (If |V| = 1, then G is
connected and hence is a tree.) A tree is also called a free tree.
The graph in fig. 15.1 is connected but is not a tree. It has many cycles, including ({A,
B, C}, {a, e, c}). The subgraph of this graph induced by the edges {a, e, g} is a tree. If
G is a tree, then is an injection since if e1 e2 and (e1 ) = (e2 ), then {e1 , e2 } induces a
cycle. In other words, any graph with parallel edges is not as tree. Likewise, a loop is a
cycle, so a tree has no loops. Thus, we can think of a tree as a simple graph when we are
not interested in names of the edges.
Since the notion of a tree is so important, it will be useful to have some equivalent
definitions of a tree. We state them as a theorem
Theorem 1 (Alternative definitions of a tree) If G is a connected graph, the
following are equivalent.
(a) G is a tree.
(b) G has no cycles.
(c) For every pair of vertices u v in G, there is exactly one path from u to v.
(d) Removing any edge from G gives a graph which is not connected.
(e) The number of vertices of G is one more than the number of edges of G.
A directed tree is a directed graph which would be a tree if the directions on the edges
were ignored.
Page: 185
Example 1:
The example tree shown in fig. 15.2 has 6 vertices and 6 - 1 = 5 edges. The unique
simple path connecting the vertices 2 and 6 is 2-4-5-6.
A directed edge refers to the link from the parent to the child (the arrows in the
picture of the tree).
The root node of a tree is the node with no parents. There is at most one root node
in a rooted tree.
The depth of a node n is the length of the path from the root to the node. The set
of all nodes at a given depth is sometimes called a level of the tree. The root node
is at depth zero.
The height of a tree is the depth of its furthest leaf. A tree with only a root node
has a height of zero.
If a path exists from node p to node q, where node p is closer to the root node than
q, then p is an ancestor of q and q is a descendant of p.
Page: 186
Rooted trees, often with additional structure such as ordering of the neighbors at each
vertex, are a key data structure in computer science. In a context where trees are
supposed to have a root, a tree without any designated root is called a free tree.
A polytree has at most one undirected path between any two vertices. In other words, a
polytree is a directed acyclic graph (DAG) for which there is no undirected cycles either.
15.2.2 Other trees
A labeled tree is a tree in which each vertex is given a unique label. The vertices of a
labeled tree on n vertices are typically given the labels 1, 2, , n.
An irreducible (or series-reduced) tree is a tree in which there is no vertex of degree 2.
An ordered tree is a tree for which an ordering is specified for the children of each node.
15.2.3 Height of the Tree
The root of the tree has level 0, and the level of any other vertex in the tree is one
more than the level of its parent. In Fig.15.3, vertices v11 , v12 , v21 , v22 , v31 and v32 are at
level. The depth (or height) of a tree is the maximum level of any leaf in the tree. This
equals the length of the longest path from the root of any leaf. The tree in Fig.15.3 is of
height 2.
Page: 187
Every tree is a bipartite graph. Every tree with only countably many vertices is a
planar graph.
Every connected graph G admits a spanning tree, which is a tree that contains
every vertex of G and whose edges are edges of G. Every connected graph even
admits a normal spanning tree.
Every non-null tree has at least one leaf, or vertex of degree 1 (If it has a vertex,
it has a leaf).
Enumeration
Given n labeled vertices, there are nn- 2 different ways to connect them to make a
tree. This result is called Cayleys formula. It can be proved by first showing that the
number of trees with n vertices of degree d1 ,d2 ,...,dn is the multinomial coefficient
Page: 188
A rooted binary tree is a rooted tree in which every node has at most two
children.
A full binary tree, or proper binary tree, is a tree in which every node has zero
or two children.
A perfect binary tree (sometimes complete binary tree) is a full binary tree in
which all leaves are at the same depth.
A complete binary tree is a tree with n levels, where for each level d <= n - 1,
the number of existing nodes at level d is equal to 2d. This means all possible
nodes exist at these levels. An additional requirement for a complete binary tree is
that for the nth level, while every node does not have to exist, the nodes that do
exist must fill from left to right. (This is ambiguous with perfect binary tree.)
A balanced binary tree is where the depth of all the leaves differs by at most 1.
An almost complete binary tree is a tree in which each node that has a right
child also has a left child. Having a left child does not require a node to have a
right child. Stated alternately, an almost complete binary tree is a tree where for a
right child, there is always a left child, but for a left child there may not be a right
child.
A degenerate tree is a tree where for each parent node, there is only one
associated child node. This means that in a performance measurement, the tree
will behave like a linked list data structure.
The number of nodes n in a complete binary tree can be found using this
formula: n = 2h + 1 - 1 where h is the height of the tree.
The number of leaf nodes n in a complete binary tree can be found using this
formula: n = 2h where h is the height of the tree.
Page: 189
Page: 190
Example 2
Note that the inorder traversal of a binary search tree yields an ordered list
Page: 191
(2)
(3)
Furthermore, ROOT will contain the location of the root R of T. Although this
representation may seem artificial, it has the important advantage that each node N of T,
regardless of the number of children of N, will contain exactly three fields.
The above representation may be extended to represent a forest F consisting of
trees T1 , T2 ,, Tm by assuming the roots of the tree are siblings. In such a case, ROOT
will contain the location of the root R1 of the tree T1 ; or when F is empty, ROOT will
equal NULL.
15.5.2 Computer Representation of Binary Trees
Binary trees can be constructed from programming language primitives in several
ways. In a language with records and references, binary trees are typically constructed by
having a tree node structure, which contains some data and references to its left child and
its right child. Sometimes it also contains a reference to its unique parent. If a node has
fewer than two children, some of the child pointers may be set to a special null value, or
to a special sentinel node.
Binary trees can also be stored as an implicit data structure in arrays, and if the
tree is a complete binary tree, this method wastes no space. In this compact arrangement,
if a node has an index i, its children are found at indices 2i + 1 and 2i + 2, while its parent
Page: 192
Page: 193
Page: 194
Page: 195
Page: 196
15.8 References
1)
2)
3)
4)
5)