Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 250, Discrete Structures, Fall 2013

Similar presentations


Presentation on theme: "CS 250, Discrete Structures, Fall 2013"— Presentation transcript:

1 CS 250, Discrete Structures, Fall 2013
Lecture 2.4: Functions CS 250, Discrete Structures, Fall 2013 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph Grunschlag

2 Course Admin HW1 Mid Term 1: Oct 8 (Tues)
Provided the solution soon Done with grading To be distributed today Mid Term 1: Oct 8 (Tues) Review Oct 3 (Thu) Covers Chapter 1 and Chapter 2 HW2 coming out: early next week Due Oct 15 (Tues) 2/24/2019 Lecture Functions

3 Outline Functions compositions common examples 2/24/2019
Lecture 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 2/24/2019 Lecture 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 2/24/2019 Lecture 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 2/24/2019 Lecture Functions

7 f n (x ) = f f f f  … f (x )
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 hn 2/24/2019 Lecture 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 2/24/2019 Lecture Functions

9 Composition - a little theorem
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. 2/24/2019 Lecture 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. 2/24/2019 Lecture 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.1 ? 2/24/2019 Lecture Functions

12 Today’s Reading Rosen 2.3 2/24/2019 Lecture Functions


Download ppt "CS 250, Discrete Structures, Fall 2013"

Similar presentations


Ads by Google