Document

advertisement
Lecture 2.4: Functions
CS 250, Discrete Structures, Fall 2011
Nitesh Saxena
*Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag
9/8/2011
Lecture 2.4 -- Functions
1
Course Admin

HW1




Mid-Term 1 on Thursday, Sep 22



Due at 11am 09/09/11
Please follow all instructions
Recall: late submissions will not be accepted
In-class (from 11am-12:15pm)
Will cover everything until the lecture on Sep 15
No lecture on Sep 20



As announced previously, I will be traveling to Beijing to
attend and present a paper at the Ubicomp 2012 conference
This will not affect our overall topic coverage
This will also give you more time to prepare for the exam
9/8/2011
Lecture 2.4 -- Functions
2
Course Admin

HW1 grading potentially delayed



TA/grader is sick with chicken pox
We will try to finish it up as soon as possible.
Apologies for the delay.
In any case, HW1 solution will be released in a
few days from now. So, you can prepare for your
exam without any interruptions
9/8/2011
Lecture 2.4 -- Functions
3
Outline

Functions


compositions
common examples
9/8/2011
Lecture 2.4 -- Functions
4
Function Composition
When a function f outputs elements of the same
kind that another function g takes as input, f and
g may be composed by letting g immediately take
as an input each output of f
Definition: 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))
f g is also called fog
9/8/2011
Lecture 2.4 -- Functions
5
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
9/8/2011
Lecture 2.4 -- Functions
6
Composition: Examples
1.
f : Z  R, f (x ) = x 2
and g : R  R, g (x ) = x 3
gf : Z  R , gf (x ) = x 6
2. f : Z  Z, f (x ) = x + 1
and g = f -1
gf (x ) = x (true for any function composed with its inverse)
3. f : {people}  {people},
f (x ) = g(x ) = the father of x
gf (x ) = grandfather of x from father’s side
9/8/2011
Lecture 2.4 -- Functions
7
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
n


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 hn
9/8/2011
Lecture 2.4 -- Functions
8
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
gn (x ) = x + n
A3: h (x ) = the father of x,
hn (x ) = x ’s n’th patrilineal ancestor
9/8/2011
Lecture 2.4 -- Functions
9
Composition - a little problem
Let f:AB, and g:BC be functions.
Prove that if f and g are one to one, then g o f :AC
is one to one.
Recall defn of one to one: f:A->B is 1to1 if f(a)=b and
f(c)=b  a=c.
Suppose g(f(x)) = y and g(f(w)) = y. Show that x=w.
f(x) = f(w) since g is 1 to 1.
Then x = w since f is 1 to 1.
9/8/2011
Lecture 2.4 -- Functions
10
Commonly Encountered Functions
Polynomials:
f(x) = a0xn + a1xn-1 + … + an-1x1 + anx0
Ex: f(x) = x3 - 2x2 + 15; f(x) = 2x + 3
Exponentials:
f(x) = cdx
Ex: f(x) = 310x, f(x) = ex
Logarithms:
log2 x = y, where 2y = x.
9/8/2011
Lecture 2.4 -- Functions
11
Some New functions
Ceiling:
f(x) = x the least integer y so that x  y.
Ex: 1.2 = 2; -1.2 = -1; 1 = 1
Floor:
f(x) = x the greatest integer y so that x  y.
Ex: 1.8 = 1; -1.8 = -2; -5 = -5
Quiz: what is -1.2 + 1.1 ?
9/8/2011
Lecture 2.4 -- Functions
0
12
Today’s Reading

Rosen 2.3
9/8/2011
Lecture 2.4 -- Functions
13
Download