cse240 lecture13 3-4-19webtodd/... · 3extensible networking platform-cse 240 –logic and discrete...

15
1 - CSE 240 – Logic and Discrete Mathematics Announcements Homework 5 was due this morning Homework 6 is posted online Read Section 2.4 (Sequences and Summations) by Wednesday Quiz 4 is today Quiz 5 is on Wednesday 2 - CSE 240 – Logic and Discrete Mathematics Functions Suppose we have: And I ask you to describe the yellow function. Notation: f: R®R, f(x) = -(1/2)x - 25 What’s a function? f(x) = -(1/2)x - 25 domain co-domain

Upload: others

Post on 10-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 11 - CSE 240 – Logic and Discrete Mathematics

Announcements

• Homework 5 was due this morning

• Homework 6 is posted online

• Read Section 2.4 (Sequences and Summations) by Wednesday

• Quiz 4 is today

• Quiz 5 is on Wednesday

Extensible Networking Platform 22 - CSE 240 – Logic and Discrete Mathematics

Functions

Suppose we have:

And I ask you to describe the yellow function.

Notation: f: R®R, f(x) = -(1/2)x - 25

What’s a function? f(x) = -(1/2)x - 25

domain co-domain

Page 2: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 33 - CSE 240 – Logic and Discrete Mathematics

Functions

Definition: a function f : A ® B is a subset of AxB where " a Î A, $! b Î B and <a,b> Î f.

A

B

A

B

A point!

A collection of points!

Extensible Networking Platform 44 - CSE 240 – Logic and Discrete Mathematics

Functions

A = {Michael, Tito, Janet, Cindy, Bobby}B = {Katherine Jackson, Carol Brady, Mother Teresa}

Let f: A ® B be defined as f(a) = mother(a).

Michael Tito

Janet Cindy

Bobby

Katherine Jackson

Carol Brady

Mother Teresa

Page 3: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 55 - CSE 240 – Logic and Discrete Mathematics

Functions - image & preimage

For any set S Í A, image(S) = {b : $a Î S, f(a) = b}

So, image({Michael, Tito}) = ?and image(A) = ?

What about the range?

Range is all values the

function maps to.

image(S) = f(S)

Michael

Tito

Janet

Cindy

Bobby

Katherine Jackson

Carol Brady

Mother TeresaWhat about

the codomain?

Everything in B

{Katherine Jackson}

B - {Mother Teresa}

Extensible Networking Platform 66 - CSE 240 – Logic and Discrete Mathematics

Functions - image & preimage

For any S Í B, preimage(S) = {a: $b Î S, f(a) = b}

So, preimage({Carol Brady}) = ? preimage(B) = ?

preimage(S) = f-1(S)

Michael Tito

Janet Cindy

Bobby

Katherine Jackson

Carol Brady

Mother Teresa

{Cindy, Bobby}A

Page 4: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 77 - CSE 240 – Logic and Discrete Mathematics

Functions - injection

A function f: A ® B is one-to-one (injective, an injection) if "a,b,c, (f(a) = b Ù f(c) = b) ® a = c

Not one-to-one

Every b Î B has at most 1 preimage.

Michael Tito

Janet Cindy

Bobby

Katherine Jackson

Carol Brady

Mother Teresa

Extensible Networking Platform 88 - CSE 240 – Logic and Discrete Mathematics

Functions - surjection

A function f: A ® B is onto (surjective, a surjection) if "b Î B, $a Î A f(a) = b

Not onto

Every b Î B has at least 1 preimage.

Michael Tito

Janet Cindy

Bobby

Katherine Jackson

Carol Brady

Mother Teresa

Page 5: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 99 - CSE 240 – Logic and Discrete Mathematics

Functions - bijectionA function f: A ® B is bijective if it is one-to-one

and onto (also called a one-to-one correspondence).

Isaak Bri Lynette

Aidan Evan

Cinda Dee Deb Katrina Dawn

Every b Î B has exactly 1 preimage.

An important implication of this

characteristic:The preimage (f-1) is a

function!

Isaak Bri Lynette

Aidan Evan

Cinda Dee Deb Katrina Dawn

Extensible Networking Platform 1010 - CSE 240 – Logic and Discrete Mathematics

Functions - examples

Suppose f: R+ ® R+, f(x) = x2.

Is f one-to-one?Is f onto?Is f bijective?

yes

yes

yes

Page 6: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 1111 - CSE 240 – Logic and Discrete Mathematics

Functions - examples

Suppose f: R ® R+, f(x) = x2.

Is f one-to-one?Is f onto?Is f bijective?

yes

no

no

Extensible Networking Platform 1212 - CSE 240 – Logic and Discrete Mathematics

Functions - examples

Suppose f: R ® R, f(x) = x2.

Is f one-to-one?Is f onto?Is f bijective?

no

no

no

Page 7: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 1313 - CSE 240 – Logic and Discrete Mathematics

More Examples

Extensible Networking Platform 1414 - CSE 240 – Logic and Discrete Mathematics

Functions - composition

Let f:A®B, and g:B®C be functions. Then the composition of f and g is:

(g o f)(x) = g(f(x))

Page 8: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 1515 - CSE 240 – Logic and Discrete Mathematics

Functions - compositionLet f1 and f2 be functions from the set of integers to the set

of integers defined by f(x) = 2x+3 and g(x) = 3x+2

(f o g)(x) = f(g(x)) = f(3x+2) = 2(3x +2) +3 = 6x + 7

(g o f) (x) = g(f(x)) = g(2x + 3) = 3(2x+3) + 2 = 6x + 11

Extensible Networking Platform 1616 - CSE 240 – Logic and Discrete Mathematics

Sequences

Definition:A sequence {ai} is a function f: N È {0} ® R, where we write ai to

indicate f(i).

Examples:

Sequence {ai}, where ai = i is just a0 = 0, a1 = 1, a2 = 2, …

Sequence {ai}, where ai = i2 is just a0 = 0, a1 = 1, a2 = 4, …

Page 9: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 1717 - CSE 240 – Logic and Discrete Mathematics

Summation

The symbol:

Lower limiti=1

Upper limiti=k

aii=1

k

∑ = a1 + a2 + … + ak

Extensible Networking Platform 1818 - CSE 240 – Logic and Discrete Mathematics

Examples

What is the value of ?

= 12 + 22 + 32 + 42 + 52

= 1 + 4 + 9 + 16 + 25 = 55

What if we want the index to run from 0 – 4 instead of 1 – 5?

=1 + 4 + 9 + 16 + 25 = 55

å=

5

1

2

ii

åå==

+=4

0

25

1

2 )1(jiji

Page 10: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 1919 - CSE 240 – Logic and Discrete Mathematics

Summation

How do you know this is true?

cai + bi( )i=1

k

∑ = c aii=1

k

∑ + bii=1

k

• Use associativity to separate the b from the a.

• Use distributivity to factor the c.

Extensible Networking Platform 2020 - CSE 240 – Logic and Discrete Mathematics

Summations you should know…

What is S = 1 + 2 + 3 + … + n?

• You get n copies of (n+1). But we�ve over added by a factor of 2. So just divide by 2.

S = 1 + 2 + … + n

S = n + n-1 + … + 1

2s = n+1 + n+1 + … + n+1

Write the sum.

Write it again.

Add together.

kk=1

n

∑ =n(n + 1)2

Page 11: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 2121 - CSE 240 – Logic and Discrete Mathematics

Summations you should know…

What is S = 1 + 3 + 5 + … + (2n - 1)?Sum of first n odds.

(2k −1)k=1

n

∑ = 2 kk=1

n

∑ − 1k=1

n

= 2 n(n + 1)2

"

# $

%

& ' − n

= n2

Extensible Networking Platform 2222 - CSE 240 – Logic and Discrete Mathematics

Summations you should know…

What is S = 1 + 3 + 5 + … + (2n - 1)?

Sum of first n odds.

= n2

Page 12: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 2323 - CSE 240 – Logic and Discrete Mathematics

Infinite Cardinality

Two sets A and B have the same cardinality if and only if there exists a bijection (one-to-one correspondence) between them, A ~ B.

An infinite set is �countably infinite� if it can be put into �one-to-

one correspondence (bijection) � with the set

of natural numbers.

A set is “countable” if it is either finite or countably infinite.

Extensible Networking Platform 2424 - CSE 240 – Logic and Discrete Mathematics

Infinite Cardinality

• If there exists a function f from A to B that is injective (i.e. one-to-one) we say that |A| |B|

• If there exists a function f from A to B that is surjective (i.e. onto) we say that |A| |B|

£

³Why?

Why?

Page 13: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 2525 - CSE 240 – Logic and Discrete Mathematics

Set of Java programs countably infinite?

• How would I count them?

• What if I created a Java program generator– Program 1 = �a�– Program 2 = �b�– Program 3 = �c�....

• Eventually you would find programs that compile

• What if I count these programs?

Extensible Networking Platform 2626 - CSE 240 – Logic and Discrete Mathematics

Are rational numbers countable?

• How would I count them?

• What method would I use to list all of the rational numbers?

Page 14: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 2727 - CSE 240 – Logic and Discrete Mathematics

Infinite Cardinality

Are there more evens than odds?

Are there more natural numbers than evens?

Are there more evens than multiples of 3?

{0,2,4,6,8,…} ~ {1,3,5,7,9,…}, f(x) = x-1

N ~ {0,2,4,6,8,…}, f(x) = 2x

{0,2,4,6,8,…} ~ {0,3,6,9,12,…}, f(x) = 3x/2

Extensible Networking Platform 2828 - CSE 240 – Logic and Discrete Mathematics

Infinite Cardinality

How many rational numbers are there?

1/1, 1/2, 1/3, 1/4, …2/1, 2/2, 2/3, 2/4, …3/1, 3/2, 3/3, 3/4, …

1/1, 1/2, 2/1, 1/3, 2/2, 3/1, 1/4, 2/3, 3/2, 4/1, …

Page 15: cse240 lecture13 3-4-19webtodd/... · 3Extensible Networking Platform-CSE 240 –Logic and Discrete Mathematics 3 Functions Definition: a function f: A ®B is a subset of AxB where

Extensible Networking Platform 2929 - CSE 240 – Logic and Discrete Mathematics

Infinite Cardinality

How many real numbers are in interval [0, 1]?

More irrational between 0 and 1 then all rationaleverywhere

0.4 3 2 9 0 1 3 2 9 8 4 2 0 3 9 …0.8 2 5 9 9 1 3 2 7 2 5 8 9 2 5 …0.9 2 5 3 9 1 5 9 7 4 5 0 6 2 1 …

�Countably many! There�s the list!�

�Are you sure they’re all there?�

Counterexample:0.5 3 6 …

So we say the reals are �uncountable.�

Extensible Networking Platform 3030 - CSE 240 – Logic and Discrete Mathematics

Quiz 4