UC Davis, ECS20, Winter 2017 Discrete Mathematics for Computer Science Prof. Raissa D Souza (slides adopted from Michael Frank and Haluk Bingöl) Lecture 8 Functions and Sequences Rosen, Secs. 2.3, 2.4
Function: Formal DeOinition Def. For any sets A, B, we say that a func'on f (or mapping ) from A to B is a par3cular assignment of exactly one element f(x) B to each element x A. We can write f:a B For a A and b B, we can evaluate f(a)=b.
Important Function Terminology Def. Let f:a B, and f(a)=b (where a A & b B). Then A is the domain of f. B is the codomain of f. b is the image of a under f. a is a pre-image of b under f. In general, b may have more than 1 pre-image. The range R B of f is R={b a f(a)=b }.
Graphical Representations Func3ons can be represented graphically in several ways: f a b A B Like Venn diagrams f A B Bipartite Graph y (This has f:r -> R) x Plot Note: EVERY element of set A has to be mapped to ONE (and only one) element in B.
One-to-One or Injective functions Bipar3te (2-part) graph representa3ons of func3ons that are (or are not) one-to-one: One-to-one Not one-to-one ( Many-to-one instead) Not a function! Note domain codomain for 1-to-1
Onto or surjective functions Some func3ons that are, or are not, onto their codomains: Onto (but not 1-1) Not Onto (or 1-1) Both 1-1 and onto 1-1 but not onto Note domain codomain for onto
1-1 and onto = bijection/invertible Some func3ons that are, or are not, onto their codomains: Onto (but not 1-1) Not Onto (or 1-1) Both 1-1 and onto 1-1 but not onto
Bijections Def. A func3on f is said to be a bijec'on, (or a one-to-one correspondence, or reversible, or inver'ble,) iff it is both one-to-one and onto. Def. For bijec3ons f:a B, there exists an inverse of f, wriqen f -1 :B A, which is the unique func3on such that (where I A is the iden3ty func3on on A) Both 1-1 and onto f 1! f = I A Domain = Codomain = Range We can invert the function!!
Graphs of Functions We can represent a func3on f:a B as a set of ordered pairs {(a,f(a)) a A}. Note that a, there is only 1 pair (a,b). Later (ch.6): rela'ons loosen this restric3on. For func3ons over numbers, we can represent an ordered pair (x,y) as a point on a plane. A func3on is then drawn as a curve (set of points), with only one y for each x.
A Couple of Key Functions In discrete math, we will frequently use the following two func3ons over real numbers: Def. The floor func3on :R Z, where x ( floor of x ) means the largest (most posi3ve) integer x. Formally, x : max({ j Z j x}). Def. The ceiling func3on :R Z, where x ( ceiling of x ) means the smallest (most nega3ve) integer x. Formally, x : min({ j Z j x})
Visualizing Floor & Ceiling Real numbers fall to their floor or rise to their ceiling. Note that if x Z, -x - x & -x - x Note that if x Z, x = x = x. 3 2 1 0-1 -2-3 1.6-1.4... -3..... 1.6 =2 1.6 =1-1.4 = -1. -1.4 = -2-3 = -3 = -3
Plots with Oloor/ceiling: Example Plot of graph of func3on f(x) = x/3 : f(x) Set of points (x, f(x)) +2-3 -2 +3 x Note, the open dot denotes that in the limit the point is not on the curve, and the closed dot means it is on the curve.
Operators (general deoinition) Def. An n-ary operator over (or on) the set S is any func3on from the set of ordered n- tuples of elements of S, to S itself. Ex. If S={T,F}, can be seen as a unary operator, and, are binary operators on S. Ex. and are binary operators on the set of all sets. (See HW3 with i k nota3on)
Combining Function Operators +, ( plus, 3mes ) are binary operators over R. (Normal addi3on & mul3plica3on.) Therefore, we can also add and mul3ply func'ons Def. Let f, g: R R. (f + g): R R, where (f + g)(x) = f(x) + g(x) (f g): R R, where (f g)(x) = f(x) g(x)
Function Composition Operator Def. Let g:a B and f:b C. The composi'on of f and g, denoted by f g, is defined by (f g)=f(g(a)). A g B f C a g(a) f(g(a)) Remark. (like Cartesian, but unlike +,, ) is non-commu3ng. (Generally, f g g f.)
Review of 2.3 (Functions) Func3on variables f, g, h, Nota3ons: f:a B, f(a), f(a). Terms: image, preimage, domain, codomain, range, one-to-one, onto, strictly (in/de)creasing, bijec3ve, inverse, composi3on. Func3on unary operator f -1, binary operators +, -, etc., and. The R Z func3ons x and x.
2.4: Sequences, Strings, & Summations A sequence or series is just like an ordered n- tuple, except: Each element in the series has an associated index number. E.g., (a 1,a 2,, a k ) A sequence or series may be infinite. A string is a sequence of symbols from some finite alphabet. (e.g., words in a language) A summa'on is a compact nota3on for the sum of all terms in a (possibly infinite) series. k i : a j + a j + + 1... i= j a + a k
Sequences Def. A sequence or series {a n } is iden3fied with a genera'ng func'on f:s A for some subset S N and for some set A. Oien we have S= N or S=Z + = N -{0}.
Recognizing Sequences Some3mes, you re given the first few terms of a sequence and you need to find the sequence s genera3ng func3on, which is a procedure to enumerate the sequence. Examples: What s the next number? 1,2,3,4, 1,3,5,7,9, 2,3,5,7,11,... 5 (the 5th smallest number >0) 11 (the 6th smallest odd number >0) 13 (the 6th smallest prime number)
Sequence elements, a n Def. If f is a generating function for a series {a n }, then for n S, the symbol a n denotes f(n), also called term n of the sequence. The index of a n is n. (Or, often i is used.) A series is sometimes denoted by listing its first and/or last few elements, and using ellipsis ( ) notation. E.g., {a n } = 0, 1, 4, 9, 16, 25, is taken to mean n N, a n = n 2.
Sequence Examples Some authors write the sequence a 1, a 2, instead of {a n }, to ensure that the set of indices is clear. Be careful: oien nota3on leaves the indices ambiguous, but context makes it clear. Ex. An example of an infinite series: Consider the series {a n } = a 1, a 2,, where ( n 1) a n = f(n) = 1/n. Then, we have {a n } = 1, 1/2, 1/3,
Switch to blackboard mode