CS 220: Discrete Structures and their Applications. Functions Chapter 5 in zybooks

Similar documents
9/21/17. Functions. CS 220: Discrete Structures and their Applications. Functions. Chapter 5 in zybooks. definition. definition

Section Summary. Definition of a Function.

Func%ons. function f to the element a of A. Functions are sometimes called mappings or transformations.

Sec$on Summary. Definition of a Function.

Section 4.4 Functions. CS 130 Discrete Structures

9/21/2018. Properties of Functions. Properties of Functions. Properties of Functions. Properties of Functions. Properties of Functions

CS100: DISCRETE STRUCTURES

2.1 Sets. Definition 1 A set is an unordered collection of objects. Important sets: N, Z, Z +, Q, R.

Section Summary. Definition of a Function.

Functions as Relations

Sets and Functions. MATH 464/506, Real Analysis. J. Robert Buchanan. Summer Department of Mathematics. J. Robert Buchanan Sets and Functions

Functions. Given a function f: A B:

Functions. Definition 1 Let A and B be sets. A relation between A and B is any subset of A B.

Sets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth

Chapter Summary. Sets (2.1) Set Operations (2.2) Functions (2.3) Sequences and Summations (2.4) Cardinality of Sets (2.5) Matrices (2.

Notes. Functions. Introduction. Notes. Notes. Definition Function. Definition. Slides by Christopher M. Bourke Instructor: Berthe Y.

3 FUNCTIONS. 3.1 Definition and Basic Properties. c Dr Oksana Shatalov, Fall

Chapter Summary. Sets The Language of Sets Set Operations Set Identities Functions Types of Functions Operations on Functions Computability

Today s Topics. Methods of proof Relationships to logical equivalences. Important definitions Relationships to sets, relations Special functions

LESSON RELATIONS & FUNCTION THEORY

3 FUNCTIONS. 3.1 Definition and Basic Properties. c Dr Oksana Shatalov, Spring

3 FUNCTIONS. 3.1 Definition and Basic Properties. c Dr Oksana Shatalov, Fall

Week Some Warm-up Questions

4.1 Real-valued functions of a real variable

Sets and Functions. (As we will see, in describing a set the order in which elements are listed is irrelevant).

Functions Functions and Modeling A UTeach/TNT Course

Cartesian Products and Relations

4) Have you met any functions during our previous lectures in this course?

Introduction to Decision Sciences Lecture 6

Solutions to Homework Problems

RELATIONS AND FUNCTIONS

CSCE 222 Discrete Structures for Computing

Discrete dynamics on the real line

EASY PUTNAM PROBLEMS

A function is a special kind of relation. More precisely... A function f from A to B is a relation on A B such that. f (x) = y

MATH 22 FUNCTIONS: COMPOSITION & INVERSES. Lecture N: 10/16/2003. Mad world! mad kings! mad composition! Shakespeare, King John, II:1

Functions Modeling Change A Preparation for Calculus Third Edition

MATH 3300 Test 1. Name: Student Id:

REVIEW FOR THIRD 3200 MIDTERM

SETS AND FUNCTIONS JOSHUA BALLEW

MATH 13 SAMPLE FINAL EXAM SOLUTIONS

Real Analysis. Joe Patten August 12, 2018

5 FUNCTIONS. 5.1 Definition and Basic Properties. c Dr Oksana Shatalov, Fall

Solved Examples. Given are two sets A {1, 2, -2, 3} and B = {1, 2, 3, 5}. Is the function f(x) = 2x - 1 defined from A to B?

9 FUNCTIONS. 9.1 The Definition of Function. c Dr Oksana Shatalov, Fall

Propositional Logic, Predicates, and Equivalence

QF101: Quantitative Finance August 22, Week 1: Functions. Facilitator: Christopher Ting AY 2017/2018

Relations, Functions & Binary Operations

AMB111F Notes 1: Sets and Real Numbers

Relations, Functions, Binary Relations (Chapter 1, Sections 1.2, 1.3)

447 HOMEWORK SET 1 IAN FRANCIS

Introduction to Functions

0 Sets and Induction. Sets

Introduction to Topology

Selected problems from past exams

CLASS12 RELATIONS AND FUNCTIONS

Math 421, Homework #9 Solutions

CSE 20 DISCRETE MATH. Fall

Chapter 1. Sets and Mappings


MATH 101: ALGEBRA I WORKSHEET, DAY #1. We review the prerequisites for the course in set theory and beginning a first pass on group. 1.

x x 1 x 2 + x 2 1 > 0. HW5. Text defines:

f(x) x

1.4 Cardinality. Tom Lewis. Fall Term Tom Lewis () 1.4 Cardinality Fall Term / 9

Math 127 Homework. Mary Radcliffe. Due 29 March Complete the following problems. Fully justify each response.

Discussion Summary 10/16/2018

CHAPTER 7 FUNCTIONS. Alessandro Artale UniBZ - artale/

Math 42, Discrete Mathematics

2 Functions. 2.1 What is a function?

MTH4100 Calculus I. Lecture notes for Week 2. Thomas Calculus, Sections 1.3 to 1.5. Rainer Klages

RELATIONS AND FUNCTIONS

Sets, Functions and Relations

Practice Exam 1 CIS/CSE 607, Spring 2009

Sets McGraw-Hill Education

Walker Ray Econ 204 Problem Set 3 Suggested Solutions August 6, 2015

Inverse Functions. One-to-one. Horizontal line test. Onto

1 Basic Combinatorics

Solution: f( 1) = 3 1)

Chapter-2 Relations and Functions. Miscellaneous

Chapter 2 - Basics Structures MATH 213. Chapter 2: Basic Structures. Dr. Eric Bancroft. Fall Dr. Eric Bancroft MATH 213 Fall / 60

SRI RAMAKRISHNA INSTITUTE OF TECHNOLOGY COIMBATORE Discrete Mathematics Functions

COM S 330 Homework 05 Solutions. Type your answers to the following questions and submit a PDF file to Blackboard. One page per problem.

Theorem. For every positive integer n, the sum of the positive integers from 1 to n is n(n+1)

Chapter 2 - Basics Structures

Math 110 Midterm 1 Study Guide October 14, 2013

On the Countable Dense Homogeneity of Euclidean Spaces. Randall Gay

Review of Functions. Functions. Philippe B. Laval. Current Semester KSU. Philippe B. Laval (KSU) Functions Current Semester 1 / 12

MAT115A-21 COMPLETE LECTURE NOTES

(a) We need to prove that is reflexive, symmetric and transitive. 2b + a = 3a + 3b (2a + b) = 3a + 3b 3k = 3(a + b k)

Unit 7 Inverse and Radical Functions

Exam Practice Problems

page 1 of 14 1 for all x because f 1 = f and1 f = f. The identity for = x for all x because f

Functional Equations

Functions of Several Variables (Rudin)

Math 300: Final Exam Practice Solutions

Mathematics 220 Workshop Cardinality. Some harder problems on cardinality.

Basic Concepts of Group Theory

Math 300 Introduction to Mathematical Reasoning Autumn 2017 Inverse Functions

MATH 215 Sets (S) Definition 1 A set is a collection of objects. The objects in a set X are called elements of X.

COMPOSITION OF FUNCTIONS

Transcription:

CS 220: Discrete Structures and their Applications Functions Chapter 5 in zybooks

Functions A function maps elements from one set X to elements of another set Y. A Brian Drew Alan Ben B C D F range: {A, B, D} domain X = {Brian, Drew, Alan, Ben} target Y = {A,B,C,D,F} The range contains the target values that the function maps to

definition Let X and Y be nonempty sets. A function from X to Y is an assignment of exactly one element of Y to each element of X. Notation: f: X Y, f(x) = y Specifying a function: Formula: f(x) = x + 1 Explicit specification: A Brian Drew Alan Ben B C D F

definition A function f that maps elements of a set X to elements of a set Y, is a subset of X Y such that for every x X, there is exactly one y Y for which (x, y) f. The fact that f maps x to y (or (x, y) f) is denoted as f(x) = y. f: X Y X - the domain of f Y - the target of f The range of f: { y : (x, y) f, for some x X } same as: { y : f(x)=y, for some x X } It is a subset of the target.

functions One of these diagrams does not represent a valid function. domain, target, range?

Examples Let f be the function that assigns the last two bits of a binary bit string of length >= 2. For example: f(11010) = 10 What is the: Domain, target, and range?

The floor function The floor function rounds x down to the closest integer less than or equal to x. floor: R Z floor(x) = the largest integer y such that y x. Notation: floor(x)= x Examples: 4.32 =4 4.32 = 5 4 =4 4 = 4

The ceiling function The ceiling function rounds x up to the closest integer greater than or equal to x. ceiling: R Z ceiling(x) = the smallest integer y such that x y. Notation: ceiling(x)= x Examples: 4.32 =5 4.32 = 4 4 =4 4 = 4

Floor or ceiling? A baker is packaging cookies in boxes of 8. He has y cookies to put into boxes. How many boxes can he sell?

one-to-one functions A function f is said to be one-to-one or injective if and only if x 1 x 2 implies that f(x 1 ) f(x 2 ) for all x 1 and x 2 in the domain of f. Example: 1 2 3 4 1 2 3 4 9 16

one-to-one functions A function f is said to be one-to-one or injective if and only if x 1 x 2 implies that f(x 1 ) f(x 2 ) for all x 1 and x 2 in the domain of f. what about f(x) = x 2 with the domain Z? what about f(x) = x 2 with the domain Z +?

onto functions A function f: X Y is said to be onto or surjective if and only if for every y in Y there is an x in X with f(x) = y. In other words: its range equals its target. Are these functions onto? The function f : {a,b,c,d} {1,2,3} defined by f(a) = 3, f(b) = 2, f(c) = 1 and f(d) = 3 The square function with the domain of Z + The function f(x) = x + 1 on Z

bijections A function f is a one-to-one correspondence, or a bijection, if it is both one-to-one and onto. Are these functions one-to-one correspondences? The function f : {a,b,c,d} {1,2,3} defined by f(a) = 3, f(b) = 2, f(c) = 1 and f(d) = 3 The square function with the domain of Z + The function f(x) = x + 1 on Z

onto/one-to-one/bijections Consider f : A X If f is onto, then for every element in the target, there is at least one element in the domain so A X. If f is one-to-one, then for every element in the domain, there is a at least one element in the target: A X. If f is a bijection: A = X.

Inverse functions We want to define the inverse of a function f: a function f -1 that undoes the action of f. Example: the square root undoes the action of f(x) = x 2. What properties does f need to have for an inverse to exist? one-to-one? onto?

Inverse functions Let f: X Y be a bijection. The inverse of f is the function f -1 : Y X that assigns to an element y in Y the element x in X such that f(x) = y, i.e., f 1 (y) = x when f(x) = y. f x=f -1 (y) X f 1 y=f(x) Y

Inverse functions Let f: X Y be a bijection. The inverse of f is the function f -1 : Y X that assigns to an element y in Y the element x in X such that f(x) = y, i.e., f 1 (y) = x when f(x) = y. Do these functions have an inverse?

Inverse functions Let f: X Y be a bijection. The inverse of f is the function f -1 : Y X that assigns to an element y in Y the element x in X such that f(x) = y, i.e., f 1 (y) = x when f(x) = y. An alternative definition: f -1 = { (y, x) : (x, y) f }.

Inverse functions Let f: X Y be a bijection. The inverse of f is the function f -1 : Y X that assigns to an element y in Y the element x in X such that f(x) = y, i.e., f 1 (y) = x when f(x) = y. Example: Let f : Z Z be f(x) = x + 1. Is f invertible? What s the inverse?

Inverse functions Are the following functions invertible? ² f: {0, 1} 3 {0, 1} 3. f takes the input string and reverses the bits. For example, f(011) = 110. ² f: {0, 1} 3 {0, 1} 3. f takes the input string x, removing the first bit of x, and adding the bit to the end of x. For example, f(011) = 110. ² f: {0, 1} 3 {0, 1} 3. f takes the input string and replaces the first bit by 1. For example, f(001) = 101 and f(110) = 110.

Composition of functions Let f and g be functions f: X Y and g: Y Z. The composition of g with f, denoted g!f, is the function (g!f) : X Z, such that (g!f)(x) = g(f(x)) for all x X. f g X Y g!f Z

Composition of functions Order of composition matters! Let f(x) = 2x + 3, g(x) = 3x + 2 (f!g)(x) = f(g(x)) = f(3x + 2) = 2(3x + 2) + 3 = 6x + 7 (g!f)(x) = g(f(x)) = g(2x + 3) = 3(2x + 3) + 2 = 6x + 11

Composition of functions What is (f -1!f)(x) and (f!f -1 )(y)?

The identity function The identity function on A, denoted I A : A A, is defined as I A (a) = a, for all a A. The identity function always maps a set onto itself and maps every element to itself. If a function f from A to B has an inverse, then f composed with its inverse is the identity function. If f(a) = b, then f -1 (b) = a, and (f f-1!f)(a) = f -1 (f(a)) = f -1 (b) = a. Let f: A B be a bijection. Then f -1!f = I A and f!f -1 = I B.

increasing/decreasing functions A function f is said to be strictly increasing if whenever x 1 < x 2, then f(x 1 ) < f(x 2 ). A function f is said to be strictly decreasing if whenever x 1 < x 2, then f(x 1 ) > f(x 2 ). Is floor increasing? strictly increasing? Is square (when restricted to positive numbers) increasing? strictly increasing?

increasing functions A strictly increasing function is one-to-one. Is increasing a sufficient condition? (i.e. is an increasing function one-to-one?)

Cartesian products and functions A function with multiple arguments has a cartesian product as its domain. Example: min maps R x R to R min(5.3, 10) = 5.3

exponents and logarithms The exponential function exp b : R R + is defined as: exp b (x)=b x where b is a positive real number and b 1. The parameter b is called the base of the exponent. The input x is called the exponent. Properties of exponents:

the logarithm function The exponential function is one-to-one and onto, and therefore has an inverse. The logarithm function is the inverse of the exponential function. For real number b > 0 and b 1, log b : R + R is defined as: b x =y log b y=x The parameter b is called the base of the logarithm

dividing chocolates Ingrid has a bag with n chocolates, where n > 0. Ingrid meets a friend and splits her chocolates into two evenly sized piles and gives her friend the chocolates in one of the piles and puts the rest in her bag. Then she meets another friend and splits her chocolates again. Every time she meets a friend, she shares half of her chocolates with the friend. How many friends can she meet and share half her chocolates before she is down to one chocolate in her bag?

dividing chocolates Ingrid has a bag with n chocolates, where n > 0. Ingrid meets a friend and splits her chocolates into two evenly sized piles and gives her friend the chocolates in one of the piles and puts the rest in her bag. Then she meets another friend and splits her chocolates again. Every time she meets a friend, she shares half of her chocolates with the friend. How many friends can she meet and share half her chocolates before she is down to one chocolate in her bag? First, consider the case where n is a power of 2, i.e. n=2 k

dividing chocolates What if the number of chocolates is not a power of 2? At some point, Ingrid will have an odd number of chocolates, and she needs to choose whether to take the smaller or larger half.

dividing chocolates Theorem: Dividing piles and the logarithm function. Let n and b be positive integers with b > 1. Consider a process in which in each step, n is replaced with n/b until n < b. The process takes log b n steps. If instead in each step, n is replaced with n/b until n < b, the process takes log b n steps.

Logarithms and programming Binary search define the steps, explain how many steps Merge sort define the steps, explain how many steps Quick sort?