0% found this document useful (0 votes)
158 views

Functions, Sequence and Relations

Discrete Mathematics PDF

Uploaded by

Isif Sethi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
158 views

Functions, Sequence and Relations

Discrete Mathematics PDF

Uploaded by

Isif Sethi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 43
34 32 3.3 24 as ‘36 Functions Problem-Solving Comer. Functions Sequences and Strings Relations Equivalence Relations Problem-Solving Corner: Equivalence Relations Matrices of Relations Relational Databases Notes. Chapter Review Chapter Self-Test Computer Exercises 31 Chapter 3 FUNCTIONS, SEQUENCES, AND RELATIONS A grey Huik? Finally a color | can relate to! From THe Inerepunce MUL All of mat science and engineering. make use of functions, sequence ‘A funetion assigns to each member of a vet X exactly ane member of a set ¥. Functions are used extensively in discrete mathematics; for example, functions are used to analyze the time needed to execute algorithms. A sequence is a special kind of function. A list of the letters as they appear in ‘word is an example of a sequence, Unlike a set, a sequence takes arder into account {Onier is obviously important since, for cxumple, form and from are different words.) Relugons generalize the notion of functions. A relation is a set of ordered pairs ‘The presence of the ordered pair (a, 5) in a relation is interpreted us indicating a rela tionship from a to &. The relational database model that helps users access information jn a database (u collection of records manipulated by acomputer) is based on the concept of relation , a8 well as subjects that rely on mathematics, cuch as computer and relations, Functions If we trayel fora certain amaunt of time aia constant rate, we know that if we travel $5 miles per hour for r hours, b= aay ‘where # isthe time anit 1 is the distance traveled. "This ection cam he ori withowt lows of coon 17 118 Chapter 3 Functions, Sequences, and Relations xp Definition 3.1.1 » Su eld Su eld x ¥ Figure 3.1.7. The arrow diagram fof the Function of Example 3-13 “There isexnctly one arms from, reach element in X. Cr ro x Figure 3.4.2 The armow diagram fof the-set in Example 3.1.4, which is not a function because there is sno arrow from 4, Equation (3.1.1) defines a function. \ function assigns to cach member of a set X exactly one:member ofa set ¥. (The sets X and ¥ may or may not be the sare.) The function defined by (3.1.1) assigns to each nonnegative real number # the value $51. For example, the number? = 1 is assigned the value $5; the number ¢ = 3.45 is assigned the value 189.75; and so on. We can represent these assignments as ardered pairs: (1, $5). (3.45, 189.75), Formally. we define a funetion lo be a particular kind of set of ordered pairs Let X and 9 be sets. A flection f from X to ¥ iva Subset of the Cartesian product Xo ¥ having the property thil for each x € X, there is exactly one y € F withs(x, y) © f We sometimes denote a tunection f tom X10 Yas fo X > ¥ The set X is called the domain of f anu the set ¥ is called the codomerin of f. The set lan sre £1 (whieh is a subset of the codomain ¥) i called the range af f « ‘The domuin und codomain of the function defined by (3.1.1) are both equal to the set cof all nonnegative real numbers, (We assume that time is restricted te nonnegative real numbers.) The range is alse equal (o the set of all nonnegutive real numbers, < The set Fe 1a 263,08) isa function from X = (1, 2, 3}t@¥ = [a, 6, e}, Each element of X is assigned a unique value in Y: 1 is assigned the unique value a; 2 is assigned the unique valve 4 am 3 is assigned the unique valve a, We can depict the situation as shown in Figure 3 sshere am arrow from j 4.x means that we assign the letter» to the integer J. We call a picture such as Pigure 3.4.1 an arrow diagram. Far aon arrow diagram to be a function, ‘1. Lrequines thar there is exactly one arrow fram each element thar Figure 3.1.1 has this property Definition 3.1.1 sllows us (0 reuse elements in ¥, Bore function f, the element erin ¥ is used qwice, Further, Definition 3,11 does an sequine us ta use ll the elements in ¥. No element in X is assigned to the element c in ¥. The domain uf f is X, the codomain of fis ¥, and the range of f is Ja, bh 4 he dom The set {C10}, (2.0), 03, B01 B42) a, b,c) ecause the element-4 in X is not ssigned toan elementin ¥, tis also upparent from the arrow diagram (sce Pigure 3.1.2) that this setis nota function because there fs no arrow from 4. The set (3.1.21 isa function tram X7 = (1,2, 3610 F el < Bee pt J | ¥ ¥ Figure 3.1.3. ‘The arsow diagram ofthe set in Example 31.5, which te nota function becuse theve ace two arrows from 1, SE ead ee 3.1 Functions 119 [Cah (2.03, 0,160) is mot a funetic fromm X = 41, 2, 3) 109 = fa. de) because: jyned a unique element in ¥ (1 is assigned the Valuesa net), [Lis also apparent frown the arrow diagram (See Figure 3.1.3) that this set is fot a funetion because Mere are two arrows frnen 1. Given a function Ff fram X to", according to Definition 3.1.1, for each clement x in the domain X, there is exactly one y in the codomain ¥ with (x, 9} € f. This unique ‘value y is denoted Cr}. In other words, j(r} = y is another way to write (x, 9) € f For the function fof £3, 4 The next example shows how we sometimes use the f(x) notation to define a function ‘Let be the fusetion defined by the rule fon For example, JQ) fs =1225, fo. “Although we frequently find functions defined in this way, the definition is incomplete ‘since the domain and cadomain are not specified, If we are told that the demain is the ‘set ofall real nurnhers and the codomain is the set of all nonnegative real numbers, in ‘ordered-pair notion, we would hawe J = Hx) xr areal suber] ‘The range of the set of all nonnegative real numbers, 4 ‘Most calculators have a 1's key. you enter a number and itt | key. the recipracal ‘of the number entered (or an approximation to it) is isplayed, This functian can be defined by the mule Rix) x ‘The domain is the set of all numbers that can be entered into:the calculator and whese reciprocals cun be computed and displayed by the caleulalor. The range is the set ofall the reciprocals that cin be computed and displayed. We-could define the codamain also to be the set of all the eeeipeoeals thal eas be computed and displayed. Notice that by the nature of the calculator, the domain abd eange ae Finite sets. 4 Another way to visualize a function is toxdraw its graph. The graph of a function F whose domain and.codemaia are subsets of the real numbers is obtained by plotting points in the plane-that correspond to the clemenis inf. The domain is contained in the horizontal axis and the codomain is contained in the vertical axis. 120 Chapter 3 Functions, Sequences, and Relations rer) ‘The graph of the function fx) = x7 is shown in Figure 3.1. < Aad 1 (0.0) -r-r 12 Figure 3.1.4 The graph af Figure 3.4.5 A set thatis nota pe function. The vertical line lnterseete two points in the set, ‘We note that a set § of points in the plane defines 4 function precisely when euch vertical Line intersects ak most ane point of 5, If'some vertical line contains wo or mare Points af some set, the domain point does not assign a rnigve codomain point and the set des por define a funetion (soe Figure 3.1), Funetions involving the modulus operator play an important roe in mathematics and computer science. fv isan integer and y is a positive integer. wedefine « mod y ta bethe remainder when -t is divided by y 4 Example 3.1.11 » Maing 6mod2=0, Smodl 8 mod 12 =8, 199673 mod 2 EMEP ILM) What day of the week will it be 365 days from Wednesday? Seven day's after Wednesday, itis Wodnesday again; 14 days after Wednesday, itis Wodnesday again; and in general, if is a positive integer, 7a days after Wednesday, it ts Wodnesday again. Thus we need to subtract as many 7's as possible from 36 and see how many days are left, which is the same as computing. 365 mod 7. Since 365 mod 7 = 1, 365 days from Wedneseiy, it will be one day Tater, namely Thursday. Thisexplains why, except for leap year, when an extra day is added to Febmory, the identical month and dale in consecutive years move farward one day of the week, « EE) 9) international Standard Book Numbers As of January 2007, an International Standard Book Number {ISBN} is a code of 13 characters separated hy dashes, such as 978] 59449-9501. (Before January 2007, an ISBN was 2 code of 10: characters.) An ISBN consists of five parte: currently the first part is 978, a group-code, a publisher code, a code that uniquely identifies the book among those published by the panicular publisher, and a check character. The check character is used to-validaic an ISBN. Forthe ISBN 978-1-59448-95( |, the group-code is |, which identifies the book as ‘one from an English-speaking country. The publisher code 59448 identifies the hook as ior material eee! foe 3.1 © Functions = 127 ‘one published by Riverhead Books, Penguin Group. The code 950 uniquely identifies the ‘book among those published by Riverhead Books, Penguin Group (Hosseini: A Thowsaset Splenclid Suns, in this case). Let ¢ equal the sum of the first digit plus theee times the second digit pls the third digit plus thrce-times the fouritt digit, ..., plus three times the twelfth digit, For example, the sum s for the ISBN 978-1-59448-950-1 is SONS THRE TTS HTS TAG BSG SH RO = 129, If s mod 10 = 0, the check character is O; otherwise, the check character is 10 — G mod 10), Since 12 mad 1) = 9, the check character for the ISBN 978-1-59448, 950-1 is 10-9 = 1 4 Hash Functions ‘Suppose that we have cellsinacomputer memory indexed from O10 10 (see Figure 3.1.61 ‘We wish to store and retrieve arbitrary nonnegative integers in these cells, One approach iste-use a hash fanetion, A hash function takes u data item to be stored or retrieved anc ‘computes the first choice for a location for the item, Far example, for our problem, te store or retrieve the number m, we might take as the first choice for locurion, x mod 11, ‘Our hash function becomes A(ny =m mod 1. Figure 3.1.6 shows the result of storing 15, 558, 32, 132, 102, and 5, in this order, in initially empty cells. PLL P=) l«— ob 2 8 4 § 6 7 8 9 Ww Figure [Now suppose that we want to store 257. Since h(257) = 4, 257 should be stored at location 4; however, this position is already Occupied, In this ease we say that a collision has occurred. More precisely, a collision eocurs fora hash fonction FFA Cc) = A(x), bul.x fy. To handle collisions, a collision resolution policy is required. One simple collision resolution policy is to find the next highest (with 0 assumed to follow 10) unoccupied cell. IF we use thiseollision resolution policy, we would store: 257 at location 6 (see Figure 3.1.6) ‘we want to lorate a stored value, we compute ot = A) and begin looking at location ri. If iS not at this position, we look in the next-highest position (again, 01s assumedita follow 10): iF is notin this position, we proceed to the next-highest position, and so on. If we reach an empty cell oF return ta our original position. we conclude that 1a Is not present; otherwise, we obtuin the posttion af 7 Ifeollisions occur infrequently, and if whten one-dnes eocar it is resolved quickly. ‘then hashing provides avery fast method of storing ant retrieving sata, As an example, personnel data are frequently stored anc retrieved by hashing on emplayes identification numbers, 4 Cells iv a computer memory, Pseudorandom Numbers ‘Computers are offen used to simulate random behavior, A game program might simulate rolling dice, and a clicat service program mightsiomllate the arrival of customers at abank. ‘Such programs generate numbers that appear random and arc called pseudorandom. numbers. For example, the dice-rolling program wauld niced pairs of pseuelorandom 122 Chapter 3. Functions, Sequences, and Relations Definition 3.1.16 F ampl numbers, cach between | and 6, to-simulate the waicome of rolling dice. Pscudorandam ‘numbers are: not truly random; if-one knows the program that generates the nucibers, fone could predict what numbers woald occur. ‘The method usually used ta generate pscndorandom numbers is.called the fimear ‘congruential method. This method requires fouriniegers: the maxdolus ny, the mualtiphicr cyte inerénen , ind a seed satisfying 2eecm tserm, O55 2m. ‘We then set.ag = 5, The sequence of pseudorandom numbers generated, ¥1,.F2, +. riven by the formula, a = leary) + ©) ted ex ‘The formmuls computes the next pseudorandom number using its immediate predecessor, For example, if m= 2 = faxy +b mod ma = (734 5) mod |= 4 2 = (ax) +6) mod we = (7-445) mod ‘Similar computations show that the sequence continues; Rp sea 7 tym 10, ym 8 ey te 8, ty Gt Since xje = 3, which is the value of the seed, the sequence now repeats: 3, 4,0, 5, Te Mich effort his been invested jf finding good silues Tor a linear congrie ital ‘biethod. Critical simulations stich as those iavolving aircraft ahd ivelear research require “suo random numbers. In practice. large values are sed foe rw anda. Commonly ised vals are n= 2" — 1 = 214,483, 600.0 = = V7, an c= Meh goer sequence of 2° — | integers before repeating a value Jn the 1990s, Daniel Corrivean of (Quebec won three straight garnes af a com puter keno game in Montreal, cach time choosing 19 of 20 numbers corsectly. The adds against this feat ares billion to 1. Suspicious officials at first refused to pay him. Although (Cocriveau attributed hissuecess to chaos theory, what in fact happened was that whenever power was cut, the random number generator siaried with the same seed, thus generat ing the same sequence of numbers. The embarrassed casino finally paid Comriveau the ‘$600,000 de hie, We next define the lor ans ceiling of w real murat ‘The floor of x. denoted | is the greatest integer less thna or equal tox. The ceiling of x, denoted [2], isthe least integer geeaiee than or equal to x 4 18.3) [-1131 = -11, (6) =0, 81 = 8 5. 19.17 [-87) = ‘The floor af x “rounds x down” while the ceiling of ¢ “ound x up.” We will use the floor and ceiling Functions throughou the book. 3.1 © Functions 123 EME e)) Figure 3.1.7 showsthe graphsef the floor andeviling functions. A bracket, | or |, indicates thar the point is to be included in the graph; a parenthesis, (or }, indicates that the point is be excluded from the graph, Figure 3.4.7 "The prapins of dhe tar (left prapih and ceiling (right graph) Functions, 4 SEDs) 1s 2007, the U.S. fiest-class postage rate for retail Mat mail up to 13 ounces was 80 cents forthe first ounce or fraction thereof and | ceats for each additional ounce or fraction thereof! The postage Pw) as a function of weight wis given by the equation mw) Pow) =80 FT EW O aNd ot i he expression [w —1] counts the number additianal ounces'heyond 1, witha fraction counting ss one ational ounce. As examples, en PG.) = 80+ LRT U] = 804 1772.7] = 804 17-3= 131, al PQ) = 80+ 1712-1) = 80+ 17/1] = 804 17-1 = 97, sof ph ofthe function P is shown in Figure 3.1.8 « 123 13 . ‘The Quotient-Remaindes Theorem (Theorem 2.5.6) states that if ef and a are inte» rid > Oy thene exist integers g (quatient) andr (remainder) satisfying Figure 3.1.8 The graph ofthe mens “ne Postoge functian P(w’) = Sm dgtr Osred a Dividing by ¢, we obtain soos Sime O = rfd <1 [5]=|e+S] = ‘Thus. we may compute the quotient g as [n/dfJ. Having computed the quoti ‘may compute the remainder as tg. We ran—dg ‘We previously introduced the notation m mod the remainder "The fit clss prntage ee fore tees son dilee mt: 4 cent forthe first ounce o retin Gare ad 1 coats fercach audios] oanec oe Foetion thereat up to 3:3 wane 124 EoaTrERE Chapter 3. Functions, Sequences, and Relations We have 36844 /2427 = 18,18088...; thus che qua = [e844 2427) = 15. is ‘Therefore, the reminder 36844 mod 2427 is v= Youad — 2427- We have nadytr or 3684) = 2427-154 439, < A function f from X 10 ¥ is said to be ane-ro-one (or injective) if for each y = ¥. there is at most one ¢ © X with fury = y « Because the amount of poten memory. hash functions ate ustally not One:te fost hash functions produce collisions. I data is usually’ so mich larger than the available (see Example 3.1.14). thother words, ‘The function FIO) Bart, eH) rom X = (1,2, 3} to ¥ = fa, bed) is one-ta-ooe, « ‘The function FHL a)42 Gen is not ane-to-one since 41) 13). « TX is the set of persons who have social security numbers and we assign each pe son x X his or her social security number SS(r}, we obtain a one-to-one function since distinct persons ate alway’ assigned distinet Social security aurtbers. It is beealse this correspondence is one-to-one thal the government uses social security aumbers as idemtiiers « Wa function from X wo Y is one-to-one, each element in ¥ in its arrow diagram will have at {E> one arrow pointing (0 it (see Figure 3.1.9), Ha function is not ane-to-one, some elem in ¥ in its arrow dagrary will have two-or more arrews pointing to Ht tsee Figure 3.1.10), x Yy Figure 3.1.9 The function of Example 3.1.22. This farction is ‘one-40-one because each element in ¥ Ihas al most one arnw pointing to ‘This function is notento ¥ because there is n0 aevow pointing ted f ¥ ¥ Figure 3.1.10 A funetion that is nol ane-tovane, Tas Function is not ‘one-to-one because has twoarrows ig tot. This function ts net ‘ont ¥ becavse there is no arrow ing 10 € « Example 3.1.26 > ee) 3.1 © Functions 125 ‘The candition given in Definition 3.1.21 for a function f from X to ¥ to be one-to-one is equivalent to: For all xy, x2 € 3, if flr.) = Pra), then xy = 3. In symbols, wrt foud = flea) > ‘This finn of the definition cam often be used to prove that a function is one-to-one. oh ‘Prove that the function fin) = 2041 ‘rom the set of positive integers tothe set oF positive integers is one-to-one ‘We must show that forall postive integers my and ta if fm Ay = nz. So, suppose that ft) translates as Flt) then (nz). Using the definition off. this latter equation 2) k= 2az bd ‘Subiracting | from bath sides of the equation and then d bby 2 yields jing bath sides of the equation. ‘Therefore, f is aBe-to-o0e. 4 A function (is wat one-to-one if Way ea flea) = Fe) + (xy = 20) is false of, equivalently, its negation is true. Using the generalized De Morgan's laws for logic (Theorem 1.3.14) and the fact that -ip + gi = pq (see Example 1.3.13), ‘we find that the negation is Cita aL Flay) = Foxet) > (xy = a = Sel Ford = Cra » xy =a su Beal fn) = Fe an Aural flr) = fl. tar =i Sey Brotd £000) = Flan) a Oxy # dh ‘In words, a function is not one-to-one if there exist. and xy such that f(xy) = Ses) andy # Prove that the Fonction Haya ‘from the set of positive integers to the set of integers is nor one-to-one. ‘We must find pesitive integers dts.) 3 res, such that Fl = Flay) By trial-and-ereor, we find that f= Fea. Therefure, f is not one-to-one. 4 126 Chapter 3 Functions, Sequences, and Relations Defi eee ee eee Lf x f Y Figure 3.1.11 The function of [Example 3.1.29. This finetion is ‘ane-to-ame because cach element fin ¥ has at most ome arrow: This function is onto because each element ia ¥ bras at leat one arrow pointing to i Example Era Ifthe range of a function is equal to its codemain ¥, the function is suid to be onto ¥ Ht f is a function trem X to ¥ and therunge of f is ¥, f is said ie be enzo ¥ tor an omte function oF a surjective function), « The function P12) 218 Bab from X = (1.2, 3} 00 ¥ = ta. b, ef is one-to-one and omo ¥. 4 ‘The function =H Bok (208) from X = (1,2, 3] to ¥ = fa, bed) is norento ¥ « Ifa function from X to ¥ is onto, each element in ¥ in its arvow diagram will have at least one arrow pointing to it see Figure 3.1.11). Ita function from X to ¥ is not onto, some element in ¥ in its arrow diagram will fail ta have an arrow pointing 16 it (see Figures 3.1.9 and 3.1.10), ‘The condition given in Definition 3.1.28 for a function ¥ from X to to be onto Y is equivalent to: For all y € ¥, there exists x € such that f(x) = y. fn symbols, Wy © Var € XUf(e) = 2). This form of the definition ean often he used to prove thal a Funetion is onto, Prove thal the function fares trom the set X of nonzero real numbers ta the set ¥ wf positive real numbers is ante ¥. ‘We must show that for every y € V, there exists x © X such that fe) = y Substituting the formula for /'(c), this last equation becomes Solving for x, we find rete we Notice that 1/./F is defined hecause » isa positive teal number. If we take x to be the positive square root " Definition 3. 34h Example 3.1.35 > eee 3.1 © Functions 127 them x © X. (We could just as well have taken x there exists x, namely c= EY y/F such that UVT) Thus, for every y © 1 = sie Ham SUD = eas ‘Therefore, f is onto < rif A fumetion f from X ta ¥ is ne on Vy eV are XCfE) = 9) is false ar, equivalently, its negation is true. Using the generalized De Morgan's laws for logic (Theorean 1.5.14), we find that the negation is, Aye Var e Mfx)= 9) = ave Fre X= = Bye VWre XV) = 9) Aye ¥ Wa XUF(a) #9). In words, a funes eX, S00 y. 18 f from X to ¥ is nor onto ¥ if there exists y € Y such that for all Prove that the: fone from the set X of positive pers is nor onto ¥. ‘We must find an element im © ¥ such that for all a © X. 4m) # on. Since fin) is an od integer forall n, we may-chouse for y any posikive, even inwzer, for example, 2. Then ye ¥ and fone y for all n © X.Thus fis not onte ¥. < A function that is hoth one-to-one and onto is called a bijection, 4 ‘The function f of Example 3.1.29 is a bijection. 4 AF J is a bijection from a finite set Xto-a finite set ¥, then |X| = || that is, the sets hhave the same cardinality and are the same size. For example, f= [Cha (2,5).8,0) 4d is a bijection from X = {L, 2,3, 4} 10 F = (x, b. ¢, eh]. Both sets have four elements, Ineffect. f counts the elements in ¥: ft he first clement in ¥; 42) = dis the second element in ¥; and soon, 4 ‘Suppose that J is a one-to-one, onto function from X to ¥. Team be shown (see Exercise 97) that (0 layne sh aterial 128 Chapter 3 Functions, Sequences, and Relations eta eee Example is a.ne-to-one, unto function from ¥ to X. This new function, denoted f-!, isculled inverse, For the Function F= (Ca, (2.03, A), we hine Fh = May Ui (e, 2 (8. 30. < Given the arrow diagram foranne-to-one, onte function f fram X to ¥ wean obtainthe arrow diagram for f—! simply by reversing the direction nf-each arrow (see Figure 3.1, 12, which is the arrow diagram for f—', where f is the function of Figure 3.1.11, Figure 3.1.12 The invers-of the fubction in Figure 3.1.11. The inverse is obtained by reversing all of the: arroms in Figure 3.1.01 « ‘The funetion fis? is a ane-towone function froan the set R.of all eal numbers onto the set RY ofall positive real numbers. We will derive a formula for fC Suppose that Cy. x) isin fs that ron 43) ‘Then (x.y) © ff. Thus, yer, ition of logarithrn, log, y= x aaa (Combining (3.1.3) and (3.1.4), we have fiw ‘That is, foreach » € RY, f° vb is the logarithm to the base 2of y, We can summarize the situation by siying that the imerse of the exponential function i the logarithm tunetion, 4 on: Let g be a function from X to ¥ and let f be'a function from ¥ to Z. Given x © X. we may apply g to-determine a unique clement y = gx) © ¥. We may then apply f to determine a unique element : = ty) = figixi) © Z. This compound action iscalled ‘composition. Definition 3.1.40 eet ele Example 3.1.42 > eRe ene Example 3.1.44 > 3.1 © Functions 129 Let g be a function from Xt ¥ and let f be a function from ¥ to 2, The composition af {with ¢. denoted Jo g. i the function Cfo nMr) = flgixd) from X te Z. 4 Given = (Ca), a), 6) function from X= 1, 2,3} 10 ¥ 2, b,c), and f= Ma. y).b. wh Co. 29h. function from ¥ ta Z = [x, y. 2], the composition function from X to Z isthe function hid zh. 4 Given the arrow diagram for a function g from X to Y and the arrow diagram for a funetion f° from ¥ 10 Z, we can obtain the uerow diageam for the exmposition Jf 3 simply by “following the arrows” (see Figure 3.1.13). Ly FTP <] PA ! x e r fee Figure 3.1.13 The composition of the Functions of there aie ato feo « te soxte yu a Rew If f(x) = log, x and g(x Flees) = logit fos = (log, 078 4 ‘Composition sometimes allows us to decompose complicated funetions imo simpler ‘Tanctions. For example. the function Says Vain ‘can be decompased into the fsnctions weve Aiebe Weecan then write F(x) = gthdvrt> aterial 130 Chapter 3 Functions, Sequences, and Relations Definition Sm a aaa ed ea Definition 3.1.48 & etl alee ‘This decomposition technique is important in differential calculus since there are rules tor differentiating simple functions such as g, h, and w and also rules about how to differentiate the composition of functions, Combining these rules, we can differentiate more complicated functions, « Ablnary operator on a set X associates with each ordeved pair of elements in X ‘one element ia X. A function from Xx X (0 X iscalled a binary eperaroron X. « Let X= (1.2...) Iwe define Sin yerty, where x.y © X.then f isa binary operator om X. « TEX is asetof propositions, 4,-v, 2, and <» are binary operators on X “ Aumary operator on 2 set X associatec with each single clement of " one element in X. A function from X to X is called 1 unary operator: on X. “ Let U be w universal set. If'we detine fax) =¥, wwhere N ¢ PUL, them f is a unary operatoron PUL), 4 1X isa set of propositions, ~ is a unary operator om X. < Probles ving Tips “The key to solving problems involving functions is clearly understanding the definition oF function. A function f from X to ¥ ean be thought afin many ways, Formally, f isa ‘subset of X = ¥ having the property that for every x © X. there is a unique y ¥ such that (x, ¥) € Xx F. Informally, f can be thought of asa mapping of ekements from X to Y, The arrow diagram emphasizes this view ofa function, For am arrow diagram 10 be a function, there must be exactly ane arrow tram each element in X to some element in ¥ A function isu very general concept, Any subset of A» ¥ having the property that for every x © Xy there isa umigue y € ¥ such that Gy, 5) Xx Y isa function, A function may be defined by listing its members; for example, Wa. DB, 3h (6, 28. (aD) is a fumetion feb, cd] to (1.2, 3}. Here, there is apparently no formula for inbership; the definition jost tells us which pairs make op the function (On the other hand, a Funetion may be defined by a formula, Far example, nar 2) | isa positive integer} right 3.1 © Functions = 131 defines a function from the set of pasitive integers to the set of positive integers. The “Formula” for the mapping is “add 2.” The fr) notation may be used to indicute which element in the codomain is associated with an element x in the demain or to define a function. For example, for the function f= Ma, 1). (6,36, 2, OL, ‘we comld write fla) = 1, (6) inition 1 positive imtegers, the equation sand so on, Assuming that the demain of d Ror sat defines the function (at DY mi Positive integer} ‘from the set of pasitive integers tothe set of positive integers. ‘To prove that u function J from. X to Y is one-to-one, show that for all x)..r) € X. if fled = fred, then xy = x3. ‘Toprove that a function f from X to ¥ ismorene-to-one, find x1, x2 € Xvi Xo. such that fry) = FO ‘To prove that a function f from X to ¥ is ona, show that for all exists x € X such that flr) = y ‘To-prnve thata function f from X 10 ¥ is may ont, find.» € ¥ sweb that £0) ¥, there for all x X. Bites aL 1, What ica function from X 40? Li. Define one function Give am example of an onto Function 2. fapanbonwisean aro dag decane, ___‘Ealnbow wan an ran dete hr A. What isthe graph of 15, What is a bijection? Give an example of a bijection, Explain 4. Given a set of primes in the plane, how can we ell whether it haw tose aa aero diagram ko determine whether 2 function isa function? is abijection, 5, What is the value x mod»? 16, Detine inverse fies. Give un example of a. funetion and its . laverse. Given the arrow diggram of a function, how can ee 6 Whats hash fonction Bnd the arrow diagram of the inverse function? 7 Whats culislan fora bts con? 17. Define compasiiow of ftows. How is the composition of 8. What isu collision resolution poiey? J and g denoted! Give an example of functions and g and their composition. Given the araw diagrantsof two Functions, how can we Bind the arrow diagram ofthe composition ofthe 10. Explain how a linear cangruentil randoct number generator Functions? works. und give am example of a linear congnoential andar 9. What are pseudorandarn numbers? ee 118, What is a binary operatoc? Give an example af a Binary: operat 1, What is the flage of 5 Hw isthe floae dened Jo. at a way oper? One an example fw vay 12, What isthe ceiling of x? Hew isthe ceiling dented? operat 13, Beline ome-to-ane fret. Give ae example of & ane-toroee function. Expl hea to use an atrow ehagranh to deternine shether 3 fuoetion i 08-10-68, 132 Ez ae Determine wherber each 10 fx Beerciser 13 8 fasion fn HL Rabe Y= lab cod Bi a faerie sain and range, draw is arr diageam, cl determine ‘ane-toncne, ona, or both. fit és ordsane-to-ane oad amo, give dhe g is onetp-ae. 63. IC is oato, them Jf 2g is emia, 64, Ip is0t0 then fF 6 8 is to, 68, UC Fand x are om, then fg is onto, 66, IC F and. g are-one-tn.ove ain ani, then Jf © 4 E onc-to-ane: and ont, 67, IF Fog is one-one, then fis one-tm-one, 68, UF fo g ivme-toome, thon g ix one-to-ae. 69. IC Fog isons, then F is onto, Wf tse Sanction from X 20 ¥ anuk A CX ond HG ¥, we define Fiabe (fed) eed 1a bee | Fa) BE evgose mage of umder f 2s Wha). 2.0). 8.3} be a fonction toon Seu =H3.e 267), H(B), and eTEM, fobs eval. Let (axel. Find 651, 71, Let {bea function from X ta ¥, Prove that { isone-bosone if ana only it SEAN Ms FANN (18) foe all subsets A aid of X. (When 5 18 4 set. we define FOS) = Hfoay |e ML 172, Let fea Funct fro X10 ¥. Prove that f ksne-tocome if and only If whenever @ 1s a 60e-to-cie Function from any set Aw X. fe sisaoe-1o-0n8, #72. Let f besa function from X to ¥. Prove that ffs oot ¥ iFand ‘only iFwbencver¢ isa funtion frome ¥ amnoany set ZF isco: 2, TH. Let f be a fanction fear X oato F. Let Sale yD ly er) Show dha $i a partition of Copyrighted material 134 Chapter 3 @ Functions, Sequences, and Relations Let RP denote the set of foncions fom R10 Ra We dpe the ‘valuadon funtion £,, where © R, frm Wt Eql ft fla 78. Is Ey one-to Cuar() = Cel) + Crix) forall se U gq: Xa¥ =e, the contrapositive is =p or a proot by contraction, '© For sivtements involving negation, De Morgan's Jaws can be very helpful. '® Look for definitdons and theorems relevant tote ‘expressions mentioned in the statements to be | A definition that invelves cases suggests a pro! hy cases. 3.2 + Sequences and Strings Blue ‘Taxi ic, charges St for the first mile and 50: cents for each additional mile, The {allowing (able shows the cost of traveling from 1 1a 1) les. tn general, the cust Cy of ‘raveling 1» mniles is 1.00 (che cast of teaveing the Bet miley plus 0:30 time the aumber (a= 1) of additional miles. That is, C= 14081 = 1505- +0K5— = 1405-4 Cos b+ OMe 0, 4253 Copyrighted material Be ene 3.2 @ Sequences and Strings 137 waileage Cost $1.00 130 2.00 290 3.00, a0 400 4% son 5 ‘The list of fares C= 1.00, C2= 1.50, C,=2.00, C= 250, y= 3.00, Cy = 450, Cp = 4.00, Cy=450, Cy= 5.00, Cio= 5.50 furnishes an example of 4 sequence, which is a special rype of function in which the consists of a set aif consecutive integers, Fur the sequence of fares, the domain 3.4.5.6. 7,89, 10), The mth term is typically denoted Cx. although 1 the more general function notation, it coud be tand sometimes is ‘written Cia). We gall nthe index of the sequence. A sequence named, say, «is denoted ¥ oF [ss]. Here s oF {sy} denotes the entire sequence ‘We use the now sg to denone the single element of the sequence s ‘Consider the sequence + ‘The first element of the sequence is 2, the second element of the sequence is 4, and 50 fon, The nth element of the sequence is 2n, If the frst index is I, we hive 4 a4 =6, fn = 2a. < ‘Consisier the sequence # amb a “The first element of the: sequence is a, the second element of the sequence is a, and so fon, Ifthe first inde 8 L. we Ihave hea I the: domain of the sequence is infinite (as in Example 3.2.1}, we say that the sequence is infinite. Wthe domain of the sequence is finite (as in Example 3.2.2), we state the initial index sé of an infinite sequence 5, we can write 4x43. Par example, ax infinite sequence v whese initial index Is 0 ean be denoted [,]og. A finite sequence x indexed from i to j ean For example, a sequence f whose domain is |=1,0, 1, 2,3} can be 138 Chapter 3% Functions, Sequences, and Relations SU Dee eete die) The sequence fay) devined by the rule ENE ESO) Define a sequence b by the mule by is the nih let Ha 1 ne ‘can be demoted {n}%,). The name of the index can be chosen in any conventent way, For ‘example. the sequence u ean alse be denoted faa index m is ‘This sequence is an infinite sequence. Fist terms 1, them By can be denoted [0 Hor and I by = by = BESET sve cancers the elements of. are Ro 1B, AI. BEE Deline a sequences as (a) Find sy. (b) Find sy (©) Find a formula for 5; d) Find a formula for 551 (2) Find a formula for sy-2 (1) Prove that [re] satisfies Sy = Soe 4— Oh forall = 2 (a) Replacing a by Qin definition 3.2.1, we obtain wa eas (b) Replacis (e) Replacis (d) Replacing a by — 1 in definition 3.2.1, we obiain ge The formuly fue the term having < in the word digital, I'the index of the This sequence is a finite sequence «4 B21) (322) ea Cre een See ete 3.2 ® Sequences and Strings 139 (e) Replacing n by a ~ 2 in definition 3.2.1, we obtain 0) To prove equation (3.2.2), we will replace s-1 and S42 in the right side of ‘equation (3.2.2) by the formulas of purts (and (c). We will then use algebra to show that the result is equal to sy. We obtain = 50 4) ~ 2" (522-6? $1504. 4+ the = Prtg ae pt reeves Stq-1~ Bry ‘The techniques shawn in the example will be useful in checking solutions of ecusrence relations in Chapter 7. 4 “Two imponant types of sequences are increasing sequences und decreasing: se- ‘quences, and their relatives: nonincreasing sequences arnt nondereasing sequences. A Sequence sis ineneasing if fe = Sq) forall n foe which w and + | are inthe domain cf the sequence. A sequence s is decreasing if 5. > sa.) foe all» for wich # and ‘1+ Laren the domain of the sequence. A sequence s is nondecreasing Ife = fn forall n for which w and a + | are in the domain of the sequence, (A nondecreasing sequence i like an inzreasing sequence exceps that”-<"is replaced by ~=") A sequence sis noninercasing if ty = 30.) forall for which mand a Lare inthe doreain of the sequence, (A noninereasing sequence is like a decreasing Sequence except that ">" is replaced bby “>, “The sequence 20% 18 108 300 is increasing and swndecre sing. 4 “The sequence a, fel is decreasing and nonincreasing < ‘The sequence Wo, 90, 90, 74, Th 74, 30 is monincreasing, but it is aoy decreasing < ‘The sequence 100 is increasing, decreasing, noninercasing, und nondecreasing since there is no walue of ‘for which both | and i 1 are indexes. 4 aterial 140 Chapter 3. Functions, Sequences, and Relations (One way to form a new sequence from a given sequence is to retain only certain terms of the original sequence, maintaining the order of terms in the given sequence: ‘The resulting sequence is called a subsequence of the original soquence, Let ire) be a sequence defined form = m,m-+ 1... anu beta bean increasing sequence whose values are in che set (mi,m + L....). We eall the sequence {5,,) @ subsequence of {59} < ‘The sequence be 823) is a subsequence of the sequence a heb neq a2 Subsequence (3.2.3) is obtained from sequence (3.2.4) by choosing. the third and fourth lerms. The expression 1, of Definition 3.2.11 tells us which terms af (3.2.4) 10 choose to-obtin subseqjuence (3.2.3); thus, A. The subsequence (3.2.3) is a a Notice that the sequence ab ix nos a subsequence of sequence (3.2.4) since the arder of terms in the soquence (3.2.4) is not maintained « ‘The sequence Ra 16 G25) isa subsequence of the sequence 24 6 BI I. A 16. B26) Subsequence (3.2.5) is obtained from sequence (3.2.6) by choosing the first, second. fourth. cighth. and so-on. terms: thus the value af #, of Definition 3.2.11 isa, = 2°! If we define sequence (3.2.6) by 5, = 2a, the subsequence (3.2.5) is detined by too a By ‘Twa important operutions on numerical sequences are adding and niub terms, He faz}, 8. a sequence, we define ya ‘The formalise ay Fetus Beeb a, tanta B27) See eee Example 3. See ee 3.2 ® Sequences and Strings 144 js called the um fe sigine noxation and (3.2.8) is called the product notation. 1n(3:27) 0 3.28), i iscalled the index, os calle the Yower lim, and. is called the appr tnt < Leta be the soquence defined by ay = 2a,.0 = 1. Then Son sata tae 24446212, fy -ay ay 2A 48 4 “The geometric sum par part foe par® cum be rewritten compucily using the sum notation as x 4 Wis sometimes useful to change not only the name of the index, but io change its limits as well. (The process is analogous to changing the variable in an integral in calcul ‘Changing the Index and Limits in a Sum Rewrite the sum se. lex { by J, where t= J — 1 J ethe term te" becomes (2 BrP Cj yeti & Lo when d= 0, j = 1 Thus the lower limit for j i 1. Simiarly, when ok I, ancl the upper limit for j is m+ 1, Theretiore, 1 Bue : a ‘Let a be the sequence defined by the rule a, = 2 sequence 5 defined by Ly 4 = 0 Find a formula for the 142 Chapter 3 Functions, Sequences, and Relations ec A ‘We find that fy = 2-1 + Y= + = aaasanaae| 0 « ‘Sometimesthe sum and product notation sare modified to denove sums and products indexed aver urbiteary sets of imegers. Formally, if S isa finite set of integers amd a is a sequence. De tet denotes the sum of the elements [a, | i € S]. Similarly, Te denotes the product of the elements ay | 7 € 5). Hf S denows the set of prime numbers less than 20, totic Tyrer _A.siring is a finite sequence of characters, In programming languages, strings can be used to denoie text. For example, in Java “Let's read Rolling Stone. denoies the string consisting of the sequence of characters Let's read Rolling Stone. {The double quotes * mark the start and end of the string.) im computer, fitstrings (strings-o 0's and 1s) represent data and instructions toexecute, As we will see in Section $.2, the bit string 10111] represents the mumiber47, A siring over X, where X isa fini finite sequence of elements from X. Let X = [a, bch. Uwe let hab fea th ‘we obtain a string over X, This string is written bade < Since a string is u sequence, order is taken into account. For example, the string baae is different from the sicing acab. Repetitions in a string can be specified by superscripts. For example, the string bboawe may be weitten bac ‘The siring with no elements is called the mull string and is denoted. We let X” denoie the sot of all strings over %, including the null string, and we let X* denote the sel of all nonnull strings over X. Bu eee eerree ra eee eee ee tae Z z 2 3 w u ie a v ae 3.2 ® Sequences and Strings 1 ‘Let X = a. }. Some elements in X* are A, a by abab, baba, 4 ‘The length of a string a is the oumber of elements in . The length of eis de- noted la Ie = aabarbs and f= ab4a%, then Jaj=5 and |p] = 39. 4 Ie and are two strings, the string casi called the eoneatenation of z and ing of a followed by i, written cis Iy =aab and @ = cal. then ab, 4 fy scabdaab, yao yeaah, Ay sy Let = [adhe]. If we define fla, B) = a8, ‘where a and fare strings aver then f isa binary operatoron X* < Asubstring of a string o isebtained by selecting some or all consecutive elements ‘of a. The formal definition follows. Asstring # is a substring of the string w if there are strings y and & with a = yi, 4 “The string f= ad isa substring ofthe string ot = aaaddad since. if we ake y = aa and 3-= ad, we have ce = yd, Note that iff isa substring of a. 74 the part of a that precedes (in a), ana # ts the part of that tallows ine), 4 Let X= [a, b). Mor € X* let oe® denote written in reverse, For example if = ab, a = bbe. Define a function from X* to X* as f(a) =a", Prove that f is a bijection, ‘We must show that 7 is one-to-one and onto X*. We first shove that f is one-t0- ‘one, We must show that if f(ce) = (61, then a = 8. So suppose that f(a = /«B). ‘Using the definition of #. we have a* = 1". Reversing each side, we find that u =f. ‘Therefore f is one-to-one, Nextwe show that f is onte X", Wem such that (or) = A, So-suppose that fF © X” Sta) Show that if #< X".sthere exists ¢ X" It we let w= fF%, we have BY = 8 since if we twice reverse a string, we obtain the orginal string, Therefore f is onto X™ ‘We have proved that isa bjestion 4 ‘Let X = [a, bj. Define a funetion from X* xX" to X" as fter, fl) = af. Is f one-to-one” Is f onto X" Chapter 3. Functions, Sequences, and Relations We try ta prove dat fis one-to-one, If we succeed, this part of the example is complete. Ifwve fail, we may learn haw to-construct a counterexample. So suppose that ‘Alay, Bil = flees, Bx). We haveto prove thater, = ly and ag = Bs. Using the definition off, we have aif = 2B. (Can we conclude that ay = A and a Xo! It js possible to concatenate different sirings and produce the same string, For example, baa = a, if we set ay = b and fy = aa. Also. = wf if we seta = bu and, ‘Therefore f is mnraneto-one. We could write up this part of the solution as follows. Wwe setay =, 8) = aa, a2 = ba, and fs = a, then Shoes. Bi) = baer = Fe. Be. Since ay # a3. P is not one-to-one ‘The function f isento X" ifgiven any string y € A" thereexist la, fl) © XX" such that fe, 8} = y. In words, fis onto X* iFevery string in X" is the concaicnation of twosstrings, cuch in X", Since concutenating a string a with the qull string & does not change a, every siring in X* is the concatenation of two strings, each in X. This part Cf the solution could be written up as follows. Leta € X*. Then fla A) = ar =o. Therefore f is ante K*, « Probles ving Tips A sequence is a special type of function; the domain is a set of consecutive integers. If ed}, ... 16.4 sequence, the numbers 1.2... are called indexes, Index I identifies the first clement of the sequence ay; index 2 identifies the second element of the sequence x and 0 an, In this book, “increasing sequence” means strictly increasing; that thesequence Is increasing if dy = ates for all a, We require that ay is strictly less than dy. for every m, Allowing equality yiek!s what we callin this book a “nondecreasing sequence,” ‘Thats, the sequence a 1s nondecreasing if d = cys. foram, Similarrervarks apply to decreasing sequences and noninereasing sequence’, |. Deine sequence, 10. Define string “2, What is am index in 2 sequence”? U1, Die mal A. Deline increasing seuence. 12 WX 4, Deline decreating cequence. 13. exe 5, Define nanincreaing cequence LA. Define fengah of «string. How inthe length of tbe sting a 6 Define nandler reusing sequence. Coote 15. Define conearenatton of stings. How’ is the concatenation af Sea wong mene ‘ 16. Define subrrieg 9, What is TT 3.2 ® Sequences and Strings 145 Answer I=3 for the sequences defined by eddie de 1. Find 4. A. Weite « sc astring 2 Find sy Answer 4-10 forthe sequence teed by 4. Bind 5. Find 6 Pid hws 7. Find tar & Fiod S71, 9 Find Sy 10, riod [[. wna [1 roa 3 12, Find a farvol that represents this sequence whose lower inde ist 1 sequence 1S Iss increasing? 18. [6s noninceeasing? Ise decreasing? 16, Isr nondecreasing” Answer 17-24 for the sequence defied by 1. Fd us 19. Fo 2 (sw incpeasing? 28. Is w nonincreasing* 14, Find os 2 an. Find Is a desreasing? 24. Taw nondecreasing? Answer 25-31 for the sequence weal walk ge 28, Is @ decressing? 30. Isp aooddccreasing? @ 27. bsg increasing? 29. tg nonincreasing? Aunswer 31-3 far the sequence wai nes ‘M. le increasing? 33, LF neninereasing’ 32, fer docreasiag™ 34k Isr oowsdecreasing? Aanwer 25-38 for the sequence ce 36, [67 increasing? 37. bs poniosreasingt Bt Is Y decreasing’ 34, Is nondecreasing Answer 39-50 forthe cequence a defined by 117, Kea imereasing? 4S, Tea decreasing? 49, Isccnonincreasing? 50, Tea nondecreasing? Answer SI-S8 for dhe sequence b defined by by = a1 Fi 3 4, Pind a formula for the sequence d defined by Tp 56, sb desesing? [Leb nondecreasing? Ps 58. Is bincreasing? 57. Ie nomincreasing Avs 59-66 fr the sete 9 dee By Find Yn) 61, Find a formu forthe sequence © defined by 3 feral 0, Find 379, (2, Find fort at sequenced lined IIo 63, Is 2 increasing’? 64, Is G2 decrensing? 65, Is 2 ooalncreasing? 66, Ie nondecreasing? Aviso 07-73 forthe sequence x defined by 146 Chapter 3. Functions, Sequences, and Relations ©, Pind Formula for the sequence ¢ defined by ade 11 Ia decreasing? TR Is 8 nondeceeasing? m, Is-r increasing? 72 Isr nowinereasing? Answer 7481 for the sequence w defined by tot wo=poaep mel 2 14. Find Jw. 78, Fmt So, ‘16, Finda Focal for the sequence ¢ defined by vy tno ey ole 78. Is w inerensing? - As we decreasing? ‘Is w noninereasing? 81, Ts» oo@decreusing? RE Lethe the sequence defined by HR ty Bt Mae Find a formula forthe sequence defined by we, 4= Jn i Bveciss 3-84 refer to she sequence kg} define By oe nue man wet 153, Lint dhe first seven teem oF Ansicer RASS forthe subsequence of cdvained By waking de fre, hind, terms. 153, List te frst seven lerms of the subsequence, 88, Find a formula for che expoession ny of Detiniiow 32.11 186, Find Foemula for the:kth ten ofthe subsequence, Exercises 83-00 refer to he sequence ti) dethned by tke rude ery 187, List he es seve lems ws Ansiter 85-90 forthe subsequence af abu fy tains the frst ‘second, fourth, seventh, elec. terms: 188, List he test seve rene af ue subse. 49, inn oenmla for dhe expression of Detintion 32.11. Fira Goemala for thet ten of the subsequence Answer 91-9 iting the sequences y and ¢ defied iy woeeh eat on vai(¥»)(35) . vi »)(Es) rman seman) (I) ‘aswer 98-102 for he tence by vee wee 6. Fin oft, 97, Find rz. 98, Find rs. 99, Piel torr for rp. JA, Pied a formula tor >, 192. Prove that (7.] satisfies P= Trt — Ware Answer 03H for the sequence z depined by 108, Find » forma fee azd meen, na 198, Find 20, 104, Find 29, 145, Pind 22. 106. Find <3 167, Pind a formula for), 19, Fina formal dow 22. 110, Prove that {z9| sakinfies fy yy — Mente 6, bere Gem Lye = 2 = 3m an = 5p 108, Find a formals for 24-1, uu. m2, Soe replacing the inden J by &. where & = K+ Le 113, Rewrite the sam Wentee tat replacing the inden & by ¢, where = J 4 |. 4, Leta and # be sequences, and Tet ‘ «=u. Prewe that ‘ Boosts = ratte brs) + soboat Tis equation, Koawe as the ssitmatdiny-parts foritale, isthe siscrete analog of the imegration-by-parts format in ccaleulus Copyrighted material 115, Sooietimes we generalize the acttoa of sequence as defined im this section by allowing more general indestag, Soppese ‘tun (a1 isa sequence indeed wver pairsof positive imagers, SS) £5) 116, Compute toe gives quantity using Be sings wsboah Rscmahe, y= bbeb. (ay of hi fer ©) ow «db 8B fe) |e 4) Wa) nh le (Aa Ai) a aan 8) af 4) BBya U7. Lista ssings ver M = (01) oF eng? 1a, Las all sings over X= {0,1} oF length 2 orks. 119, Liat ll cringe over X = {0,1} of feng 3. 128, List all anagsver X= 0, 1} oF Bengt 3 ores 12, Find an substrings of me sting babe, 122, Find all sobarigs the sing ach (23, Use indies to prove that Dm foe sll w= 1, where the sim ie taken overall sonempty subsets jz. -- mb OF EL...) 24, Suppose thatthe sequence (aq) sats, eam bn = Diese. 4 Gena) ford = 3, Use Linton to prove that oe ose ee TT are = Han forall = b, ie Brercives I2SADP. ay, 2. te HE 2 are wea naman onifhing Hy <.kg-< =~ Hy, amt TF am erbionnry reel aumbee: 12S, Prowe thal ify = = ra, thew . = Sos-ai= Vo eat em— a ro forall = 3. 126, Prove that tx 2 ay ore = sq then . = Sou-ale Ele at+ac-an. 7 ro ap i8 te mile Vale OF sy... 4 When w Bs odd, and any value besoreen the tts middle values (Of Ry -soety when n is even. For example, fx; <3 = xg. the medion ibe Way te ky = hein Is any valueberseen 2: and ¥9, including x2 amd 15. 3.2 © Sequences and Stings 147 Uae Execs 125 ad 126d athena oe onto pst ta ese Yen e29 21k ts minimized whee © is equal to 2 medine of 1 we repeat am experiment times and observe tbe Walues aj, ty, the stm (3-29) can be innerpreted a6 a seasure Of tse error in assusBiog that the Coen value is ‘Ths exercise shows thar this erie fs malized by thos ing.c to be-a ein of the values... 4. The requested Inductive argumeot is-atriboted ta F, Lancaster, AR, Prove hat 7 worn Eder stay = fie) = aad, boo Ut = (a te # as am aw 8 fle) = ae, Ts f one-tosone? Is ff onto 8"? Prove your sa tana Apne ep tech ta glee amaurosis cata nes Soa fine a function freer X* io the set of palindromes over X eames a a a Deine: @ fonction from X* 0X" as SF one-to-onet Is f onto 4"? Prove your ‘Let be the seal ering, lacing th nal song. io Be constricted ry xpeted applicasin ofthe flowing eas: es L then aah 6 Land nea € be fa Lond #6 H.sp g B. For evanple. ab isin L,for ifme whew = 3. theca € Lam! the Jest re states hod ab = ab & B. Similar’ bo 6 LAs anavter example, ash icia L for we make = ab, Hew © dy the Fist rule 0abb = oa € L. Ava frat example: uae ain For me woke bo thom or Lond 8 the second rule, cabo = of € L. 1 Sow that aaabie sia, NK Sow that rab isin IBM. Sher that aab is mat in B. U8. Prove that fer a has equal numbers ofa"s ands. 2136, Prove thot fe bacequal azmbercat ae ond Be them a @ ANT Let [22s be a oadecreasing aoqucnce. which iu shore, aid Ket £ Be the lest upper bound of she set Wee | 0 1,2. -.-f. Prive that for every real number «> 0, here exists 8 positive itagee N suc hal k—e = ay = forevery n = N. In caleulus eeminclogs, anondocreasing. sequence, which s howled shove, coavetzs othe Bint £, where 4 the lest upper Boel ofthe st of elenients tthe sequence. Copyrighted material 148 Chapter 3 Functions, Sequences, and Relations 33 7 Relations Definition 3.3.1 » ‘A relation from ane set to another can be thought of as. table that lists which elements ff the first set relate to which elements of the second set (see Table 3.3.1}, Table 3.3.1 shows which students are taking which courses, For example. Bill is taking Com Science and An, and Mary is taking. Mathematics, In the terminology of relations, we ‘would say that Bill is related i Computer Science and Art, and that Mary is related Mathematics, OF course, Table 3.3.1 is really just a set of ordered pai relation to be a set of urderes! pairs, In this setting, we consider the ‘ordered pair to be related to the second element ofthe adored gals Abstractly, we deine a element of the TABLE 3.3.1 m Relation of Students to Courses Student Course Bill CompSei Mary a Bill An Bel History ew CompSei Dave Mab A (binary) relation & from ar set X 10. set ¥ is a subset of the Cartesian product X x ¥. Wx. y) © R we write x Ry and suy that v is relaed aay, WX = ¥, we call Ra thinary) relation on X < A function face Section 3.1) is a special type of relation. A function f from X to Y is a relation from X ta Y having the properties: (a) The domain of fis equal to ¥. (b) Foreach x € X, there is exactly ane y € ¥ such that (x, »)€ Tee let X = (Bill, Mary, Beth, Dave} and y [CompSei, Math. Art, History} ‘oureelation R of Table 3.3.1 can be written = [CBN CompSci), (Mary, Math), (Bill, Ar), (Beth, History), (Beth, CompSci), (Dave, Math)). Since (Beth, History) < R, we may write Beth R History, < Example 3.3.2 shows that a relation can be given by simply specifying which ‘ordered pairs belong tothe elation. Qur ext example shows that sometimes tis possible to-define a relation by giving a rule for membership in the relation aterial 3.2 © Relations 149° ee X=(2.3.4) and ¥ = 13,4,5,6, 7]. If we define a relation R from X ta ¥ by Lhe Rife divides » ‘we obtain B= 12, 4,02, 61.03, 35,43, 6), (4, dab. Irwe rewrite R as a table, we ebiain puwn |e 4 6 3 6 4 4 IE tet k be the elation on X= (1,2, 3,4] defined by (x, 9) 6 Rix = yx, 7 eX. Then R (LT 22 LM DARD 4 224.6 An infaemative way co picture a relation an a sat isto deaw its digraph, (Dix s2raphs are discussed in moge detail in Chapter 8. Far now, we meation digraphs only in ‘connection with relations.) To draw the digraph of a relation on a set X, we first draw dots o¢ vertices to represent the clements of X. In Figure 3.3.1, we have drawa Four vertices to represent the elements of the set X of Example 3.3.4. New, if the element } is in the relation, we draw an arrow (called a directed edge) from « toy. In Figure 33.1, we have drawn direcied cdges to represent the members of the relation R ‘of Example 3.3.4, Notice that an element ofthe form (x, x) ina relation corresponds to. directed edge from x to. Such an edge isealled a loop. There is. a loop atevery vertex in Figure 3.3.1 ‘igure 3.3.1 The digranb af the relation of Example 334 EERE The relution Ron X = bed] given by the digeaph of Figure 3.3.2 is Re tah (bel (eh (ded : ia Figure 3.3.2 The digsaph of the relation of Example 3.3.3 < right 150 Chapter 3 Functions, Sequences, and Relations We next define several properties that relations may have. inition 3.3.6 » | Acelation Ron a set X is reflerive if (x, x) € R farevery x € X. “ ees “The relation # on X = (1,2, 3,4] defined by (x, y) € Rafx yx, y € X, isteflenive because for cach element x € X,(x,.1) € R:specifically, (1, 1), (2, 2),(3, 31, and (4,4) are each in R, The digraph of a reflexive relation has a loop al every vertex, Natice Unat the digraph of this relation (see Figure 3.3.1) has a Toop af every vertex. « By the generalized De Morgan’s laws for logic (Theorem 1.5.14), 2 elation & on AX is not reflexive if there existe.x = X such that (4,2) # R ah R= la, a), hn Ce Ble bd fon X = (ab. cd} 6 not reflexive, For example, b € X. but (b.8) € 8. That this relation is not reflexive can also be seen by looking at is digraph (see Figure 3.3.2 sertex # dacs not have & oop. 4 ‘efinition 3.3 Arelation R om a set X is synumerric if forall. x,y ¢ X.if (x,y) ¢ R,thendy, x) € R. (beter 339°] 1 on X= fa, hye issymmetric because forall, yi Cr. ¥) € Ry then Lys 0) For ‘example, (b,¢¥ isin & amd tc. b) is also in R, The digraph of a symrnetric relation has the propery that wheneverthere is a directed edge from v 10 w, there is alsa a directed edge trom w to-p, Notice that the digraph af this relation (see Figure 3.3.2) has the property that for every dinevted edge from v We ir, there is also-a directed edge from t0 1.4 R= {1a.a), 0, Ce, eG In symbols, a relation & is symmetric if vevy{le, y) € RI [yon € Rb ‘Thus R is not symmetric if [Ye rls, rhe A) [oat 81) Ba) Using the generalized De Morgan's laws for logic (Theorem 1.5.14) and the fuct that Tip + 4) = p Ama (see Example 1.3.13), we find that (3.3.1) is equivalent 0 SrBvllesy}e R)A AIC.) € Rl ‘or, equivalently, Bey llr, ¥) © RPA LOZ RI In words, arelation is oot symmnctri Ay.) is not in R there exist x and y such that (x, ») isin Rand Example 3.3.11 > Definition 3.3.12 » Example 3.3.13 » eee eee cca aie aaa) Figure 3.3.3 The digraph of the ‘of Example 3.3.15. 3.3 © Relations 151 ‘The relation Kon X = [1.2.3.4 defined by (xy) Rix < yay © X, is ‘not symmetric. For example, (2,3) € R. but (3.2) ¢ R. The digraph of this relation (see Figure 3.3.1) hus a directed edge from 2 10 3, but there is no directed edge from 3102, 4 Arelition Ran aset X is antigyrametric i forall. y € X,if(x, y)€ Rand (x0) € Re then = y 4 The relation R on X = [1.2.3.4] defined by (x,y) € Rife Z yy € Mis antisymmetric because for all x,y. x,y) € (Le, x 2 yband (uxt eR (Le. z xjthen x = y < I is sometimes moce convenient to replace if (x,y) = Rand (y.2) © Rothen x in the definition of “antisymmetric” (Definition 3.3.12) with its logically equivalent contrapesitive (see Theorem 13.18) ifn #y.thenty. 1g Roe(y x) eR to obtain a logically equivalent characterization of “umtisymmenic”: A relation & on x set X is antisymmetric if for all x, v © X,ifx # y.them(x, v) ¢ Rordy, x) R. ‘Using this equivalent definition of “antisymmewic,” we again see that the relation Ron X = [1.2.3.4] defined by (cy) ¢ Rife < y.c.9 € X, is amisymmesric because for all.x, ysife gy. Ge yh e Raita > voor(y.) ¢ >a ‘The equivalent characterization of “antisymmesric" translates for digraphs as fol- lows, The digraph of an antisymmetric reluiion has the property that between any two distinct vertices there is at most ane directed edge, Notice that the digraph of the relation A in the previous paragraph (see Figure 3.3.1) has at most one directed edge between ‘each pair af vertices, 4 I a relation has 1 members of the form (x,y), #2 y. we see that the equivalent ‘characterization of “antisymmetric” forally.y eX.itx g y.thenir. 9) ¢ Rove, nen ‘sce Example 3.3, 14) is trivially true ¢sinee the hypothesis.c # y is always fal relation R haswermembers of the form (x. 7a # ¥. Thus if inisymmetric. For example, R= [(a.a}, (0, b). te, c}) ‘on X = [a,c] is antisymmetric. The digraph of R shown im Figure 3.3.3 has at most ‘one directed edge betwcen each pair distinat vertices, Notice that Ris also reflexivecand symmetric, This example shorts that“untisymmetic™ snot the same as “not symmetric™ ‘Because this elation i in fat both symmetric and antisyrametric 4 mune if In symbols, «relation & is am Ye¥yIle, ye RAC mde Rl be 152 Chapter 3 Functions, Sequences, and Relations eee Se Ee ia ‘Thus R is not antisymmetric iF sIvaVylbe. yr Batya] R] > be = VI] (332) Using the generalized De Morgan's laws for logic (Theorem 1.$.14) and the fact that (pg) = png (see Example 13.13), we find that (3.3.2) is equivalent to Indl, 1) Rady RAL = 9) BrFpl(x, 9) € RACY) RAC FSD {ion R is nos antisymmetric if there oxi and (7.8) are both in wand year #9, sus that (x, 99 ‘The relation Rem [la,0), Oc. Oe bd did fon X = [as by eval is antisymmetric becuse bath (b,c) and te.) are in R. Notice that in the digraph of this relation (see Figure 3.3.2) there aretwo directed edges between bande, 4 Accelution R on a set X is wansitive iffor all x, y.2 2X ifCe. y1 and fe) eR The relation Aon X = (1,2. 5.4] detinedbby (x, 9) € Wife = ys oy © Nyistransitive because forall F(x, yb and (y, cb € R, then (x, 2) © R. Tos formally verify that relation satisties Definition 3.3.17, we can list all paits of pairs of the form (x, ¥) and (y, :) in R and then verify that in every case, 1x, 2) € 2 airs of Form Pair af Form Ga O21 bi) Oe) an an QD 22 an a2 (22) (23) an a3) en ea an ad (2a) a) a2) 22) 2) oa a2) 23) aa) 2) ae a2 aa a4) GB a3) G3) a) aa a a3) 64) a4) Ga) aa ag 48 aa | aa) Actually, some of the entries in the prevesting table were unnecessary. IE.x = y or iy verify thal the condition Cr, yyand Gy, 2) © Re then (1, 27 R is sutisfied since it will automatically be truc. Suppose, forexample, thal x = y-and (x, 9) and (y. 2) are im R. Ys} is im R and the condition is satisfied. right 3.3 @ Relations 153 ‘Eliminating the cases. x = y and y = z leaves only the following to be explicitly checked ‘tw verify that the relation is transitive: Pairs of Faema fat Oa (2) 3) (2) ay La) Bah 23) Gay ‘The digraph of atransitive elation asthe property thal whenever there are directed! sedges roi 10 9 ain Troe 9 ta c these is also a directed edge from x 10 z, Notice that the digraph of this relation (see Figure 3.3.1) has this propedty “4 In syurbols, «relation R is transitive if WeMsWElen YVE RA (ye2) © RIF (Or. 23 € RI. Thus & is not transitive if TWva Welln. 9) © Re) © RI U2) © AD 6.33) ‘Using the generalized Be Morgans laws for logie (Theorem 15.14} aid Ube fet that hp yg) = pny bce Exarple 1.3.03), we Me tht (3.3.3) 45 equivalent 16 BedySelts, ye Ry, 2) € RDA Mx, 2h eR) ‘or, equivalently, ArAy3c[tx, ype Roady, sh © Rex, che RI, In words, a relation Fis not wansttive'if thereesist.c, y,and such that ta, 1 and {y, 21 sare iw R, but (x, 2} is not im The telation R= {for 1b, ©), be 8), ta AD) ‘on X = (a, 6c. d] is not transitive. For example, (b, cand (¢, 4) are in R, but ib, Bis ros in, Notice that ja the digraph of tbis relation (see: Figure 3.8.29 there are directed edges from & 10 ¢ and fram «10 blot there is no directed edge from # 10 6, 4 [Relations can be used to onder elements of a set. Far example, the relation R defined on the sel of integers bey (ayeR ifxcy ‘orders the integers. Notice that the-selation R'is reflexive, antisymmetric, and transitive. ‘Such relations are called partial orders. A relation Boon a set Nis a partial ander if R is reflesive, antisymmetric, ane transitive, a 154 Chapter 3 Functions, Sequences, and Relations ee Since the relation R defined on the positive integers. by (aye R ie divides y vrder. 4 is reflesive, antisymmevric, und wansitive, Ris 8 pant 1 8 isa partial order on a set X. the notation x ~ y is sometimes used to indicate that (x, v) © R. This notation suggests that we are interpreting the relation as an ordering ‘of the elements in X ‘Suppose that R is a partial onder oma set X.Ifr. y ¢ X andeitherx = yory Ry, is the relation from X Z det by Ryo Ry = (Cn 2h 1 Cty) © Rr and Cy, 2) € Re forsome y € Y ‘Tocompute the eomposit Put(x,2)in Ro Ry nl all puis of the form (x, v) © Ay amdty, 2} © Ra Picea ed 1 What isa binary relation froen X to F 22, Whit isthe digraph of a Binary selation? |. Defioe eeflevive relation, Give an example of o eeflesive relation, Give an example ofa relaton that is fat rePexive 4. Define simmer relation, Give an example of a symmetric relation, Give an example of a relation that is sat symmetric, S. Define ertisymetricreardon. Give an example of un antisym- mettis relatiog, Give an example af a relation that is nat anti- sommeteic, tee (n Exeovives 1-4, write the relarion as a set of oniered pata 1 8D Mammer 9921 Pliers 45, Pai mT Carpet 6 Define transitive erlation, Clive anv example of a transitive relaion. Give at enarnple of a relation that isa transitive. 7. Define partial onter and give aa example ofa partial one, 1% etine imeese velation and give an example of at inverse sclatioa, Detine eanposiion of retions ane) give an example af the ‘samposition of relations, 158 Chapter 3 @ Functions, Sequences, and Relations & Sally ‘Math Rath Physics Suen eon a 2 » Un Ecconcses 5-8, wrive dhe relation ase table, SR = fer. 63.4. 3, (a. Uh fo. DP 6 A= eRe, Music} (Pat, Mistry) (en, Reh). Pat, PalySsih 11. The relation @ om 1.2.3.4) deta by (x. 9) € RIFTS y 15 Tie ren fea beset of planes tenet Ff itegers lined by (x, yh ifr iin position y foen the aun jneae- the sun ei i position 1, sed ces he sis ing in (position 2, snd se om) 4 Exersses 9-12, drow the digraplof he relation, 9. The solution of Exercise 400 (heb 10. The relation R=H1, 2012, 1008.00.02 Db ow XSL 23) Uy The relation & = 401, 21.42, 89,3, 4) FA, Dh an (1.2. A] 12, The relation of Exercise 7 In Exercises 13-16, write the relation ava sex of ondeed prs, 13, 6 ‘Find the inverse fais a set of ordered pairs) of each relacien in Exciines 116 Eveatees 18 and 1aefor tothe relaion Wo the $6012, 2,3, 4.5} cefmedd by rhe vante (x, ork Raf 3 divides x — 18, List the elements af Ft, 19. List the elements of R~! 2M, Repeat Exercises 18 ana 19 for the relation on the ast {1.2 3.4, 3) defined by the mule Cr, 9} @¢ Rife + ys 6. 21, Repeal Exersises 18 ned 19 forthe relation om the set 1162.3 4,5) defined by the rule (x, 9} 6 Rife — 1. 22. te the relation of Exercise 20 reflenive, symametti, aeviyen: netic. musts, ar a pata onder? Is the relaiion of Exercise 21 reflesive, symmetric, anlisym- metic, wanstve, ancora alone? fn Exercises 24-24 determine whether cach sate defined én the ser of positive insegors is reflexive, symmetric, amrigymmerric, tronslve, andor a para ander MinyeRifres: aS Hye RIES y Minvle Riles, BOs Rites =v. DAL tc. ye RIT divides = y 29, tr, 91 © RIF divides #428, Woke ye Rie ped MW (aye Riley) 2 3X LeL.X be a nonempty set. Define arelatica.on PUN). the power sola X,20(4, AVG Rif AS B. fs Bisselation reflexive, sy: matric, ntisymenetie, eancitive, andra paral er? 3B, Prov laa relation R oma set X i ainymmekic aad oly for alla, ye X40(a, 9) © 8 andr = 9, then Cy Fe R. 34. Let X beth set of all ourbit sings en, 0011, 0101, 1000). Define a relation & on X as 4 33H some substring of s of tengib 2 is equal 1 some substring of 92 of length 2, F:xam- ples: O11 R NGI (because both 1111 snd {010 caoiain 01), 110 8 G01 -ecause F1-anel OE dno share a cone substring of Hength 2), ls this relation reflexive, symmetric, snfsy mimetic, transite, anda partial onder? Suppose that Ri 4 partial one oa Ni, 4 = 1,2, Show tha Risa partial arderon Xy = Xs if we define Kerra) R era) xy Ry | andl Re ‘6 Let Ry sad Rye the eats on 12,3, 4) gisba by D..410420 (2,1), 03, 1), aob ob, 02, 2a. List he cleentse By o Rad Bo Ry Give exampler of refatiows ow {1.2.3.4} having Je properties “specified in Exercies TP 37, Retlecive, symmetric. and not wapsitse: ‘34, Redleuive, not symouctric, and nos transitive 9. Reflexive, ntisysometti, aod 90 transitive Copyrighted material “40, Noc reflexive, symimetcie, nor antisymmetric, and transitive 41, Not refleive, sot symomenesc, al Wansitive Let R and S be relarionson X. Determine whether-each starement in Exercises 42-4 ds em or fave, [fake stosement is trwe, pve ay onheraise; give a cavareresanipte, 42. FR jewransitive, them R-! is tansitve, WF R and S ure eflexive.then RU Sis reflerive. VER and § are reflenive, then RY Sis reflexive. Rand § are reflexive. then Ro $ is reflexive TER issefiexive then 16 and § are symmetric, then WU S issymamesric. WER sod § ure symmetric, then RS icxymametric. WR aod § ure sprnmnetric. then Ro Sis syemnelee 8 iesymmenric, ten RW! is symmette. HER aod $ are anisymipecte, then WLS is untisymmeric. Hf aod § are antisymmetric, then #77 S fs antisymmetric. inrellenive. Beesear age 3.4 © Equivalence Relations 159° 53. 18 and S are ancsyenonetsic, then Ko Sts uncnyanmesre. 54. ICR is aispmimetic. then A! is amisymnmetsic 58, How many relathons are thereon an n-eleroent set? 4h Buercisey 56-58. determine whenher each retaiow defined ow he collection ofall ponennpy subsets of rea mares ds rere Symmetric, arisymumerric, anmasive, conkior a parti onder 56. (A. B)-e Rif focevery © > M.shereexisisaé Aand be B with a — Bh 8, ST. (AB) € Rifforevery a ¢ dandy = 0, there exists be with ja = By 58. (A.B) 6 Rifforevery a €.A.h-6 Band > O, there exists a’ € Aan B with le — | < ean fa! — Bf < 59, Whats wrode With the folowing argue. whichsupposedly shor ast anyretation & on. thats symmetric und rast isrefecive™ Let X. Using symmetry, We have (4,9 al (9 8) bot in. Sinoe (x, yh ye) © A by Wransviy we have (xx) ¢ Therefore, i isrellerive. 3.4 > Equivalence Relations ‘Suppose thut we have a set X of 10 bulls, each of which is either red, blue, or green (see Figure 3.4.1), If we divide the balls into sets R. Band G according to color, the furily LR, B, G) isa panition of X. (Recall that in Section 1,1, we defined a panttion of a set & X tobe a collection $ of nonempty subsets of X such that every clement in X belongs to exactly one member of 8.) A partition can be used 1o define a relation, 1S isa partion of X, we may define 2 Ry to mean that for some set SS, both x and y belong 19 5. For the example of ‘Figure 3.1, the relation obisined could be described ass the same colar a” The next theorem shows that such 1 elation is always reflexive, symmetric, ad tansitve eoooe Ooo000 Figure 3.4.1 A set of colored balls Theorem 3.4.1 Copyrighted material

You might also like