Understanding Functions and Relations: Concepts, Products, and Uses, Lecture notes of Computer Science

An introduction to functions and relations, explaining concepts such as functions as a set of pairs, the cartesian product of sets, and the relationship between functions and relations. It covers the definition of functions as a relation where for every x, there is a unique y, and discusses the concepts of domain, range, and mapping. The document also explores the uses of functions and relations, including depictions and applications.

Typology: Lecture notes

2012/2013

Uploaded on 04/23/2013

ashwini
ashwini 🇮🇳

4.5

(18)

167 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
which can be relations or functions
make sets of pairs
Common things one can do with sets:
Functions and relations
Friday, September 24, 201 0
2:51 PM
Functions Page 1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Understanding Functions and Relations: Concepts, Products, and Uses and more Lecture notes Computer Science in PDF only on Docsity!

which can be relations or functions make sets of pairs Common things one can do with sets: Functions and relations Friday, September 24, 2010 2:51 PM Docsity.com

You are probably used to functions such as f(x)=x 2 . For every x, there is a y, such that y=x 2 . Let's generalize this concept. Familiar and unfamiliar concepts of function Saturday, September 25, 2010 4:00 PM Docsity.com

A relation between two sets A, B is some subset of A x B. Example: A = { "Fred", "George" }, B = {"cars" ,"trucks" } A x B = { R = { ("Fred", "cars"), ("Fred", "cars"), ("George", "cars"), ("Fred", "trucks"), ("George", "trucks") ("George", "cars"), } ("George", "trucks") } Relations Friday, September 24, 2010 2:57 PM Docsity.com

E.g., interpret (x,y) as "x likes y" in the previous example. Defining the relationships between two sets of things E.g., interpret (x,y) as "x is a friend of y". Defining friends in a set of users Uses of relations: Using relations Friday, September 24, 2010 3:01 PM Docsity.com

A function is a relation in which for every x, there is a unique y such that (x,y). This can be written as: (x,y) ϵ R (x,z) ϵ R → y=z More generally: "There is a unique q such that P(q)" can be written as P(q) P( r) - > q=r Functions Friday, September 24, 2010 3:04 PM Docsity.com

domain (things that can go on the left) range (things that can go on the right) A function has a "f is a function from domain D to range R" is often notated as f: D → R This is not implication; it is mapping. For x in D, the corresponding element of R is f(x). Thus the function is a set of pairs f=(x, f(x)). Thus f is a set, and f(x) is a lookup of the pair (x,y) ϵ f Function concepts Friday, September 24, 2010 4:01 PM Docsity.com

A function can be recognized by noting that only one arrow points away from each element of the domain. Recognizing a function Friday, September 24, 2010 4:04 PM Docsity.com

one-to-one (or injective ): each value in D maps to a different value in R. onto (or surjective ): all values in R are part of some pair. one-to-one and onto (or bijective ): there is a one-to-one correspondence between all of D and all of R. partial : only some x in D have f(x) defined. A function can be Kinds of functions Friday, September 24, 2010 4:06 PM Docsity.com

Onto function Friday, September 24, 2010 4:13 PM Docsity.com

If D is a set, f(D) = { f(x) | x ϵ D}. Thus we have another equivalent definition of surjective: f:D→R is surjective ↔ f(D)=R. Functions of a set Saturday, September 25, 2010 3:42 PM Docsity.com

A bijective function f:A→B has an inverse function f

  • 1 : B→A , where f(a)=b ↔ f
  • 1 (b)=a. Inverse functions Saturday, September 25, 2010 3:37 PM Docsity.com

The composition of two functions f:D→E and g:E→F is a set g f:D→F = { (x,z) | x ϵ D z=g(f(x)) }. Composing functions Saturday, September 25, 2010 4:07 PM Docsity.com

An array is a function from integers to values. foreach $x (0,1,2,3) { $square[$x]=$x*$x; } results in @square=(0,1,4,9); An array is a function Saturday, September 25, 2010 4:12 PM Docsity.com

A hash is a function from scalars to scalars. Example: %h = ("01201" => "Harry", "05560" => "Sue", "07707" => "Mark"); domain of %h is the set {"01201", "05560", "07707"}. range of %h is the set {"Harry", "Sue", "Mark"}. Each element of the domain is a unique key. A hash is a function Saturday, September 25, 2010 4:14 PM Docsity.com