MSU/CSE 260 Fall 20091 1 Functions Read Section 1.8.

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

Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
CSE115/ENGR160 Discrete Mathematics 02/16/12 Ming-Hsuan Yang UC Merced 1.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
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,
Functions.
Chapter 7 Functions Dr. Curry Guinn. Outline of Today Section 7.1: Functions Defined on General Sets Section 7.2: One-to-One and Onto Section 7.3: The.
Functions. Let A and B be sets A function is a mapping from elements of A to elements of B and is a subset of AxB i.e. can be defined by a set of tuples!
Functions, Sequences, and Sums
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
Functions.
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
FUNCTION Discrete Mathematics Asst. Prof. Dr. Choopan Rattanapoka.
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,
Functions. Copyright © Peter Cappello2 Definition Let D and C be nonempty sets. A function f from D to C, for each element d  D, assigns exactly 1 element.
ICS 253: Discrete Structures I
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (2)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
Functions Section 2.3 of Rosen Spring 2012 CSCE 235 Introduction to Discrete Structures Course web-page: cse.unl.edu/~cse235 Questions: Use Piazza.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
1 Discrete Structures – CNS 2300 Text Discrete Mathematics and Its Applications (5 th Edition) Kenneth H. Rosen Chapter 1 The Foundations: Logic, Sets,
Functions1 Elementary Discrete Mathematics Jim Skon.
Chapter 1 SETS, FUNCTIONs, ELEMENTARY LOGIC & BOOLEAN ALGEBRAs BY: MISS FARAH ADIBAH ADNAN IMK.
Based on Rosen, Discrete Mathematics & Its Applications, 5e Prepared by (c) Michael P. Frank Modified by (c) Haluk Bingöl Module #4.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Example Prove that: “IF 3n + 2 is odd, then n is odd” Proof by Contradiction: -p = 3n + 2 is odd, q = n is odd. -Assume that ~(p  q) is true OR -(p 
Functions Reading: Chapter 6 (94 – 107) from the text book 1.
Basic Structures: Functions Muhammad Arief download dari
CSE 2353 – October 1 st 2003 Functions. For Real Numbers F: R->R –f(x) = 7x + 5 –f(x) = sin(x)
Chapter 5 – Relations and Functions. 5.1Cartesian Products and Relations Definition 5.1: For sets A, B  U, the Cartesian product, or cross product, of.
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
CompSci 102 Discrete Math for Computer Science January 31, 2012 Prof. Rodger Slides modified from Rosen AB a b c d x y z.
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
MATH 224 – Discrete Mathematics
Basic Structures: Sets, Functions, Sequences, and Sums.
CSC102 - Discrete Structures Functions
1 Functions CS 202 Epp section ??? Aaron Bloomfield.
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.
Discrete Mathematics 3. MATRICES, RELATIONS, AND FUNCTIONS Lecture 6 Dr.-Ing. Erwin Sitompul
1 Lecture 5 Functions. 2 Functions in real applications Curve of a bridge can be described by a function Converting Celsius to Fahrenheit.
Section 2.3. Section Summary  Definition of a Function. o Domain, Cdomain o Image, Preimage  One-to-one (Injection), onto (Surjection), Bijection 
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 Functions
Functions Section 2.3.
Relations, Functions, and Matrices
MATH 224 – Discrete Mathematics
Relation and function.
Chapter 3 Relation and Function Homework 4 For each of the following relations on set A = { 1,2,3,4 }, check each of them whether they are reflexive, irreflexive,
… and the following mathematical appetizer is about…
Functions Section 2.3.
CSE15 Discrete Mathematics 02/27/17
CS100: Discrete structures
… and the following mathematical appetizer is about…
Functions CS 202 Epp section 7.1.
Functions.
Functions Rosen 6th ed., §2.3.
Functions Section 2.3.
Copyright © Zeph Grunschlag,
Presentation transcript:

MSU/CSE 260 Fall Functions Read Section 1.8

MSU/CSE 260 Fall Outline Introduction: definitions, example and terminology, image of a subset of domain, sum and product of functions One-to-one functions: strictly increasing, decreasing functions Onto functions Bijections: identity functions Graphs of Functions Inverse Functions Compositions of Functions Some Important Functions: Floor, Ceiling and Factorial functions

MSU/CSE 260 Fall Function Example  Consider your final grades in CSE 260. Your grades will be one of the values from the set {4, 3.5, 3, 2.5, 2, 1.5, 1, 0} What kind of properties does this assignment have? Consider the courses you are taking this semester. { (A123, CSE 260), (A123, CSE 232), (A123, MTH 234), (A123, DYLANTHOMAS 111)} What kind of properties does this assignment have?

MSU/CSE 260 Fall Introduction Definition: Let A, B be sets. A function f from A to B, denoted f: A → B, is an assignment where each element of A is assigned exactly one element of B. Notation:  f: A → B  We write f (a) = b, if b is the element of B assigned under f to the element a of A.  We also say f maps A to B Formally, f is a function from A to B if and only if  x  A  !y  B f(x) = y. where  ! is the uniqueness quantifier.

MSU/CSE 260 Fall Example Stevens Sara 4 0 Adams Marie f: A → B GradesStudents f(Adams)=1 f(Marie)=4 f(Stevens)=3 f(Sara)=3 A B

MSU/CSE 260 Fall Domain, Co-domain, … Definition: Let f be a function from A to B, that is, f: A → B. Then A is called the domain of f, and B is the codomain of f. If f(a) = b, then  b is called the image of a, and  a is a pre-image of b. The range of f is the set of all images of elements of A. How are codomain and range related?  Range is a subset of the codomain

MSU/CSE 260 Fall Example Stevens Sara 4 0 Adams Marie GradesStudents f (Adams)=1 f (Marie)=4 f (Stevens)=3 f (Sara)=3 The image of ‘Marie’ is 4; the pre-images of 3 are ‘Stevens’ and ‘Sara’; the range of f is {1, 3, 4}. A B f: A → B

MSU/CSE 260 Fall Sum, Products of real-valued Functions Definition: Let f 1 and f 2 be functions from A to R. Then f 1 + f 2 and f 1  f 2 are also functions from A to R, defined as:  (f 1 + f 2 )(x) = f 1 (x) + f 2 (x)  (f 1  f 2 )(x) = f 1 (x)  f 2 (x) Note that if f 1 and f 2 do not have the same domain, the above operations do not make sense.

MSU/CSE 260 Fall Image of a subset of a domain Definition: Let f be a function from A to B, and let S be a subset of A. The image of S, denoted f (S), is the subset of B consisting of the images of the elements of S.  Formally: f (S) = { f (s) | s  S}.  Note that f (A) is the range of f. In the previous Example,  f ({Adams, Sara}) = {3, 1}

MSU/CSE 260 Fall One-to-one Functions Definition: A function f from A to B is said to be one-to-one, or injective, if and only if distinct elements of the domain have distinct images. That is,  x  A  y  A f (x) = f (y) → x = y. 1 b a c 2 3 4

MSU/CSE 260 Fall Onto Functions Definition: A function f from A to B is said to be onto, or surjective, if and only if its range and codomain are the same. That is,  y  B  x  A f(x) = y. 1 c b d 2 3 a

MSU/CSE 260 Fall Bijections Definition: A function f: A → B is a bijection, or one-to-one correspondence, if it is both one-to-one and onto.  Note that the cardinalities (when dealing with finite sets) of domain and codomain of a bijection are equal. c b d 3 4 a 2 1

MSU/CSE 260 Fall Summary of Function Types b a c c b d a c b d 3 4 a c b d 3 4 a c b 3 4 a 2 1 onto but not 1-to-1 both 1-to-1 and onto; bijection Neither 1-to-1 nor onto Not a function 1-to1 but not onto

MSU/CSE 260 Fall Monotonic Functions Definition: Let A and B be subsets of R, the set of real numbers. A function f: A → B is strictly increasing if  x  A  y  A x < y → f (x) < f (y). f: A → B is strictly decreasing if  x  A  y  A x f (y). Note that strictly increasing, or strictly decreasing (strictly monotone) functions must be one-to-one.

MSU/CSE 260 Fall Inverse Function Definition: Let function f: A → B be a bijection. The inverse function of f, denoted f -1, is the function, f -1 : B → A, that assigns to each element b of B the element a of A such that f (a) = b.   a  A  b  B f(a) = b → f -1 (b) = a.  f is called invertible. c b d 3 4 a1 2 f -1 (1) = d f -1 (2) = b f -1 (3) = a f -1 (4) = c f

MSU/CSE 260 Fall Inverse Function… Example: Let f : Z → Z, where f (x) = x + 1.  f is a bijection; what is f -1 ?  Suppose f (x) = y; then x + 1= y; so x = y - 1= f -1 (y) f -1 (x) = x ­ 1.

MSU/CSE 260 Fall Identity Function Let A be a set. The identity function on A is the function ι A : A → A, where  x  A ι A (x) = x. Notes:  ι A assigns each element of A to itself.  ι A is a bijection.

MSU/CSE 260 Fall Characteristic and Constant Functions Let A be a subset of universe U. The characteristic function f A : U → {0, 1}, is such that f A (x) = 1 if x  A and f A (x) = 0 if ¬ (x  A ) Let A be a set. The constant function f : A → {t} maps each element of A to the same value t.

MSU/CSE 260 Fall Compositions of Functions Definition: Let g be a function from A to B and f a function from B to C, that is, g: A → B f: B → C The composition of f and g, denoted f o g, is function from A to C, defined as follows  x  A ( f o g)(x) = f (g(x)). v k 3 4 p 2 1 c b d a (f o g)(a) = 2 (f o g)(b) = 3 (f o g)(c) = 1 (f o g)(d) = 2 g f q A={a, b, c, d} B={q, p, k, v} C={1, 2, 3, 4}

MSU/CSE 260 Fall Composition of Functions A Bc gf f o g A Bc A BcccBcBc A Bc

MSU/CSE 260 Fall Example Consider the two functions f : Z → Z, where f (x) = 2x + 3 g: Z → Z, where g (x) = 3x + 2.  What are f o g, and g o f ?  f o g: Z → Z, where (f o g)(x) = f (g(x)) = f (3x + 2) = 2(3x + 2) + 3 = 6x +7  g o f: Z → Z, where (g o f )(x) = g( f (x)) = g (2x + 3) = 3(2x + 3) + 2 = 6x + 11

MSU/CSE 260 Fall Example

MSU/CSE 260 Fall Example

MSU/CSE 260 Fall Example….

MSU/CSE 260 Fall Graph of a Function Definition: Let f: A → B. The graph of f is the set of ordered pairs G f = {(x, f (x)) | x  A}.

MSU/CSE 260 Fall Graph of a Function…. The graph of the function f : Z → Z, where f (n) = 2n + 1, is G f = {(n, 2n + 1) | n  Z} n f (n) (0,1) (1,3) (2,5) (-1,-1)

MSU/CSE 260 Fall Important Integer Functions Whole numbers constitute the backbone of discrete mathematics. We often need to convert fractions or arbitrary real numbers to integers. These integer functions will help us do that. Besides the identity function, some important functions are:  The floor function,  The ceiling function,  The mod function.

MSU/CSE 260 Fall Floor Function Definition: The floor function from R to Z assigns to the real number x, the largest integer ≤ x. The value of the floor function at x is denoted by  x .   x  R  n  Z  x  = n  n  x < n + 1. Examples:   18  = 18   3.75  = 3   – 4.5  = – 5

MSU/CSE 260 Fall Ceiling Function The ceiling function from R to Z assigns to the real number x the smallest integer ≥ x. The value of the ceiling function at x is denoted by  x .   x  R  n  Z  x  = n  n – 1 < x  n.   x  R x – 1 <  x   x   x  < x + 1. Examples:   18  = 18   3.75  = 4   – 4.5  = – 4

MSU/CSE 260 Fall Floor and Ceiling Functions, recap 0 ** xxxx xxxx xxxx xxxx

MSU/CSE 260 Fall Properties of  x  and  x   x  R  n  Z  x  = n  n  x < n + 1.  x  R  n  Z  x  = n  n – 1 < x  n.  x  R  n  Z  x  = n  x – 1 < n  x.  x  R  n  Z  x  = n  x  n < x +1.  x  R x – 1 <  x   x   x  < x + 1.  x  R  – x  = –  x   x  R  – x  = –  x   x  R  m  Z  x + m  =  x  + m  x  R  m  Z  x + m  =  x  + m 0 ** xxxx xxxx xxxx xxxx

MSU/CSE 260 Fall Example

MSU/CSE 260 Fall Example: Solution

MSU/CSE 260 Fall Integer Functions

MSU/CSE 260 Fall

MSU/CSE 260 Fall Example

MSU/CSE 260 Fall Example: Solution

MSU/CSE 260 Fall The mod Function When dividing an integer n by a number m, the quotient of the division is  n/m . What about a simple notation for the remainder of this division? That’s what the mod function is about: n mod m m is called modulus n = m   n/m  + n mod m quotient remainder

MSU/CSE 260 Fall Example Formally, the mod function is a mapping: mod : Z  Z + → N where n mod m = n – m   n/m  Examples : 5 mod 3 = 5 – (3   5/3  ) = 5 – (3   1.6  ) = 5 – (3  1 ) = 2

MSU/CSE 260 Fall Example n mod m = n – (m   n/m  ) Examples: - 5 mod 3 = -5 – (3   -5/3  ) = -5 – (3   -1.6  ) = -5 – (3  (-2)) = 1. We also write: 5  2 mod 3, 9  0 mod 3, -5  1 mod 3.

MSU/CSE 260 Fall mod Function m m-1 + –

MSU/CSE 260 Fall List Search Methods Problem: Given a list of elements, how fast can we decide whether or not a given input element belongs to the list?  Linear search  Binary search; need to sort the list first  Hash table

MSU/CSE 260 Fall Hash Functions

MSU/CSE 260 Fall Hash Functions A hash function h: keys → integers maps “keys” to “small” integers (buckets) Ideal features:  The function should be easy to compute  The range values should be “evenly” distributed  Given an image, it should not be “easy” to find its pre- image Applications  Searching/indexing  Information hiding  File signature

MSU/CSE 260 Fall Hashing for Indexing A hash function h: keys → integers maps “keys” to “small” integers (buckets) Ideally this mapping is done in a “random” manner so that the bucket values are evenly distributed despite irregularities in the keys. For simplicity, we will assume that the keys are also integers, denoted by k, and the number of buckets is demoted by m. Note that the buckets are indexed 0 through m - 1.

MSU/CSE 260 Fall Example Storing CSE 260, both sections, PIDs\A  Using Hash Function h(PID) = k mod 31

MSU/CSE 260 Fall Simple Hash Functions h(k) = k mod m  Suggestion: Choose m to be a prime number that isn’t close to a power of 2. h(k) = k(k + 3) mod m

MSU/CSE 260 Fall Hashing for Hiding Information Here, the hash function maps a string to another string with the property of being very difficult to reverse the result of the hash. Used in hiding user’s password

MSU/CSE 260 Fall How password is checked.

MSU/CSE 260 Fall Hashing for file signature The hash function maps a large string (e.g., a file) to a fixed size string called digest Examples:  MD5 (Message-Digest algorithm 5), gives a 128-bit hash (digest)  SHA-1 (Secure Hash Algorithm) is a most commonly used from SHA series of cryptographic hash functions, designed by the National Security Agency  SHA-1 produces the 160-bit hash value. Original SHA (or SHA- 0) also produce 160-bit hash value, but SHA-0 has been withdrawn by the NSA shortly after publication and was superseded by the revised version commonly referred to as SHA-1. The other functions of SHA series produce 224-, 256-, 384- and 512-bit hash values.

MSU/CSE 260 Fall Secure Hashes in Python >>> from hashlib import md5 >>> md5("cse201").hexdigest() 'fa8190eb6032a99f61d822c bf‘ >>> from hashlib import sha1 >>> sha1("cse201").hexdigest() '44dd02666ee b6b5897c6d013fdf41dc1'