You are on page 1of 16

Discrete Structures

Sets, Functions, Matrices, and Relations


(Lecture -2)

Dr. Nirnay Ghosh


Functions
 In many instances we assign to each element of a set a particular
element of a second set.
 Example of a function: Assignment of grades in a particular class

 Functions: important for both mathematics and computer science


 Used to define discrete structures: sequences and strings
 How long it takes a computer to solve problems of given size
 Many computer programs and subroutines are designed to calculate values of
functions.
 Recursive functions, which are functions defined in terms of themselves, are
2 8/30/2019
used throughout computer science
Functions

 Two functions are equal when they have the same domain, have the same
codomain, and map each element of their common domain to the same
element in their common codomain.
 A function is called real-valued if its codomain is the set of real numbers,
and it is called integer-valued if its codomain is the set of integers.
 Two real-valued functions or two integer-valued functions with the same
3 domain can be added, as well as multiplied. 8/30/2019
Functions

 Image of a subset can be defined as follows:

4 8/30/2019
Mappings: One-to-One Functions

 Conditions that guarantee that a function is one-to-one:


 Increasing/Strictly increasing, Decreasing/Strictly decreasing functions

5 8/30/2019
Mappings: Onto Functions

 A function f is onto if ∀y∃x (f (x) = y), where the domain for x is the domain
of the function and the domain for y is the codomain of the function.

6 8/30/2019
Mappings: One-to-one correspondences

7 8/30/2019
Inverse Functions

 A one-to-one correspondence is called invertible because we can


define an inverse of this function.
 A function is not invertible if it is not a one-to-one correspondence,
because the inverse of such a function does not exist.
8 8/30/2019
Composition of Functions

9 8/30/2019
Floor & Ceiling Functions

 Floor function: same value throughout the


interval [n, n + 1), namely n, and then it
jumps up to n + 1 when x = n + 1.
 Ceiling function: same value throughout
the interval (n, n + 1], namely n + 1, and
then jumps to n + 2 when x is a little larger
than n + 1.
 A useful approach for considering
statements about the floor function is to let
x = n + ε,where n is the integer, and ε is
the fractional part of x, satisfies the
inequality 0 ≤ ε < 1.
 Similarly, when considering statements
about the ceiling function, it is useful to
10 write x = n - ε, where n is an integer and 0 8/30/2019
≤ ε < 1.
Floor & Ceiling Functions
 In Figure 10(a), the floor function is shown. Note that this function has the same value
throughout the interval [n, n + 1), namely n, and then it jumps up to n + 1 when x = n +
1.
 In Figure 10(b), the graph of the ceiling function is shown. Note that this function has the
same value throughout the interval (n, n + 1], namely n + 1, and then jumps to n + 2
when x is a little larger than n + 1.

11 8/30/2019
Partial Functions
 A program designed to evaluate a function may not produce the
correct value of the function for all elements in the domain of this
function.
 Function considering only a subset of the domain.

 The function f : Z → R where f (n) = √n is a partial function from


Z to R where the domain of definition is the set of nonnegative
integers. Note that f is undefined for negative integers.

12 8/30/2019
Matrices

 Matrix addition:

 The sum of two matrices of the same size is obtained by adding elements in
the corresponding positions.
 Matrices of different sizes cannot be added, because the sum of two
matrices is defined only when both matrices have the same number of rows
and the same number of columns.

13 8/30/2019
Matrices
 Matrix multiplication:

 The product of two matrices is not defined when the number of columns in
the first matrix and the number of rows in the second matrix are not the same.

14 8/30/2019
Identity and Transposes Matrices
 Identity matrix

 Transpose of a matrix

15 8/30/2019
Square and Symmetric Matrices

 A matrix is symmetric if and only if it is square and it is symmetric


with respect to its main diagonal (which consists of entries that are
in the ith row and ith column for some i).

16 8/30/2019

You might also like