Functions Sequences, Sums, Countability: Zeph Grunschlag

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 61

Copyright Zeph Grunschlag,

2001-2002.
Functions;
Sequences, Sums, Countability
Zeph Grunschlag
L6 2
Announcements
HW 2 is due
As explained last lecture,
announcement went up over week-end
moving last 3 problems to HW3.
L6 3
Agenda
Section 1.6: Functions
Domain, co-domain, range
Image, pre-image
One-to-one, onto, bijective, inverse
Functional composition and exponentiation
Ceiling ( and floor
Section 1.7: Sequences and Sums
Sequences a
i

Summations
Countable and uncountable sets

=0 i
i
a
0

L6 4
Functions
In high-school, functions are often identified
with the formulas that define them.
EG: f (x ) = x
2

This point of view does not suffice in Discrete
Math. In discrete math, functions are not
necessarily defined over the real numbers.
EG: f (x ) = 1 if x is odd, and 0 if x is even.
So in addition to specifying the formula one
needs to define the set of elements which are
acceptable as inputs, and the set of elements
into which the function outputs.

L6 5
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 e A }.
L6 6
Functions. Basic-Terms.
EG: Let f : Z R be given by f (x ) = x
2

Q1: What are the domain and co-domain?
Q2: Whats the image of -3 ?
Q3: What are the pre-images of 3, 4?
Q4: What is the range f (Z) ?
L6 7
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 isnt 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,}
L6 13
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
L6 14
One-to-One, Onto, Bijection.
Intuitively.
Bijection means that when arrows reversed,
a function results. Equivalently, that both
one-to-oneness and ontoness occur.
BAD: not 1-to-1. Reverse
over-determined:

BAD: not onto. Reverse
under-determined:

GOOD: Bijection. Reverse
is a function:

L6 15
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 e B.
L6 16
One-to-One, Onto, Bijection.
Examples.
Q: Which of the following are 1-to-1, onto, a
bijection? If f is invertible, what is its
inverse?
1. f : Z R is given by f (x ) = x
2
2. f : Z R is given by f (x ) = 2x

3. f : R R is given by f (x ) = x
3
4. f : Z N is given by f (x ) = |x |
5. f : {people} {people} is given by
f (x ) = the father of x.
L6 17
One-to-One, Onto, Bijection.
Examples.
1. f : Z R, f (x ) = x
2
: none

2. f : Z Z, f (x ) = 2x : 1-1

3. 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
L6 18
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) )
L6 19
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
L6 20
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 fathers side
L6 21
Repeated Composition
When the domain and codomain are equal, a
function may be self composed. The
composition may be repeated as much as
desired resulting in functional
exponentiation. The whole process is
denoted by
f
n
(x ) = f -f -f -f - -f (x )
where f appears n times on the right side.
Q1: Given f : Z Z, f (x ) = x
2
find f
4
Q2: Given g : Z Z, g (x ) = x + 1 find g
n
Q3: Given h(x ) = the father of x, find h
n

n

L6 22
Repeated Composition
A1: f : Z Z, f (x ) = x
2
.
f
4
(x ) = x
(2*2*2*2)
= x
16
A2: g : Z Z, g (x ) = x + 1
g
n
(x ) = x + n

A3: h (x ) = the father of x,
h
n
(x ) = x s nth patrilineal ancestor



L6 23
Ceiling and Floor
This being a course on discrete math, it is often
useful to discretize numbers, sets and
functions. For this purpose the ceiling and
floor functions come in handy.
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(, -1.7(.
L6 24
Ceiling and Floor
A: 1.7 = 1, -1.7 = -2,
1.7( = 2, -1.7( = -1

Q: Whats the difference between the
floor function and the (int) casting
function in Java?
L6 25
Ceiling and Floor
A: Casting to int in Java always
truncates towards 0. Ceiling and floor
are not symmetric in this way.
EG: (int)(-1.7) == -1
-1.7 = -2
L6 26
Example for section 1.6
Consider the function f : R
2
R
2

defined by the formula
f (x,y ) = ( ax+by, cx+dy )
where a,b,c,d are constants. Give a
condition on the constants which
guarantees that f is one-to-one.
More detailed example
L6 27
Sequences
Sequences are a way of ordering lists of
objects. Java arrays are a type of sequence
of finite size. Usually, mathematical
sequences are infinite.
To give an ordering to arbitrary elements, one
has to start with a basic model of order. The
basic model to start with is the set
N = {0, 1, 2, 3, } of natural numbers.
For finite sets, the basic model of size n is:
n = {1, 2, 3, 4, , n-1, n }
L6 28
Sequences
DEF: Given a set S, an (infinite) sequence in S is a
function N S. A finite 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.
The book often uses the positive numbers Z
+
so
counting starts at 1 instead of 0. Ill usually assume
the ordering model N.
Q: Give the first 5 terms of the sequence defined by
the formula
)
2

cos( i a
i
=
L6 29
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,
1 , 0 , 1 , 0 , 1
4 3 2 1 0
= = = = = a a a a a
L6 30
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 well 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 youll 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

L6 31
Bit Strings
Bit strings are finite sequences of 0s and 1s.
Often there is enough pattern in the bit-string
to describe its bits by a formula.
EG: The bit-string 1111111 is described by the
formula a
i
=1, where we think of the string of
being represented by the finite sequence
a
1
a
2
a
3
a
4
a
5
a
6
a
7
Q: What sequence is defined by
a
1
=1,

a
2
=1 a
i+2
= a
i
a
i+1
L6 32
Bit Strings
A: a
0
=1,

a
1
=1 a
i+2
= a
i
a
i+1
:
1,1,0,1,1,0,1,1,0,1,


L6 33
Summations
The symbol E takes a sequence of numbers
and turns it into a sum.
Symbolically:


This is read as the sum from i =0 to i =n of a
i

Note how E converts commas into plus signs.
One can also take sums over a set of numbers:
n
n
i
i
a a a a a + + + + =

=
...
2 1 0
0

eS x
x
2
L6 34
Summations
EG: Consider the identity sequence
a
i
= i
Or listing elements: 0, 1, 2, 3, 4, 5,
The sum of the first n numbers is given
by:


(The first term 0 is dropped)

n a
n
i
i
+ + + + =

=
... 3 2 1
1
L6 35
Summation Formulas
Arithmetic
There is an explicit formula for the previous:


Intuitive reason: The smallest term is 1, the
biggest term is n so the avg. term is (n+1)/2.
There are n terms. To obtain the formula
simply multiply the average by the number of
terms.
2
) 1 (
1
+
=

=
n n
i
n
i
L6 36
Summation Formulas
Geometric
Geometric sequences are number
sequences with a fixed constant of
proportionality r between consecutive
terms. For example:
2, 6, 18, 54, 162,
Q: What is r in this case?

L6 37
Summation Formulas
2, 6, 18, 54, 162,
A: r = 3.
In general, the terms of a geometric sequence
have the form
a
i
= a r
i
where a is the 1
st
term when i starts at 0.
A geometric sum is a sum of a portion of a
geometric sequence and has the following
explicit formula:
1
...
1
2
0

= + + + + =
+
=

r
a ar
ar ar ar a ar
n
n
n
i
i
L6 38
Summation Examples
If you are curious about how one could prove
such formulas, your curiosity will soon be
satisfied as you will become adept at
proving such formulas a few lectures from
now!
Q: Use the previous formulas to evaluate each
of the following
1.


2.

=

103
20
) 3 ( 5
i
i

=
13
0
2
i
i
L6 39
Summation Examples
A:
1. Use the arithmetic sum formula and
additivity of summation:

= = = =
= =
103
20
103
20
103
20
103
20
3 5 5 ) 3 ( 5 ) 3 ( 5
i i i i
i i i
24570 84 3 5
2
) 20 103 (
84 5 =
+
=
L6 40
Summation Examples
A:
2. Apply the geometric sum formula
directly by setting a = 1 and r = 2:
16383 1 2
1 2
1 2
2
14
14
13
0
= =

= i
i
L6 41
Cardinality and Countability
Up to now cardinality has been the number of
elements in a finite sets. Really, cardinality is
a much deeper concept. Cardinality allows us
to generalize the notion of number to infinite
collections and it turns out that many type of
infinities exist.
EG:
{,}
{ , }
{ , {,{,{}}} }
These all share 2-ness.
L6 42
Cardinality and Countability
For finite sets, can just count the elements to
get cardinality. Infinite sets are harder.
First Idea: Can tell which set is bigger by
seeing if one contains the other.
{1, 2, 4} c N
{0, 2, 4, 6, 8, 10, 12, } c N
So set of even numbers ought to be smaller
than the set of natural number because of
strict containment.
Q: Any problems with this?
L6 43
Cardinality and Countability
A: Set of even numbers is obtained from N by
multiplication by 2. I.e.
{even numbers} = 2N
For finite sets, since multiplication by 2 is a
one-to-one function, the size doesnt change.
EG: {1,7,11} 2 {2,14,22}
Another problem: set of even numbers is
disjoint from set of odd numbers. Which one
is bigger?
L6 44
Cardinality and Countability
Finite Sets
DEF: Two sets A and B have the same
cardinality if theres a bijection
f : A B
For finite sets this is the same as the old
definition:
{,}

{ , }

L6 45
Cardinality and Countability
Infinite Sets
But for infinite sets
there are surprises.
DEF: If S is finite or has the same cardinality as N, S is
called countable.
Notation, the Hebrew letter Aleph is often used to
denote infinite cardinalities. Countable sets are said
to have cardinality .
Intuitively, countable sets can be counted in the sense
that if you allocate 1 second to count each member,
eventually any particular member will be counted
after a finite time period. Paradoxically, you wont be
able to count the whole set in a finite time period!
0

L6 46
Countability Examples
Q: Why are the following sets countable?
1. {0,2,4,6,8,}
2. {1,3,5,7,9,}

3. {1,3,5,7, }
4. Z
100
100
100
100
100
L6 47
Countability Examples
1. {0,2,4,6,8,}: Just set up the
bijection f (n ) = 2n
2. {1,3,5,7,9,} : Because of the
bijection f (n ) = 2n + 1
3. {1,3,5,7, } has cardinality
5 so is therefore countable
4. Z: This one is more interesting.
Continue on next page:
100
100
100
100
100
L6 48
Countability of the Integers
Lets try to set up a bijection between N and Z.
One way is to just write a sequence down
whose pattern shows that every element is
hit (onto) and none is hit twice (one-to-
one). The most common way is to
alternate back and forth between the
positives and negatives. I.e.:
0,1,-1,2,-2,3,-3,
Its possible to write an explicit formula down
for this sequence which makes it easier to
check for bijectivity:
(

+
=
2
1
) 1 (
i
a
i
i
L6 49
Demonstrating Countability.
Useful Facts
Because is the smallest kind of infinity, it
turns out that to show that a set is countable
one can either demonstrate an injection into
N or a surjection from N.
THM: Suppose A is a set. If there is an one-to-
one function f : A N, or there is an onto
function g : N A then A is countable.
The proof requires the principle of mathematical
induction, which well get to at a later date.
0

L6 50
Uncountable Sets
But R is uncountable (not countable)
Q: Why not ?
L6 51
Uncountability of R
A: This is not a trivial matter. Here are some
typical reasonings:
1. R strictly contains N so has bigger
cardinality. Whats wrong with this
argument?
2. R contains infinitely many numbers
between any two numbers. Surprisingly,
this is not a valid argument. Q has the
same property, yet is countable.
3. Many numbers in R are infinitely complex in
that they have infinite decimal expansions.
An infinite set with infinitely complex
numbers should be bigger than N.
L6 52
Uncountability of R
Last argument is the closest.
Heres the real reason: Suppose that R were
countable. In particular, any subset of R,
being smaller, would be countable also. So
the interval [0,1] would be countable. Thus
it would be possible to find a bijection from
Z
+
to [0,1] and hence list all the elements
of [0,1] in a sequence.
What would this list look like?

r
1
,

r
2
,

r
3
,

r
4
,

r
5
,

r
6
,

r
7
,
L6 53
Uncountability of R
Cantors Diabolical Diagonal
So we have this list
r
1
,

r
2
,

r
3
,

r
4
,

r
5
,

r
6
,

r
7
,
supposedly containing every real number
between 0 and 1.
Cantors diabolical diagonalization
argument will take this supposed list,
and create a number between 0 and 1
which is not on the list. This will
contradict the countability assumption
hence proving that R is not countable.
L6 54
Cantor's Diagonalization
Argument
r
1
0.
r
2
0.
r
3
0.
r
4
0.
r
5
0.
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 55
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0.
r
3
0.
r
4
0.
r
5
0.
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 56
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 1 1 1 1 1 1
r
3
0.
r
4
0.
r
5
0.
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 57
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 1 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0.
r
5
0.
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 58
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 1 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0. 7 8 9 0 6 2 3
r
5
0.
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 59
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 5 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0. 7 8 9 0 6 2 3
r
5
0. 0 1 1 0 1 0 1
r
6
0.
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 60
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 5 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0. 7 8 9 0 6 2 3
r
5
0. 0 1 1 0 1 0 1
r
6
0. 5 5 5 5 5 5 5
r
7
0.
:
r
evil
0.
Decimal expansions of r
i

L6 61
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 5 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0. 7 8 9 0 6 2 3
r
5
0. 0 1 1 0 1 0 1
r
6
0. 5 5 5 5 5 5 5
r
7
0. 7 6 7 9 5 4 4
:
r
evil
0.
Decimal expansions of r
i

L6 62
Cantor's Diagonalization
Argument
r
1
0. 1 2 3 4 5 6 7
r
2
0. 1 5 1 1 1 1 1
r
3
0. 2 5 4 2 0 9 0
r
4
0. 7 8 9 0 6 2 3
r
5
0. 0 1 1 0 1 0 1
r
6
0. 5 5 5 5 5 5 5
r
7
0. 7 6 7 9 5 4 4
:
r
evil
0. 5 4 5 5 5 4 5
Decimal expansions of r
i

L6 63
Uncountability of R
Cantors Diabolical Diagonal
GENERALIZE: To construct a number not on
the list r
evil
, let r
i,j
be the j th decimal digit
in the fractional part of r
i
.
Define the digits of r
evil
by the following rule:
The j th digit of r
evil
is 5 if r
i,j
= 5. Otherwise
the j th digit is set to be 4.
This guarantees that r
evil
is an anti-diagonal.
I.e., it does not share any elements on the
diagonal. But every number on the list
contains a diagonal element. This proves
that it cannot be on the list and contradicts
our assumption that R was countable so the
list must contain r
evil
. //QED
L6 64
Impossible Computations
Notice that the set of all bit strings is countable. Heres
how the list looks:
0,1,00,01,10,11,000,001,010,011,100,101,110,111,0000,
DEF: A decimal number
0.d
1
d
2
d
3
d
4
d
5
d
6
d
7

Is said to be computable if there is a computer program
that outputs a particular digit upon request.
EG:
1. 0.11111111
2. 0.12345678901234567890
3. 0.10110111011110.


L6 65
Impossible Computations
CLAIM: There are numbers which cannot be computed
by any computer.
Proof : It is well known that every computer program
may be represented by a bit-string (after all, this is
how its stored inside). Thus a computer program
can be thought of as a bit-string. As there are
bit-strings yet R is uncountable, there can be
no onto function from computer programs to
decimal numbers. In particular, most numbers do
not correspond to any computer program so are
incomputable!

0

L6 66
Section 1.7 Blackboard Exercises
1.7.17(d) Evaluate the double
summation:


1.7.33: Show that if A is uncountable
and B is countable then A-B is
uncountable.

= =
2
0
3
1 i j
ij

You might also like