MATH 224 – Discrete Mathematics

Slides:



Advertisements
Similar presentations
1.6 Functions. Chapter 1, section 6 Functions notation: f: A B x in A, y in B, f(x) = y. concepts: –domain of f, –codomain of f, –range of f, –f maps.
Advertisements

Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
1 Section 1.8 Functions. 2 Loose Definition Mapping of each element of one set onto some element of another set –each element of 1st set must map to something,
Absolute Value: A number’s distance from zero on a number line. A number’s absolute value is nonnegative.
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Section 1.8: Functions A function is a mapping from one set to another that satisfies certain properties. We will first introduce the notion of a mapping.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
 Let A and B be any sets A binary relation R from A to B is a subset of AxB Given an ordered pair (x, y), x is related to y by R iff (x, y) is in R. This.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
February 12, 2015Applied Discrete Mathematics Week 2: Functions and Sequences 1Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3,
ICS 253: Discrete Structures I
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
MSU/CSE 260 Fall Functions Read Section 1.8.
Functions1 Elementary Discrete Mathematics Jim Skon.
Basic Structures: Sets, Functions, Sequences, and Sums CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
CS201: Data Structures and Discrete Mathematics I
Discrete Mathematics R. Johnsonbaugh
MATH 224 – Discrete Mathematics
CompSci 102 Discrete Math for Computer Science
Mathematical Preliminaries
Basic Structures: Sets, Functions, Sequences, and Sums.
Sets Definition: A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a.
1 2/21/2016 MATH 224 – Discrete Mathematics Sequences and Sums A sequence of the form ar 0, ar 1, ar 2, ar 3, ar 4, …, ar n, is called a geometric sequence.
FUNCTIONS COSC-1321 Discrete Structures 1. Function. Definition Let X and Y be sets. A function f from X to Y is a relation from X to Y with the property.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
FUNCTIONS.
Discrete Mathematics Lecture # 17 Function. Relations and Functions  A function F from a set X to a set Y is a relation from X to Y that satisfies the.
ICS 253: Discrete Structures I
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Discrete Mathematics Lecture 6
MATH 224 – Discrete Mathematics
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Relations, Functions, and Matrices
Functions and Their Graphs
Set, Combinatorics, Probability & Number Theory
CS 2210:0001 Discrete Structures Sets and Functions
Chapter Functions.
Relation and function.
Functions.
Function Hubert Chan (Chapter 2.1, 2.2) [O1 Abstract Concepts]
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Cardinality of Sets Section 2.5.
Relations and Functions Pages
Functions Section 2.3.
Discrete Structure II: Introduction
Discrete Math (2) Haiming Chen Associate Professor, PhD
CS100: Discrete structures
Lecture 7 Functions.
CSE15 Discrete Mathematics 02/27/17
Splash Screen.
CS 220: Discrete Structures and their Applications
Mathematical Background 1
Mathematical Background 1
Introduction to Relations and Functions
Ch 5 Functions Chapter 5: Functions
ICS 253: Discrete Structures I
Functions Rosen 6th ed., §2.3.
Section 1.8 INVERSE FUNCTIONS.
Math/CSE 1019N: Discrete Mathematics for Computer Science Winter 2007
Functions Section 2.3.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Copyright © Zeph Grunschlag,
Presentation transcript:

MATH 224 – Discrete Mathematics Basic Structures - Sets Sets provide a basis for many of the data structures used in computer science. As you already know sets are collections of any type of object without ordering and without duplicates. The original formalization of the set was developed by the mathematician Georg Cantor in the late 19th century. Cantor is most famous for both his theory of sets and infinity. He developed the idea of a hierarchy of infinities with the smallest being countable infinity sets, e.g., the integers, followed what he called Aleph 1 (א1) the “smallest” uncountable set, e.g., the real numbers. His theory provides the basis for the concept that some problems are not solvable by computers. 7/22/2018

MATH 224 – Discrete Mathematics Set Examples Some examples of sets include: The set of students in this class The set N of natural number (all non-negative integers) {0, 1, 2, 3, …} The set Z of all integers both positive and negative {…, -2, -1, 0, 1, 2, …} The set Q of all rational numbers (numbers that can be expressed as p/q, where p and q are elements of Z The set R of real numbers. The set C of complex numbers. Which of these sets are countable and which are uncountable? Countable sets can also be finite. Can you name some other countable sets, both finite and infinite? 7/22/2018

MATH 224 – Discrete Mathematics Basic Set Notation 7/22/2018

MATH 224 – Discrete Mathematics Sets and Venn Diagrams Describe the sets represented by this Venn diagrams and there size. Computational Problems x ≥ 0 x Z Solvable by N2 algorithms Solvable by computers Letters ASCII characters 7/22/2018

MATH 224 – Discrete Mathematics Basic Set Notation Vertical bars are used to indicate the size of a set or the number of elements in a set. So far example, the set of English lowercase letters L has size twenty six as indicated by |L| = 26 A set of this size can be put in one-to-one correspondence with the set {0, 1, 2, ..., 25}. The power set of a set is indicated by P(X). This is the set of all subsets of X. So for example, if X = {a, b, c} then P(X) = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}} If a set has a finite number of elements, for example N, how many elements will its power set have? Do you think that the power set of the integers is countable? Is it possible for a set to contain itself? Can you think of an example? 7/22/2018

MATH 224 – Discrete Mathematics Sets with Quantifiers Assume that we have an algorithm σ that finds square roots of numbers. This might be indicated by something like ( x R) (x ≥ 0 → σ(x) returns the √x) How would you describe the set of perfect squares? How would you describe the real numbers as a subset of the complex numbers without mentioning the imaginary number i? 7/22/2018

MATH 224 – Discrete Mathematics Cartesian Products and Ordered Pairs Finally the concept of Cartesian products and order pair is important in computer science. You have seen ordered pairs, when plotting XY coordinates on a 2-dimensional graph. The Cartesian product, A x B, of two sets consists of all possible ordered pairs (a, b) where a A and b B. So for example if A = {1, 2, 3} and B = {a, b}, then A x B = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}. Data structures such as graphs, trees and 2-dimensional arrays may be described as sets of ordered pairs. Any subset of a Cartesian product is called a relation. And under specific circumstances a relation may also be a function. As an example, consider the set of all ordered (x, y) pairs of the grapy of y = 2x + 5. That set is called a relation and a function. It is a subset of R x R where R is the set of real numbers. Why do circles and ellipses on an x ─ y coordinate graph not represent functions while parabolas and straight lines do? 7/22/2018

MATH 224 – Discrete Mathematics Set Operations Union: A U B = { x | x A v x B} Intersection: A ∩ B = { x | x A ^ x B} Difference: A – B = { x | x A ^ x B} ( stands for not in) Complement: A′ or A = {x | x A} (It is assumed with respect to a universal set) Symmetric Difference: A O B = {x | (x A U B) ^ (x A ∩ B) Can you explain why the identities in Table 1, on Page 124 from our text are true? For example , why does A ∩ (B U C) = (A ∩ B) U (A ∩ C)? And what about A U (A ∩ B) = A? Could the distributive law for union be used to get the same result when union and intersection are swapped? 7/22/2018

MATH 224 – Discrete Mathematics Functions You already know what a function is in C++. It is a routine that possibly takes some input, performs some operations and possibly returns a value. Not all functions in C++ correspond to functions in mathematics. To conform to a mathematical function a C++ function must: Take input, one or more parameters Return a value that is unique for a given input Must be a constant function – that is it must not alter any values, just return something (Well, it could be a void function with some parameters passed by value and some passed by reference satisfying specific conditions.) When a C++ function returns a value, will a unique input always determine a unique output? What does a function have to do with ordered pairs? How are mathematical functions specified? 7/22/2018

MATH 224 – Discrete Mathematics Functions In mathematics, a function has a domain, sometimes referred to as the independent variable and a range (or codomain)* sometimes referred to as the dependent variable. For each possible value in the domain, there must be exactly one element in the range. An example of a function is f(x) = 2x – 3. If the domain of this function is restricted to integer values between –5 and 2, then the function f might be described as the set of ordered pairs {(-5, -13), (-4, -11), (-3, -9), (-2, -7), (-1, -5), (0, -3), (1, -1), (2, 1)}. The elements in this set correspond to points on the line described by y = 2x – 3. *Note that there is a distinction between range and the codomain. To be precise the range is a subset of the codomain. Why does the equation y2 + x2 = 4, not describe a function? Why does the set {(0,1), (2, 4), (4, 8), (1, 0), (4, 2)} not describe a function? 7/22/2018

MATH 224 – Discrete Mathematics Function Terminology A function is called onto if its range is equal to the codomain. So for example, f(x) = 2x – 3 is a function from the real numbers to the real numbers that is onto since ( y R) x (y = 2x – 3 ) . On the other hand g(x) = 2x2 – 3 is not onto the real numbers since no value of x results in a value for g(x) < –3. An onto function is called a surjection. How would you express the fact that g(x) is not an onto function using quantifiers? Can you give some examples of functions that are surjections? Can you give some examples where the domain is finite? Is a C++ function that sorts array surjective? 7/22/2018

MATH 224 – Discrete Mathematics Function Terminology A function is called one-to-one if there is exactly one value in the domain for each value in the range.. So for example f(x) = 2x – 3 is a one-to-one function from the real numbers to the real numbers that is ( y R, x R [(f(x) = f(y)) → x = y] . On the other hand, g(x) = 2x2 – 3 is not one-to-one. For example, g(3) = g(-3) =15. A one-to-one function is called an injection. Finally a function that is one-to-one and onto is called a bijection or a one-to-one correspondence. When there is a one-to-one correspondence between to sets, those sets are the same size (have the same number of elements). Is a C++ function that sorts arrays injective? Can you give some examples of functions that are bijections? Does the set of all integers have the same number of elements as the set of even integers? Can you describe a one-to-one correspondence between these two sets. Is the factorial function one-to-one? Is it onto the set of all positive integers? 7/22/2018

MATH 224 – Discrete Mathematics Function Terminology A function is said to be invertible if it has an inverse. For example, the inverse of f(x) = 2x + 5 is f-1(x) = (x – 5)/2. How would you show that this example is correct? The inverse of a function interchanges the domain and the range. Does a function have to be a bijection in order to have an inverse? Can you give some examples of functions and their inverses? 7/22/2018

MATH 224 – Discrete Mathematics Function Terminology Functions can be combined to create new functions. For example the result of two functions may be added, for example, (f1 + f2) = f1(x) + f2(x). All arithmetic operations may be used in a similar way including multiplication, division and subtraction. Even more complex operations such as exponentiation, e.g., f1(x)f2(x) may be used. Can functions be combined in this way in C++. How would you do exponentiation of two functions in C++? Another operation is the composition of functions f o g(x) = f(g(x)). What function results form f o f-1(x)? Describe the function as an equation in y and x ? Give an example of how to create the composition of two functions in C++. 7/22/2018

MATH 224 – Discrete Mathematics Some Important Functions for programming You should know what the floor and ceiling functions are. In C++, when doing integer division, which of these functions is used? Find a value for x that makes └x┘+ └x┘ ≤└x + x┘ Another important function in programming is log2(x) written as lg(x). This function is the inverse of 2x. So for example, since 25 = 32, it follows that lg(32) = 5. The lg function along with the ceiling function can be used to determine the number of bits required to represent an integer. For example, to represent 1000, requires 10 bits since lg(512) = 9 and lg(1024) = 10. Therefore 9 < lg(1000) < 10 and ┌lg (1000)┐ = 10. Do you know an algorithm that you were taught in CS 140 or 141 that takes ┌lg(n) ┐ iterations when applied to an array with n elements? 7/22/2018