Functions Discrete Structure. L62 Functions. Basic-Terms. DEF: A function f : A  B is given by a domain set A, a codomain set B, and a rule which for.

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

© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Manish Kumar PRE. 1 Theory Of Computation Pre-requisite.
Copyright © Cengage Learning. All rights reserved.
Functions; Sequences, Sums, Countability
Functions Section 2.3 of Rosen Fall 2008
Discrete Structures Chapter 5 Relations and Functions Nurul Amelina Nasharuddin Multimedia Department.
Discrete Mathematics Lecture 7 Alexander Bukharovich New York University.
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,
February 5, 2015Applied Discrete Mathematics Week 1: Logic and Sets 1 Homework Solution PQ  (P  Q) (  P)  (  Q)  (P  Q)  (  P)  (  Q) truetruefalsefalsetrue.
Functions.
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.
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.
Functions Definition & purpose Notation Functions on binary / returning binary values Finite automaton model We haven’t completely left the world of counting.
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,
Discrete Maths Objectives to show the connection between relations and functions, and to introduce some functions with useful, special properties ,
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.
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.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Fall 2002CMSC Discrete Structures1 … and the following mathematical appetizer is about… Functions.
10/26/20151 … and the following mathematical appetizer is about… Functions.
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.
MSU/CSE 260 Fall Functions Read Section 1.8.
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
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
CSC102 - Discrete Structures Functions
RECURRENCE Sequence Recursively defined 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.
Functions CSRU1400 Spring 2008Ellen Zhang 1 CISC1400, Fall 2010 Ellen Zhang.
1 RECURRENCE 1. Sequence 2. Recursively defined sequence 3. Finding an explicit formula for recurrence relation.
Ch02-Basic Structures: Sets, Functions, Sequences, Sums, and Matrices 1.
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 7/7/2016COCS - Discrete Structures1. Functions A function f from a set A to a set B is an assignment of exactly one element of B to each element.
Sequences Lecture 11. L62 Sequences Sequences are a way of ordering lists of objects. Java arrays are a type of sequence of finite size. Usually, mathematical.
Functions Section 2.3.
Applied Discrete Mathematics Week 2: Functions and Sequences
A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0.
MATH 224 – Discrete Mathematics
Functions.
… and the following mathematical appetizer is about…
Functions.
Discrete Math for Computer Science CSC 281
Discrete Structure Sets.
Functions Section 2.3.
Discrete Math (2) Haiming Chen Associate Professor, PhD
Functions.
CS100: Discrete structures
… and the following mathematical appetizer is about…
… and the following mathematical appetizer is about…
SE-561 Math Foundations of Software Engineering VIII. Functions
Properties of Functions
Functions Section 2.3.
Copyright © Zeph Grunschlag,
Presentation transcript:

Functions Discrete Structure

L62 Functions. Basic-Terms. DEF: A function f : A  B is given by a domain set A, a codomain set B, and a rule which for every element a of A, specifies a unique element f (a) in B. f (a) is called the image of a, while a is called the pre-image of f (a). The range (or image) of f is defined by f (A) = {f (a) | a  A }.

3 Functions Let us take a look at the function f:P  C with P = {Linda, Max, Kathy, Peter} C = {Boston, New York, Hong Kong, Moscow} f(Linda) = Moscow f(Max) = Boston f(Kathy) = Hong Kong f(Peter) = New York Here, the range of f is C.

L64 Functions. Basic-Terms. f : Z  R is given by f (x ) = x 2 A1: domain is Z, co-domain is R A2: image of -3 = f (-3) = 9 A3: pre-images of 3: none as  3 isn’t an integer! pre-images of 4: -2 and 2 A4: range is the set of perfect squares f (Z) = {0,1,4,9,16,25,…}

L65 Functions and Java Java: Functions are like non-void Java methods. The domain is the parameter type and the codomain is the return type. The image is the return value. EG: int f(double x){ return x<0 ? –1 : ( x>0 ? 1 : 0 ); } The domain is double the codomain is int. Q: What does this function do?

L66 One-to-One, Onto, Bijection. Intuitively. Represent functions using “node and arrow” notation: One-to-One means that no clashes occur. BAD:a clash occurred, not 1-to-1 GOOD:no clashes, is 1-to-1 Onto means that every possible output is hit BAD: 3 rd output missed, not onto GOOD:everything hit, onto

L67 One-to-One, Onto, Bijection. Intuitively. Bijection means that when arrows reversed, a function results. Equivalently, that both one-to-one’ness and onto’ness occur. BAD:not 1-to-1. Reverse over-determined: BAD:not onto. Reverse under-determined: GOOD:Bijection. Reverse is a function:

8 Properties of Functions Is f injective? Yes. Is f surjective? Yes. Is f bijective? Yes. Linda Max Kathy Peter Boston New York Hong Kong Moscow Lübeck Helena

L69 One-to-One, Onto, Bijection. Formal Definition. DEF: A function f : A  B is: one-to-one (or injective) if different elements of A always result in different images in B. onto (or surjective) if every element in B is hit by f. I.e., f (A ) = B. a one-to-one correspondence (or a bijection, or invertible) if f is both one-to-one as well as onto. If f is invertible, its inverse f -1 : B  A is well defined by taking the unique element in the pre- image of b, for each b  B.

L610 One-to-One, Onto, Bijection. Examples. 1. f : Z  R, f (x ) = x 2 : none 2. f : Z  Z, f (x ) = 2x : f : R  R, f (x ) = x 3 : 1-1, onto, bijection, inverse is f (x ) = x (1/3) 4. f : Z  N, f (x ) = |x |: onto 5. f (x ) = the father of x : none

L611 Composition When a function f spits out elements of the same kind that another function g eats, f and g may be composed by letting g immediately eat each output of f. DEF: Suppose that g : A  B and f : B  C are functions. Then the composite f  g : A  C is defined by setting f  g (a) = f ( g (a) )

L612 Composition. Examples. Q: Compute g  f where 1.f : Z  R, f (x ) = x 2 and g : R  R, g (x ) = x 3 2. f : Z  Z, f (x ) = x + 1 and g = f -1 so g (x ) = x – 1 3. f : {people}  {people}, f (x ) = the father of x, and g = f

L613 Composition. Examples. 1.f : Z  R, f (x ) = x 2 and g : R  R, g (x ) = x 3 f  g : Z  R, f  g (x ) = x 6 2. f : Z  Z, f (x ) = x + 1 and g = f -1 f  g (x ) = x (true for any function composed with its inverse) 3. f : {people}  {people}, f (x ) = g(x ) = the father of x f  g (x ) = grandfather of x from father’s side

14 Composition Example: f(x) = 7x – 4, g(x) = 3x, f:R  R, g:R  R (f  g)(5) = f(g(5)) = f(15) = 105 – 4 = 101 (f  g)(x) = f(g(x)) = f(3x) = 21x - 4

Ceiling and Floor DEF: Given a real number x : The floor of x is the biggest integer which is smaller or equal to x The ceiling of x is the smallest integer greater or equal to x. NOTATION: floor(x) =  x , ceiling(x) =  x  Q: Compute  1.7 ,  -1.7 ,  1.7 ,  .

L616 Ceiling and Floor A:  1.7  = 1,  -1.7  = -2,  1.7  = 2,  -1.7  = -1 Q: What’s the difference between the floor function and the (int) casting function in Java?

a0a0 a1a1 a2a2 anan a n-1 a 0 =0 a 1 =2 a 2 =6 a 3 =12 a 4 =20

Recursive Definitions F(0) = 0; F(n + 1) = F(n) + 1; F(0) = 1; F(n + 1) = 2  F(n); F(0) = 1; F(n + 1) = 2 F(n)

The First-Order Linear Recurrence Relation There are many sequences that satisfy For example, 5,15,45,135,... or 7,21,63,189,.... To pinpoint the particular sequence described, we need to know one of the terms of the sequence. (boundary condition, or initial condition since usually a 0 is specified)

The First-Order Linear Recurrence Relation nonhomogeneous linear recurrence relation Ex time complexity of bubble sort algorithm a n =a n-1 +(n-1), n>1, a 1 =0, where a n =the number of comparisons to sort n numbers a n - a n-1 = n-1 a n-1 - a n-2 = n-2 a n-2 - a n-3 = n-3 a 2 - a 1 = 1 + a n = (n-1)=(n 2 -n)/2

The Second-Order Linear Homogeneous Recurrence Relation with Constant Coefficients Be careful not to draw conclusions from a few (or even, perhaps, many) particular instances. Ex Arrange pennies contiguously in each row where each penny above the bottom row touches two pennies in the row below it. a 1 =1,a 2 =1,a 3 =2,a 4 =3,a 5 =5,a 6 =8,... Is a n =F n ? NO

Sequences DEF: Given a set S, an (infinite) sequence in S is a function N  S. Symbolically, a sequence is represented using the subscript notation a i. This gives a way of specifying formulaically Note: Other sets can be taken as ordering models. Q: Give the first 5 terms of the sequence defined by the formula

Sequence Examples A: Plug in for i in sequence 0, 1, 2, 3, 4: Formulas for sequences often represent patterns in the sequence. Q: Provide a simple formula for each sequence: a) 3,6,11,18,27,38,51, … b) 0,2,8,26,80,242,728,… c) 1,1,2,3,5,8,13,21,34,…

L624 Sequence Examples A: Try to find the patterns between numbers. a) 3,6,11,18,27,38,51, … a 1 =6=3+3, a 2 =11=6+5, a 3 =18=11+7, … and in general a i +1 = a i +(2i +3). This is actually a good enough formula. Later we’ll learn techniques that show how to get the more explicit formula: a i = 6 + 4(i –1) + (i –1) 2 b) 0,2,8,26,80,242,728,… If you add 1 you’ll see the pattern more clearly. a i = 3 i –1 c) 1,1,2,3,5,8,13,21,34,… This is the famous Fibonacci sequence given by a i +1 = a i + a i-1

Definition of Finite Automaton The finite automaton has 5-tuple (Q, ∑, δ, q0, F) Q is a set of states ∑ is a set of input alphabet δ is a transition function or rule for moving q0 is a start state F is a set of accept states

Finite automaton If the input is: & 0100 & & & What is the outputs? q3 q2 q , 1

The finite automaton M is (Q, ∑, δ, q0, F) Where Q = {q1, q2, q3} ∑ = {0, 1} q0 is the state q1 F = {q2} q3 q2 q , 1

δ is describes as 0 1 q1q1q2 q2q3q2 q3q2q2 q3 q2 q , 1

Example r2 q1 s b a b a r1 q2 b a aab b

For the start state, is even because it is possible to input 0 so far q even q odd For the accept state, we consider qodd because we want to test odd numbers qodd

Example The inputs a, b, baba, baa, bbb,  q2 q1 a  q3 b a a, b

0 0, The machine accepts a string if the process ends in a double circle Anatomy of a Deterministic Finite Automaton states q0q0 q1q1 q2q2 q3q3 start state (q 0 ) accept states (F)

Anatomy of a Deterministic Finite Automaton 0 0, q0q0 q1q1 q2q2 q3q3 The alphabet of a finite automaton is the set where the symbols come from: The language of a finite automaton is the set of strings that it accepts {0,1}

Q = {q 0, q 1, q 2, q 3 } Σ = {0,1}  : Q  Σ → Q transition function * q 0  Q is start state F = {q 1, q 2 }  Q accept states M = (Q, Σ, , q 0, F) where  01 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q2q2 q3q3 q2q2 q3q3 q0q0 q2q2 * q2q2 0 0, q0q0 q1q1 q3q3 M