Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.

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 CSLU Fall 2007 Cameron McInally Fordham University.
Functions, Pigeonhole Principle Lecture 14: Nov 4 A B f( ) =
Functions Section 2.3 of Rosen Fall 2008
Relations and Functions CSRU Binary Relations A binary relation is a mapping between two sets as defined by a rule.
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
Lecture 3 Set Operations & Set Functions. Recap Set: unordered collection of objects Equal sets have the same elements Subset: elements in A are also.
Terminology Domain: set which holds the values to which we apply the function Co-domain: set which holds the possible values (results) of the function.
Functions f( ) = A B Lecture 15: Nov 4.
Discrete Math for CS Chapter 5: Functions. Discrete Math for CS New Relation Operations: Given R, a relation on A x B, we define the inverse relation,
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.
1 CMSC 250 Chapter 7, Functions. 2 CMSC 250 Function terminology l A relationship between elements of two sets such that no element of the first set is.
Discrete Structures Functions Dr. Muhammad Humayoun Assistant Professor COMSATS Institute of Computer Science, Lahore.
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.
Functions A B f( ) =. This Lecture We will define a function formally, and then in the next lecture we will use this concept in counting. We will also.
12.1 Inverse Functions For an inverse function to exist, the function must be one-to-one. One-to-one function – each x-value corresponds to only one y-value.
Relations & Functions CISC1400, Fall 2011 Fordham Univ.
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.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
My Introduction Name: Prakash ADHIKARI Academic Qualification: Master’s Degree Research, Universite Lumiere-IUT Lumiere, Lyon - 2(ULL-2), France Master’s.
Chapter 3 Functions Functions provide a means of expressing relationships between variables, which can be numbers or non-numerical objects.
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.
Week 7 - Friday.  What did we talk about last time?  Set disproofs  Russell’s paradox  Function basics.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
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.
Mathematics for Computing Lecture 8: Functions Dr Andrew Purkiss-Trew Cancer Research UK
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
Discrete Mathematics CS 2610 September 12, Agenda Last class Functions  Vertical line rule  Ordered pairs  Graphical representation  Predicates.
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.
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.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
11 DISCRETE STRUCTURES DISCRETE STRUCTURES UNIT 5 SSK3003 DR. ALI MAMAT 1.
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.
Temperature Readings The equation to convert the temperature from degrees Fahrenheit to degrees Celsius is: c(x) = (x - 32) The equation to convert the.
CSC102 - Discrete Structures Functions
College Algebra Fifth Edition James Stewart Lothar Redlin Saleem Watson.
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.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Functions – Page 1CSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Functions Reading: Kolman, Section 5.1.
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 Goals Introduce the concept of function
Relation and function.
Functions Section 2.3.
Functions.
Functions Rosen 6th ed., §2.3.
Functions Rosen 2.3, 2.5 f( ) = A B Lecture 5: Oct 1, 2.
Functions Section 2.3.
Function 1 st day Objectives: At the end of the class, the learners shall be able to; 1. demonstrate an understanding of key concepts of functions. 2.
Presentation transcript:

Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang

Outline Definition of function Property of functions ◦ Injective, i.e., one-to-one ◦ Surjective: i.e., onto ◦ Pigeonhole principle Function composition Inverse function CSRU1400 Spring 2008Ellen Zhang 2

Functions are everywhere A function is a way of transforming one set of things (usually numbers) into another set of things (also usually numbers). For example: ◦ Fahrenheit to Celsius Conversion (link)link  [°C] = ([°F] − 32) × 5 ⁄ 9 ◦ Closed formula of a sequence: maps position to value (link)link  a n =100*n+1, b n =2 n CSRU1400 Spring 2008Ellen Zhang 3

Components of a function Name, typically a letter like f, g, h, … Domain, a set of values Codomain, a set of values Rule: maps values in the domain to values in the codomain ◦ For every value in the domain, the rule maps it into a single value in the codomain CSRU1400 Spring 2008Ellen Zhang 4

Function f : S  T Function f maps values in set S (domain) to values in set T (codomain) CSRU1400 Spring 2008Ellen Zhang 5 Domain S Codomain T t s f(s)=t f maps s to t t is called the image of s. s is called the pre-image of t. f Useful analogy: elements in S: pigeons elements in T: holes f(s)=t: pigeon s flies into hole t

Using mathematic formula For functions of numbers, the mapping can be specified using formula  f(a) = a + 4, “f of a equals a plus 4”  g(b) = b * b + 2, “g of b equals b times b plus 2”  h(c) = 5, “h of c equals 5” CSRU1400 Spring 2008Ellen Zhang 6

Definition of function as relation Function f: A → B is a relation with domain A and codomain B, and for every, there is exactly one element for which, we write it as f(x)=y. ◦ i.e., a function is a relation where every element in the domain, say x, is related to exactly one element in the codomain, say y. CSRU1400 Spring 2008Ellen Zhang 7 Useful analogy: elements in S: pigeons elements in T: holes f(s)=t: pigeon s flies into hole t every pigeon goes to one hole

Testing whether a mapping is a function … Example. ◦ Domain: {1, 2, 3} ◦ Codomain: {5, 6, 7, 8} ◦ Rule: f(x) =x + 5 Is this a function? ◦ To find out, be very meticulous and walk through each value of the domain CSRU1400 Spring 2008Ellen Zhang 8

Let me try the value 1. f(1) = 1+ 5 = 6 ◦ 6 is in my Codomain. So far it’s working Let me try the value 2. f(2) = = 7 ◦ 7 is in my Codomain. It is still working Let me try the value 3. f(3) = = 8 ◦ 8 is in my Codomain. It is still working I have tried all values in my domain, and they are all mapped to a value in codomain. Therefore this is a function CSRU1400 Spring 2008Ellen Zhang 9 Domain = {1, 2, 3} Codomain = {5, 6, 7, 8} f(x) = x + 5

Ok, begin the same way (take values from the domain and put them in the formula) Choose 0. f(x) = 5 … it’s in the Codomain Choose 1. f(1) = 6 … it’s in the Codomain Choose -1. f(-1) = 4... it’s in the Codomain But we can’t do this forever Hand-waving argument ◦ “Regardless of what integer I take from the domain, I can add 5 to that number and still have a value in the codomain.” CSRU1400 Spring 2008Ellen Zhang 10 Domain = Z (all integers) Codomain = Z (all integers) f(x) = x + 5

Dealing with infinite sets If the domain is infinite, you can’t try all values in the domain So you need to look for values that might not work and try those. If you can’t find any domain values that don’t work, can you make an argument that all the domain values do work ? CSRU1400 Spring 2008Ellen Zhang 11

Choose some values ◦ Choose 0: f(0) = -1 … -1 is not in the codomain, it doesn’t work so it’s not a function CSRU1400 Spring 2008Ellen Zhang 12 Domain = N (natural numbers, i.e., 0,1,2,…) Codomain = N f(x) = x-1

Functions with multiple variables Example: ◦ f(x,y)=x-y, where x takes integer value, and y takes integer value ◦ f maps an ordered pair of integers, i.e., x and y, to their difference (x-y), which is also an integer What’s the domain ? ◦ The set of ordered pairs of integers … ◦ In mathematical notation:, the Cartesian product of Z CSRU1400 Spring 2008Ellen Zhang 13

Outline Definition of function Property of functions ◦ one-to-one ◦ onto ◦ Pigeonhole principle Inverse function Function composition CSRU1400 Spring 2008Ellen Zhang 14

Properties of Functions Two interesting properties of functions ◦ one-to-one ◦ onto ◦ Bijective: one-to-one and onto CSRU1400 Spring 2008Ellen Zhang 15

One-to-one function function f: S → T is one-to-one, if no two different values in the domain are mapped to the same value in codomain. ◦ for two elements, if s 1 ≠s 2, then f(s 1 )≠f(s 2 ) ◦ Equivalently, for two elements, if f(s 1 )=f(s 2 ), then s 1 =s 2 CSRU1400 Spring 2008Ellen Zhang 16 Useful analogy: elements in S: pigeons elements in T: holes f(s)=t: pigeon s flies into hole t every pigeon goes to one hole one-to-one function: no two pigeons go to same hole

Example So we must ask if it is a function? ◦ Choose 1: f(1) = 2 ◦ Choose 2: f(2) = 3 ◦ Choose 3: f(3) = 4 ◦ So it is a function. Is it injective (one-to-one)? Well ◦ we only reached value 2 by using x = 1. ◦ we only reached value 3 by using x = 2. ◦ we only reached value 4 by using x = 3. So it is one-to-one CSRU1400 Spring 2008Ellen Zhang 17 Domain = {1, 2, 3} Codomain = {1, 2, 3, 4} f(x) = x + 1

Is it a function? ◦ f(-2) = 4, f(-1) = 1, f(0) = 0, f(1) = 1, f(2)=4 ◦ So it is a function Is it one-to-one? ◦ No. We can reach the value 4 in two ways. ◦ f(-2)=4 and f(2)=4 For any injective function f: S → T, where S and T are finite, what kind of relation hold between |T|, |S| ? CSRU1400 Spring 2008Ellen Zhang 18 Domain = {-2, -1, 0, 1, 2} Codomain = {0, 1, 2, 3, 4, 5, 6} f(x) = x 2

Pigeonhole Theorem Consider function f: S →T, where S, T are finite sets ◦ If f is one-to-one, then |S|≤|T| ◦ If |S|>|T|, then f is not injective.  at least two diff. values in S are mapped to same value in T Pigeonhole Theorem CSRU1100/CSRU1400 Fall 2008Ellen Zhang 19 Domain S Codomain T t s f

Dealing with infinite sets Is the function injective (one-to-one) ? What does this function look like ? ◦ One can use Excel to plot a function (link)link A function is injective if its graph is never intersected by a horizontal line more than once. CSRU1400 Spring 2008Ellen Zhang 20 f: R → R with the rule f(x)=x 2 +4x+1

Onto Functions A function is onto if every value in the codomain is the image of some value in the domain (i.e., every value in the codomain is taken) ◦ f: S → T is onto if for any element t in T, there exists an element s in S, such that f(s)=t Let Range of f, ran(f), be the set of all values that f can take: ◦ For onto function f, ran(f)=T CSRU1400 Spring 2008Ellen Zhang 21

Surjective function example First you have to figure out if it is a function or not. ◦ Choose 1: f(1) = 11 ◦ Choose 2: f(2) = 12 ◦ Choose 3: f(3) = 13 ◦ Choose 4: f(4) = 14 ◦ So it is a function Is it onto? ◦ Yes. Because we covered all of the Codomain values, i.e., every value of codomain is an image of some values in the domain. CSRU1400 Spring 2008Ellen Zhang 22 Domain = {1, 2, 3, 4} Codomain = {11, 12, 13, 14} f(x) = x + 10

Determine whether it is a function ◦ Choose 1: f(1) = 0 ◦ Choose 2: f(2) = 1 ◦ Choose 3: f(3) = 2 ◦ So it is a function. Is it onto? ◦ No, we never arrived at the value 3 which is in the Codomain CSRU1400 Spring 2008Ellen Zhang 23 Domain = {1, 2, 3} Codomain = {0, 1, 2, 3} f(x) = x -1

Property of onto function Consider function f: S →T, with S, T finite ◦ If f is onto, then |S|≥|T| ◦ If |S|<|T|, then f is not onto  There is some element in T that is not mapped to CSRU1100/CSRU1400 Fall 2008Ellen Zhang 24 Domain S Codomain T t s f Useful analogy: elements in S: pigeons elements in T: holes f(s)=t: pigeon s flies into hole t every pigeon goes to one hole onto function: every hole is occupied by some pigeon(s)

Dealing with infinite sets* Is it a function? Is it an onto function ? ◦ For every CSRU1400 Spring 2008Ellen Zhang 25 f: R → R with the rule f(x)=x 2 +1

Bijection A function that is both onto and one-to- one is called a bijection, or we say the function is bijective. Consider function f: S →T, with S, T finite ◦ If f is bijective (one-to-one and onto), then |S|=|T|  as f is one-to-one, we have |S|≤|T|  as f is onto, we have |S|≥|T| CSRU1400 Spring 2008Ellen Zhang 26 Useful analogy: elements in S: pigeons elements in T: holes f(s)=t: pigeon s flies into hole t every pigeon goes to one hole bijective function: every hole is occupied by exactly one pigeon

Invertible functions Give a function f: S →T, what happens if we “invert” the mapping, and get a new relation ? ◦ Make T the new domain ◦ Make S the new codomain ◦ If is mapped to, we now map t to s Do we get a function this way ? ◦ i.e., is any value in the new domain (T) being mapped to one and only one value in the new domain S ? If we get a function after we insert the mapping, the f is called invertible.

Formal definition of inverse Function f: A →B is invertible if there is a function f -1 :B →A such that f(x)=y if and only if f -1 (y)=x. f -1 : read as “ f inverse ”

What kind of function is invertible? Every value in the codomain has values in the domain mapped to it ◦ The function is onto. ◦ Every value in the codomain has only one value in the domain mapped to it. ◦ i.e. the function is one-to-one ◦ A function is invertible if it’s bijective. CSRU1400 Spring 2008Ellen Zhang 29

Finding inverse function To find inverse of function f ◦ First check if f is invertible (i.e., bijective) ◦ Make the old codomain the new domain ◦ Make the old domain the new codomain ◦ Reverse the mapping CSRU1400 Spring 2008Ellen Zhang 30

Reverse the mapping If the mapping is given by the set of ordered pairs ◦ Just reverse the first- and second- components of each pair If the function is given by a diagram ◦ Reverse the directions of the arrows If the function is given by a formula, f(x) ◦ Solve the formula for x, i.e., express x in terms of f(x) CSRU1400 Spring 2008Ellen Zhang 31

Inverse Example, f -1 New domain = {4, 8, 12, 16} New Codomain = {2, 4, 6, 8} Original mapping maps x to y=f(x)=2x Reverse mapping map y to x, i.e., given y, what’s the x ? (express x in terms of y)  Solve y=2x for x, we get x=y/2. Inverse function is ◦ f -1 : {4,8,12,16} →{2,4,6,8}, f -1 (y)=y/2 CSRU1400 Spring 2008Ellen Zhang 32 Domain = {2, 4, 6, 8} Codomain = {4, 8, 12, 16} f(x) = 2x

Examples Are the following functions invertible ? Find inverse for those invertible. ◦ f: R →R, with f(x)=3x+6 ◦ f:R →R, with f(x)=x 2 ◦ g:Z →Z, with the rule:

Outline Definition of function Property of functions ◦ Onto ◦ One-to-one ◦ Pigeonhole principle ◦ Inverse function Function composition CSRU1400 Spring 2008Ellen Zhang 34

Function Composition We can chain functions together – this is called composition (apply the mappings subsequently) f ◦ g (reads “f composed with g”) defined as f ◦ g (x)=f(g(x)) (note apply g first, then f) ◦ First apply mapping of g, then apply mapping of f CSRU1400 Spring 2008Ellen Zhang35 g(x) x f(g(x)) gf f ◦ gf ◦ g

Function Composition Example Example: for f, g with domain/codomain of R ◦ f(x) = x+5, g(x) = 2x + 3 ◦ f ◦ g (x)=f(g(x)) =f(2x+3) =(2x+3) + 5 =2x + 8 ◦ g ◦ f (x)=g(f(x)) =g(x+5) = 2(x+5) + 3 = 2x + 13 CSRU1400 Spring 2008Ellen Zhang36

What is f ◦ g ? What is g ◦ f? What is f ◦ f? What is g ◦ g ? What is f ◦ g for g(2)? CSRU1400 Spring 2008Ellen Zhang 37 Assume we have two functions with Domains and Codomains over all integers f(x) = 3x – 2 g(x) = x * x f(x*x) = 3(x*x)-2 = 3x 2 -2 g(3x-2) = (3x-2)*(3x-2)=9x 2 -12x+4 f(3x-2) = 3(3x-2)-2 = 9x-8 g(x*x) = (x*x) * (x*x) = x 4 f(g(2)) = f(4) = 3(4) – 2 = 10 f(g(2)) = f(4) = 3(4) – 2 = 10

Function Compositions CSRU1100/CSRU1400 Fall 2008Ellen Zhang 38 Assume we have two functions with Domains and Codomains over all real numbers … f(x) = 3x – 2 g(x) = x 3 h(x) = x/4 What is f -1 ? What is f ◦ f -1 ? What is f -1 ◦ f? What is f ◦ g ◦ f -1 ? What is f ◦ f -1 ◦ g?