Functions A function, f, is a mechanism that relates (or maps) one set of elements to another set. –More specifically, f, is a special type of relation.

Slides:



Advertisements
Similar presentations
Functions Reading: Epp Chp 7.1, 7.2, 7.4
Advertisements

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.
Functions.
Lecture 15 Functions CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Domain Restriction on Relation domain restriction operator,, restricts a relation to only those members whose domain is in a specified set. domain restriction.
12 April 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Formal.
The Engineering Design of Systems: Models and Methods
Copyright © Cengage Learning. All rights reserved. CHAPTER 1 SPEAKING MATHEMATICALLY SPEAKING MATHEMATICALLY.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
1 Functions Chapter 10 Formal Specification using Z.
EE1J2 - Slide 1 EE1J2 – Discrete Maths Lecture 8 Equivalence relations on sets Function between sets Types of function.
Functions Goals Introduce the concept of function Introduce injective, surjective, & bijective functions.
C241 PLTL SESSION – 3/1/2015 Functions & Relations.
Functions. A function between two sets is a relation between those sets that has a special property, namely that each member of the from-set is related.
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,
CS 2210 (22C:019) Discrete Structures Sets and Functions Spring 2015 Sukumar Ghosh.
Functions.
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.
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
2.1 Sets 2.2 Set Operations 2.3 Functions ‒Functions ‒ Injections, Surjections and Bijections ‒ Inverse Functions ‒Composition 2.4 Sequences and Summations.
Relations and Functions Another Foundational Concept Copyright © 2014 – Curt Hill.
Mathematics. Session Set, Relation & Function Session - 3.
 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.
Foundations of Discrete Mathematics Chapter 3 By Dr. Dalia M. Gil, Ph.D.
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.
An ordered n-tuple is a set of n objects with an order associated with them. If n objects are represented by x 1, x 2,..., x n, then we write the ordered.
INM175 Topic 7 1 Module INM175 Discrete Mathematics Topic 7 Set Theoretic Models.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
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.
MAT 3749 Introduction to Analysis Section 1.3 Part I Countable Sets
321 Section, Week 3 Natalie Linnell. Functions A function from A to B is an assignment of exactly one element of B to each element of A. We write f(a)
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)
Functions Definition: A relation ‘ f ’ from set X to set Y is a function if each element in set X is mapped to exactly one element in set Y
Agenda Week 10 Lecture coverage: –Functions –Types of Function –Composite function –Inverse of a function.
Mathematical Induction
Functions. L62 Agenda Section 1.8: Functions Domain, co-domain, range Image, pre-image One-to-one, onto, bijective, inverse Functional composition and.
Discrete Mathematics Relation.
MAT 2720 Discrete Mathematics Section 3.1 Functions
Sets. Definitions (I) Collection of elements such that: There are no duplicates There is no order Special sets Universe (U or E): all elements under consideration.
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.
CSNB 143 Discrete Mathematical Structures
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.
160 as a product of its prime factors is 2 5 x 5 Use this information to show that 160 has 12 factors.
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 Goals Introduce the concept of function
Functions Section 2.3.
Relations and Functions
Overview of Sets an Functions for ICS 6D
Relations, Functions, and Matrices
CS 2210:0001 Discrete Structures Sets and Functions
Cartesian product Given two sets A, B we define their Cartesian product is the set of all the pairs whose first element is in A and second in B. Note that.
Chapter 2 Sets and Functions.
Functions Section 2.3.
CS201: Data Structures and Discrete Mathematics I
Discrete Math (2) Haiming Chen Associate Professor, PhD
CSE15 Discrete Mathematics 02/27/17
Ch 5 Functions Chapter 5: Functions
Warm-Up For the following, make a T-Chart and sketch a graph for x ={-2, -1, 0, 1, 2}
Functions.
Functions Section 2.3.
Copyright © Zeph Grunschlag,
Presentation transcript:

Functions A function, f, is a mechanism that relates (or maps) one set of elements to another set. –More specifically, f, is a special type of relation which associates the element of its domain to a unique element of its range. Let S and T be two sets, then f is often written as: – f : S x T (f defined over a Cartesian Product just like relation) – f : S T –f (s) = t, for s in S (domain) and t in T (range) – s f t, for s in S and t in T Formally, a function, f, over S x T is defined as follows: – f = { \/ s: S; t 1, t 2 : T I ( s f t 1 /\ s f t 2 ) -> t 1 = t 2 }

Function, f, pictorially S = domain of f T = range of f s1 s2 s3 s4 t1 t2 t3 t4 f (s1) = t1 and f (s2) = t ok f (s3) = t ok f (s4) = t3 and f (s4) = t NOT ok X X

Examples of functions f(x) = 2x + 2, for x : N f(x) = 2x + 2, for x : N –this is the same as y = 2x + 2, for x, y : N g = { (1,2), (2,5), (3,10), (n, n 2 +1)}, for n: N 1 g = { (1,2), (2,5), (3,10), (n, n 2 +1)}, for n: N 1 Let S = { tom, jane, maple, sam} and Emp_N = N 1, then f: S x Emp_N may be defined as: Let S = { tom, jane, maple, sam} and Emp_N = N 1, then f: S x Emp_N may be defined as: f = { (tom, 3), (jane, 423) } f = { (tom, 3), (jane, 423) } Is Square Root a function? NO! Sqrt (4) = +2 and Sqrt (4) = -2 Sqrt (4) = +2 and Sqrt (4) = -2 This violates the definition of a function because sqrt results in two values. Employee number is unique

Partial & Total Functions A function, f : S x T, is a partial function if dom f is a proper subset of S. – dom f S (e.g. f(x) = 10/x does not include x = 0) A function, f: S x T, is a total function if the dom f is the same as S. – dom f = S

Injection A function, f: S x T, is called an injection if – f(s1) = t1 and f(s2) = t1, then s1 = s2 Injective functions are also called 1-to-1 functions s1 s2 s3 s5 s4 t1 t2 t3 t4 f(s4) = t4 and f(s5) = t4 would not be allowed if f were an injection X X Note the inverse of f. If f is an injection, then f -1 is also a function

Examples of Injection f = {(1,3), (2,5), (3,2), (11,24) } is an injection f = {(1,3), (2,5), (3,2), (11,24) } is an injection –Note that f -1 = {(3,1), (5,2), (2,3), (24,11)} is also a function. g = {(1,3), (2,5), (3,5), (11,24)} is NOT an injection –Note that g -1 = {(3,1), (5,2), (5,3), (24,11)} is not a function with (5,2) and (5,3) as part of g -1 – So, when f is not an injection, f -1 will not be a function. Is “absolute value” function an injection? Is “absolute value” function an injection? I 4 I = 4 and I -4 I = 4 I 4 I = 4 and I -4 I = 4

Surjection A function, f: S x T, is called a surjection if ran f = T ran f = T A surjective function is also called an onto function For function, f, to be surjective, there can not be t5 in T t1 t2 t3 t4 t5 ST

Examples of Surjection Let A = { a1,a2,a3,a4,a5,a6,a7,a8,a9} and WK_day = { M,T,W,Th,F,S,Sn}, then g : A x WK_day defined below is a surjection g = {(a1, T),(a2, M),(a3,Th),(a4, F),(a5, Sn),(a6,Sn), (a7, W), (a8,S)} g = {(a1, T),(a2, M),(a3,Th),(a4, F),(a5, Sn),(a6,Sn), (a7, W), (a8,S)} but g -1 is not a surjection because a9 would not be included. (and what else can you say about g -1 ?) but g -1 is not a surjection because a9 would not be included. (and what else can you say about g -1 ?) –Is g -1 a total or partial function ? Is it even a function? Example: In a computing file system, the function, f, that maps file_owners to active_files should be a surjection because every active_file is owned by some file_owner. (But What do we have to look out for to make sure that f is even a function? May be it should be f -1 ? May be we should just leave “f” as a relation?)

Bijection A function, f, is called bijective if it both –injective and –surjective A bijective function is also known as isomorphic

Example of bijective function Let S = {0 and positive even integers} and T={positive odd integers}, then g: S x T defined below is a bijection. – g (s) = t = s + 1, for s in S and t in T – note that g -1 is also a bijection Let S = {positive integers} and then f : S x S defined below is NOT a bijection – f(s) = s +1, for s in S – note that range of f does not include 1, which is in S. – note also that the inverse function, f -1, can not include 1 as its domain because f -1 (1) = 0 which is not in S.

Predecessor and Successor functions Let pred stands for predecessor function defined as: – pred: N 1 x N (note that N includes 0 and N 1 does not) – pred = {(1,0); (2,1); (3,2); } Let succ stands for successor function defined as: –Succ: N x N 1 –Succ = { (0,1); (1,2); (2,3); }

Higher-Order functions A higher order function is a function, f, whose domain or range is itself a function.

Example of Higher-order function Model a query that will display all the items in a warehouse –Let w = warehouse names = { Atl, Ny, SanFran, LA}, I = items = {shoes, boots, socks, pants, jackets}, and D = dozens of items = {0, 1, 2, 3}. –Let function f : I x D be defined as the total function that specifies quantity of each item. –Let g : w x P f be the higher-order function that specifies the amount of each item in the warehouses. {remember: P f stands for power set of f } –g = { [Atl, ( (shoes,1),(boots,2),(socks,2),(pants,0),(jackets,1))], [Ny, ( (boots,2),(pants3),(jackets,1) ) ], } g (Atl) = {(shoes, 1), (boots, 2), (socks, 2), (pants, 0), (jackets,1) } g (Atl) = {(shoes, 1), (boots, 2), (socks, 2), (pants, 0), (jackets,1) }

Higher-Order function example re-examine Look at the previous example: –Would you want to redefine function f : I x D ? –Would it be better to have a non-function, but just a relation for this model?