1 / 26

MT263F Discrete Structures

MT263F Discrete Structures. Li Tak Sing ( 李德成 ). Functions. If A and B are sets and so that each element in A is associated with exactly one element in B. Such association is called a function from A to B.

liuz
Download Presentation

MT263F Discrete Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MT263F Discrete Structures Li Tak Sing (李德成)

  2. Functions • If A and B are sets and so that each element in A is associated with exactly one element in B. Such association is called a function from A to B. • If f is a function from A to B and x in A is associated with y in B under this function, we would write f(x)=y.

  3. Some function examples • f(x)=x2 • f(x)=sin(x)

  4. Graphical representation of functions

  5. Terminology • If f is a function from A to B, we denote this by writingf: A BA is the domain of f, B is the codomain of f. • If f(x)=y, then x is called an argument of f, and y is called a value of f. If the domain of f is the Cartesian product A1xA2x…xAn, then f(x1,x2,…,xn) denotes the value of at(x1,x2,..,xn).

  6. For example, f:RxRR and f(x,y)=x+y.

  7. Ranges, images, pre-images • f: A BThe range of f, denoted by range(f), is the set of elements in B that are associated with some element of A. • range(f)={f(a) | aA} • For any subset SA, the image of S under f, denoted by f(S), is the set of elements in B that are associated with some elements of S. f(S)={f(x)|xS}

  8. Pre-images • For any set TB, the pre-image of T under f, denoted by f-1(T), is the set of elements in A that associate with elements of T. • f-1(T)={aA|f(a)T}

  9. Examples • Let f:NN be defined by f(x)=x+1. Evaluate each of the following expressions: • f({0,2,4,6,8,10}) • range(f) • f-1({0}) • f-1({1,3,5,7,9})

  10. Functions and binary relations • A function can be consider as a binary relation. If f(x)=y, then x is related to y under f. So every function is a relation. Note that not all relations are functions.

  11. Equality of functions • Two functions are equal if they have the same type and the same values for each domain element. f=g iff f(x)=g(x) for all x in A.

  12. Some useful functions • The floor and ceiling functions • x=y, yZ and yx<y+1 • x=y, yZ and y<x  y

  13. Floor and ceiling properties • x+1= x+1 • x-1= x-1 • x= x iff xZ • x= x+1 iff xZ • x= x-1 iff xZ

  14. Examples • Evaluate each of the following expressions • -2.3 • 2.3 • 9.4 • -9.4

  15. Functions and Not Functions • f:RR, f(x) = square root of x. • f:R+R, f(x) = square root of x. • f:R+R+, f(x) = square root of x.

  16. Tuples are functions • Any ordered sequence of objects can be thought of as a function. • The tuple (9,4,5,2,3) can be thought of as a listing of values of the function:f:{0,1,2,3,4}->N where f(0)=9, f(1)=4, f(2)=5, f(3)=2, f(4)=3.

  17. Greatest Common Divisor • gcd(a,b)=greatest positive integers that divides a and b which are not both 0. • gcd(a,b)=gcd(b,a)=gcd(a,-b) • gcd(a,b)=gcd(b,a-bq) • if g=gcd(a,b), then there are integers x and y such that g=ax+by • If d|ab and gcd(d,a)=1, then d|b

  18. Division Algorithm • If a and b are integers and b0, then there are unique integers q and r such that a=bq+r, where 0r<|b|. • g(a,b)=g(b,a-bq)=g(b,r) • We can use the above result to find the gcd of two integers.

  19. Euclid's Algorithm • Input natural numbers a and b, not both zero, and output gcd(a,b). • while b>0 do Construct a=bq+r, where 0r<b; a:=b; b:=rod; • Output a.

  20. Finding the gcd • Evalue each of the following expressions: • gcd(235,110) • gcd(15,63)

  21. Mod function • If a and b are integers with b>0, then the remainder upon the division of a by b is denoted a mod b • a mod b = a - ba/b

  22. Mod Function Properties • x mod n = y mod n iff n divides x-y iff (x-y) mod n =0. • (x+y) mod n=((x mod n)+(y mod n)) mod n • (xy) mod n =((x mod n)(y mod n)) mod n. • If ax mod n=ay mod n and gcd(a,n)=1, then x mod n= y mod n.

  23. Evaluate each of the following expressions • 25 mod 4 • 68 mod 7 • (-16) mod 3 • (-16) mod 5

  24. The Log Function • log:R+R • logbx=y means by=x

  25. Log Function Properties • logb(bx)=x • logb(xy)=logbx+logby • logb(xy)=ylogbx • logb(x/y)=logbx-logby • logax=(logab)(logbx)

  26. Evaluate each of the following expressions • log2(1024) • log2(512) • log2(2543) • log2(49)

More Related