… and the following mathematical appetizer is about…

31
Fall 2002 CMSC 203 - Discrete Structures 1 and the following and the following mathematical appetizer is mathematical appetizer is about… about… Functions Functions

Upload: madison

Post on 25-Feb-2016

21 views

Category:

Documents


1 download

DESCRIPTION

… and the following mathematical appetizer is about…. Functions. Functions. A function f from a set A to a set B is an assignment of exactly one element of B to each element of A. We write f(a) = b if b is the unique element of B assigned by the function f to the element a of A. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 1

… … and the following and the following mathematical appetizer is mathematical appetizer is

about…about…

FunctionsFunctions

Page 2: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 2

FunctionsFunctionsA A functionfunction f from a set A to a set B is an f from a set A to a set B is an assignmentassignment of exactly one element of B to each of exactly one element of B to each element of A.element of A.We writeWe writef(a) = bf(a) = bif b is the unique element of B assigned by the if b is the unique element of B assigned by the function f to the element a of A.function f to the element a of A.If f is a function from A to B, we writeIf f is a function from A to B, we writef: Af: ABB(note: Here, “(note: Here, ““ has nothing to do with if… then)“ has nothing to do with if… then)

Page 3: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 3

FunctionsFunctionsIf f:AIf f:AB, we say that A is the B, we say that A is the domaindomain of f and B of f and B is the is the codomaincodomain of f. of f.

If f(a) = b, we say that b is the If f(a) = b, we say that b is the imageimage of a and of a and a is the a is the pre-imagepre-image of b. of b.

The The rangerange of f:A of f:AB is the set of all images of B is the set of all images of elements of A.elements of A.

We say that f:AWe say that f:AB B mapsmaps A to B. A to B.

Page 4: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 4

FunctionsFunctionsLet us take a look at the function f:PLet us take a look at the function f:PC withC withP = {Linda, Max, Kathy, Peter}P = {Linda, Max, Kathy, Peter}C = {Boston, New York, Hong Kong, Moscow}C = {Boston, New York, Hong Kong, Moscow}

f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong Kongf(Kathy) = Hong Kongf(Peter) = New Yorkf(Peter) = New York

Here, the range of f is C.Here, the range of f is C.

Page 5: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 5

FunctionsFunctionsLet us re-specify f as follows:Let us re-specify f as follows:

f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong Kongf(Kathy) = Hong Kongf(Peter) = Bostonf(Peter) = Boston

Is f still a function?Is f still a function? yesyes{Moscow, Boston, Hong {Moscow, Boston, Hong Kong}Kong}

What is its range?What is its range?

Page 6: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 6

FunctionsFunctionsOther ways to represent f:Other ways to represent f:

BostonBostonPeterPeter

Hong Hong KongKongKathyKathy

BostonBostonMaxMaxMoscowMoscowLindaLinda

f(x)f(x)xx LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

Page 7: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 7

FunctionsFunctionsIf the domain of our function f is large, it is If the domain of our function f is large, it is convenient to specify f with a convenient to specify f with a formulaformula, e.g.:, e.g.:f:f:RRRR f(x) = 2xf(x) = 2x

This leads to:This leads to:f(1) = 2f(1) = 2f(3) = 6f(3) = 6f(-3) = -6f(-3) = -6……

Page 8: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 8

FunctionsFunctionsLet fLet f11 and f and f22 be functions from A to be functions from A to RR..Then the Then the sumsum and the and the productproduct of f of f11 and f and f22 are are also functions from A to also functions from A to RR defined by: defined by:(f(f11 + f + f22)(x) = f)(x) = f11(x) + f(x) + f22(x)(x)(f(f11ff22)(x) = f)(x) = f11(x) f(x) f22(x)(x)

Example:Example:ff11(x) = 3x, f(x) = 3x, f22(x) = x + 5(x) = x + 5(f(f11 + f + f22)(x) = f)(x) = f11(x) + f(x) + f22(x) = 3x + x + 5 = 4x + 5(x) = 3x + x + 5 = 4x + 5(f(f11ff22)(x) = f)(x) = f11(x) f(x) f22(x) = 3x (x + 5) = 3x(x) = 3x (x + 5) = 3x22 + 15x + 15x

Page 9: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 9

FunctionsFunctions

We already know that the We already know that the rangerange of a function of a function f:Af:AB is the set of all images of elements aB is the set of all images of elements aA.A.

If we only regard a If we only regard a subsetsubset S SA, the set of all A, the set of all images of elements simages of elements sS is called the S is called the imageimage of of S.S.

We denote the image of S by f(S):We denote the image of S by f(S):

f(S) = {f(s) | sf(S) = {f(s) | sS}S}

Page 10: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 10

FunctionsFunctionsLet us look at the following well-known function:Let us look at the following well-known function:f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong Kongf(Kathy) = Hong Kongf(Peter) = Bostonf(Peter) = BostonWhat is the image of S = {Linda, Max} ?What is the image of S = {Linda, Max} ?f(S) = {Moscow, Boston}f(S) = {Moscow, Boston}What is the image of S = {Max, Peter} ?What is the image of S = {Max, Peter} ?f(S) = {Boston}f(S) = {Boston}

Page 11: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 11

Properties of FunctionsProperties of Functions

A function f:AA function f:AB is said to be B is said to be one-to-oneone-to-one (or (or injectiveinjective), if and only if), if and only if

x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)

In other words:In other words: f is one-to-one if and only if it f is one-to-one if and only if it does not map two distinct elements of A onto does not map two distinct elements of A onto the same element of B.the same element of B.

Page 12: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 12

Properties of FunctionsProperties of FunctionsAnd again…And again…f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong Kongf(Kathy) = Hong Kongf(Peter) = Bostonf(Peter) = BostonIs f one-to-one?Is f one-to-one?

No, Max and Peter are No, Max and Peter are mapped onto the mapped onto the same element of the same element of the image.image.

g(Linda) = Moscowg(Linda) = Moscowg(Max) = Bostong(Max) = Bostong(Kathy) = Hong g(Kathy) = Hong KongKongg(Peter) = New Yorkg(Peter) = New YorkIs g one-to-one?Is g one-to-one?

Yes, each element is Yes, each element is assigned a unique assigned a unique element of the element of the image.image.

Page 13: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 13

Properties of FunctionsProperties of FunctionsHow can we prove that a function f is one-to-How can we prove that a function f is one-to-one?one?Whenever you want to prove something, first Whenever you want to prove something, first take a look at the relevant definition(s):take a look at the relevant definition(s):x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)Example:Example:f:f:RRRRf(x) = xf(x) = x22

Disproof by counterexample:f(3) = f(-3), but 3 f(3) = f(-3), but 3 -3, so f is not one-to-one. -3, so f is not one-to-one.

Page 14: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 14

Properties of FunctionsProperties of Functions… … and yet another example:and yet another example:f:f:RRRRf(x) = 3xf(x) = 3xOne-to-one: One-to-one: x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)To show:To show: f(x) f(x) f(y) whenever x f(y) whenever x y yx x y y 3x 3x 3y 3y f(x) f(x) f(y), f(y), so if x so if x y, then f(x) y, then f(x) f(y), that is, f is one-to-one. f(y), that is, f is one-to-one.

Page 15: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 15

Properties of FunctionsProperties of FunctionsA function f:AA function f:AB with A,B B with A,B R is called R is called strictly strictly increasingincreasing, if , if x,yx,yA (x < y A (x < y f(x) < f(y)), f(x) < f(y)),and and strictly decreasingstrictly decreasing, if, ifx,yx,yA (x < y A (x < y f(x) > f(y)). f(x) > f(y)).

Obviously, a function that is either strictly Obviously, a function that is either strictly increasing or strictly decreasing is increasing or strictly decreasing is one-to-oneone-to-one..

Page 16: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 16

Properties of FunctionsProperties of FunctionsA function f:AA function f:AB is called B is called ontoonto, or , or surjectivesurjective, if , if and only if for every element band only if for every element bB there is an B there is an element aelement aA with f(a) = b.A with f(a) = b.In other words, f is onto if and only if its In other words, f is onto if and only if its rangerange is is its its entire codomainentire codomain..

A function f: AA function f: AB is a B is a one-to-one one-to-one correspondencecorrespondence, or a , or a bijectionbijection, if and only if it is , if and only if it is both one-to-one and onto.both one-to-one and onto.Obviously, if f is a bijection and A and B are Obviously, if f is a bijection and A and B are finite sets, then |A| = |B|.finite sets, then |A| = |B|.

Page 17: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 17

Properties of FunctionsProperties of Functions

Examples:Examples:In the following examples, we use the arrow In the following examples, we use the arrow representation to illustrate functions f:Arepresentation to illustrate functions f:AB. B.

In each example, the complete sets A and B are In each example, the complete sets A and B are shown.shown.

Page 18: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 18

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?No.No.Is f surjective?Is f surjective?No.No.Is f bijective?Is f bijective?No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

Page 19: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 19

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?No.No.Is f surjective?Is f surjective?Yes.Yes.Is f bijective?Is f bijective?No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

PaulPaul

Page 20: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 20

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?Yes.Yes.Is f surjective?Is f surjective?No.No.Is f bijective?Is f bijective?No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

LLüübeckbeck

Page 21: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 21

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?No! f is not evenNo! f is not evena function!a function!

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

LLüübeckbeck

Page 22: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 22

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?Yes.Yes.Is f surjective?Is f surjective?Yes.Yes.Is f bijective?Is f bijective?Yes.Yes.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

LLüübeckbeckHelenaHelena

Page 23: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 23

InversionInversion

An interesting property of bijections is that An interesting property of bijections is that they have an they have an inverse functioninverse function..

The The inverse functioninverse function of the bijection of the bijection f:Af:AB is the function fB is the function f-1-1:B:BA with A with ff-1-1(b) = a whenever f(a) = b. (b) = a whenever f(a) = b.

Page 24: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 24

InversionInversionExample:Example:

f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong f(Kathy) = Hong KongKongf(Peter) = Lf(Peter) = Lüübeckbeckf(Helena) = New f(Helena) = New YorkYorkClearly, f is Clearly, f is bijective.bijective.

The inverse function The inverse function ff-1-1 is given by: is given by:ff-1-1(Moscow) = Linda(Moscow) = Lindaff-1-1(Boston) = Max(Boston) = Maxff-1-1(Hong Kong) = (Hong Kong) = KathyKathyff-1-1(L(Lüübeck) = Peterbeck) = Peterff-1-1(New York) = (New York) = HelenaHelenaInversion is only Inversion is only possible for possible for bijectionsbijections(= invertible (= invertible functions)functions)

Page 25: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 25

InversionInversionLindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKongMoscowMoscow

LLüübeckbeckHelenaHelena

ff

ff-1-1

ff-1-1:C:CP is no P is no function, because function, because it is not defined it is not defined for all elements of for all elements of C and assigns two C and assigns two images to the pre-images to the pre-image New York.image New York.

Page 26: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 26

CompositionCompositionThe The compositioncomposition of two functions g:A of two functions g:AB B and f:Band f:BC, denoted by fC, denoted by fg, is defined by g, is defined by (f(fg)(a) = f(g(a))g)(a) = f(g(a))This means that This means that • firstfirst, function g is applied to element a, function g is applied to element aA,A, mapping it onto an element of B, mapping it onto an element of B,• thenthen, function f is applied to this element , function f is applied to this element of of B, mapping it onto an element of C. B, mapping it onto an element of C.• ThereforeTherefore, the composite function maps , the composite function maps from A to C. from A to C.

Page 27: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 27

CompositionCompositionExample:Example:

f(x) = 7x – 4, g(x) = 3x,f(x) = 7x – 4, g(x) = 3x,f:f:RRRR, g:, g:RRRR

(f(fg)(5) = f(g(5)) = f(15) = 105 – 4 = 101g)(5) = f(g(5)) = f(15) = 105 – 4 = 101

(f(fg)(x) = f(g(x)) = f(3x) = 21x - 4g)(x) = f(g(x)) = f(3x) = 21x - 4

Page 28: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 28

CompositionComposition

Composition of a function and its inverse:Composition of a function and its inverse:

(f(f-1-1f)(x) = ff)(x) = f-1-1(f(x)) = x(f(x)) = x

The composition of a function and its The composition of a function and its inverse is the inverse is the identity functionidentity function i(x) = x. i(x) = x.

Page 29: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 29

GraphsGraphs

TheThe graphgraph of a functionof a function f:Af:AB is the set of B is the set of ordered pairs {(a, b) | aordered pairs {(a, b) | aA and f(a) = b}.A and f(a) = b}.

The graph is a subset of AThe graph is a subset of AB that can be B that can be used to visualize f in a two-dimensional used to visualize f in a two-dimensional coordinate system.coordinate system.

Page 30: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 30

Floor and Ceiling FunctionsFloor and Ceiling FunctionsThe The floorfloor and and ceilingceiling functions map the real functions map the real numbers onto the integers (numbers onto the integers (RRZZ).).The The floorfloor function assigns to r function assigns to rRR the largest z the largest zZZ with z with z r, denoted by r, denoted by rr..Examples:Examples: 2.32.3 = 2, = 2, 22 = 2, = 2, 0.50.5 = 0, = 0, -3.5-3.5 = -4 = -4The The ceilingceiling function assigns to r function assigns to rRR the smallest the smallest zzZZ with z with z r, denoted by r, denoted by rr..Examples:Examples: 2.32.3 = 3, = 3, 22 = 2, = 2, 0.50.5 = 1, = 1, -3.5-3.5 = -3 = -3

Page 31: … and the following mathematical appetizer is about…

Fall 2002 CMSC 203 - Discrete Structures 31

ExercisesExercises

I recommend Exercises 1 and 15 in Section I recommend Exercises 1 and 15 in Section 1.6.1.6.

It may also be useful to study the graph It may also be useful to study the graph displays in that section. displays in that section.

Another question: What do all graph displays Another question: What do all graph displays for any function f:for any function f:RRR R have in common?have in common?