Presentation is loading. Please wait.

Presentation is loading. Please wait.

Relations and Functions CSRU 1100. Binary Relations A binary relation is a mapping between two sets as defined by a rule.

Similar presentations


Presentation on theme: "Relations and Functions CSRU 1100. Binary Relations A binary relation is a mapping between two sets as defined by a rule."— Presentation transcript:

1 Relations and Functions CSRU 1100

2 Binary Relations A binary relation is a mapping between two sets as defined by a rule.

3 3 Requirements for a Relation A Domain: This is the set we are going to start with.A Domain: This is the set we are going to start with. A Codomain: This is the set we are going to relate with.A Codomain: This is the set we are going to relate with. A Rule: This defines how the domain relates to the codomain.A Rule: This defines how the domain relates to the codomain.

4 Relation Example Let A={1, 2, 3, 4} be the domainLet A={1, 2, 3, 4} be the domain Let B = {10, 11, 12} be the codomainLet B = {10, 11, 12} be the codomain Let’s make the rule be all the pairs defined in: L ={(1, 10), (1, 11), (2, 10), (2, 12),Let’s make the rule be all the pairs defined in: L ={(1, 10), (1, 11), (2, 10), (2, 12), (3, 10), (4, 11)} (3, 10), (4, 11)}

5 Or we can be more concrete Domain: The set of all students at FordhamDomain: The set of all students at Fordham Codomain: The set of all Computer Science classes this fallCodomain: The set of all Computer Science classes this fall Rule: (x, y) is in the relation, if student x is enrolled in class y in the fallRule: (x, y) is in the relation, if student x is enrolled in class y in the fall

6 Some relations are special We call these special relations “functions” and you have probably met them before.We call these special relations “functions” and you have probably met them before. A function is a way of transforming one set of things (usually numbers) into another set of things (also usually numbers).A function is a way of transforming one set of things (usually numbers) into another set of things (also usually numbers).

7 4 Components of All Functions Every functions must haveEvery functions must have –A Name, typically we use a letter like f, g, or h –A Domain – a set of values, there are no constraints on these values –A Codomain – a set of values, there are no constraints on these values –A Rule

8 Terminology f : A  B This means that the function f maps values in the Set A (the domain) to the values in the Set B (the codomain)

9 Simple rules We can deal with the rules of functions the same way we dealt with relations.We can deal with the rules of functions the same way we dealt with relations. Domain: {1, 2, 3} Codomain: {5, 6, 7, 8} Rule: {(1, 5), (2, 6), (3, 8)}

10 More Advanced Rules Rules can also be written in the following styleRules can also be written in the following style –f(a) = a + 4 –g(b) = b * b + 2 –h(c) = 5 These would readThese would read –“f of a equals a plus 4” –“g of b equals b times b plus 2” –“h of c equals 5”

11 Rules continued When we see rules we often ask what their value might be when given concrete values.When we see rules we often ask what their value might be when given concrete values. Take the formula from the previous pageTake the formula from the previous page f(a) = a+4f(a) = a+4 What is its value when a equals 7?What is its value when a equals 7? Answer: 11Answer: 11

12 More Rules To abbreviate this question you might just ask what is f(7)?To abbreviate this question you might just ask what is f(7)? This means substitute the 7 for the a and solve the equation on the right hand side.This means substitute the 7 for the a and solve the equation on the right hand side. Try out the following formulas and related questions on the next slide.Try out the following formulas and related questions on the next slide.

13 Formula Problems f(x) = 2x + 3f(x) = 2x + 3 g(x) = 7g(x) = 7 What is f(5)?What is f(5)? What is f(8)?What is f(8)? What is f(-4)?What is f(-4)? What is g(3)?What is g(3)? What is g(7)?What is g(7)? What is g(-10)?What is g(-10)?

14 So what is a function really? A function is a certain way that three of the components (domain, codomain and rule) are related.A function is a certain way that three of the components (domain, codomain and rule) are related. Something is a function if (and only if) you can take every value in the Domain, put the value in the formula, and get a single value that is in the CodomainSomething is a function if (and only if) you can take every value in the Domain, put the value in the formula, and get a single value that is in the Codomain

15 Explanation Let’s look at an example.Let’s look at an example. –Suppose I define my Domain to be {1, 2, 3} –And I define my Codomain to be {5, 6, 7, 8} –And my formula is f(x) =x + 5 Is this a function?Is this a function? –To find out, we will go through each value of the domain

16 Let me try the value 1. f(1) = 1+ 5 = 6Let me try the value 1. f(1) = 1+ 5 = 6 –6 is in my Codomain. So far it’s working. Let me try the value 2. f(2) = 2 + 5 = 7Let me try the value 2. f(2) = 2 + 5 = 7 –7 is in my Codomain. It is still working. Let me try the value 3. f(3) = 3 + 5 = 8Let me try the value 3. f(3) = 3 + 5 = 8 –8 is in my Codomain. It is still working. I have tried all values in my domain, and they all worked.I have tried all values in my domain, and they all worked. Therefore, this is a function.Therefore, this is a function. Domain = {1, 2, 3} Codomain = {5, 6, 7, 8} f(x) = x + 5

17 Almost identical.Almost identical. Taking 1 from the domain worksTaking 1 from the domain works Taking 2 from the domain worksTaking 2 from the domain works Taking 3 from the domain fails.Taking 3 from the domain fails. –Why? It produces the value 8. This value is no longer part of my Codomain. So therefore this example is not a function Domain = {1, 2, 3} Codomain = {5, 6, 7} f(x) = x + 5

18 Ok, begin the same way (take values from the domain and put them in the formula)Ok, begin the same way (take values from the domain and put them in the formula) Choose 0. f(x) = 5 … it’s in the CodomainChoose 0. f(x) = 5 … it’s in the Codomain Choose 1. f(1) = 6 … it’s in the CodomainChoose 1. f(1) = 6 … it’s in the Codomain Choose -1. f(-1) = 4... it’s in the CodomainChoose -1. f(-1) = 4... it’s in the Codomain But we can’t do this foreverBut we can’t do this forever Domain = Z (all integers) Codomain = Z (all integers) f(x) = x + 5

19 Dealing with infinite sets Sometimes you can’t try all values in the domain because its infinite.Sometimes you can’t try all values in the domain because its infinite. So you need to look for values that might not work and try those.So you need to look for values that might not work and try those. If you can’t find any domain values that don’t work, can you make an argument that all the domain values do work.If you can’t find any domain values that don’t work, can you make an argument that all the domain values do work.

20 Argument:Argument: –“Regardless of what integer I take from the domain, I can add 5 to that number and still have a value in the Codomain.” Once you convince yourself of this argument than you know it is a functionOnce you convince yourself of this argument than you know it is a function Domain = Z (all integers) Codomain = Z (all integers) f(x) = x + 5

21 Ok choose some valuesOk choose some values –Choose 0: f(0) = 6 … it works –Choose 1: f(1) = 6 … it works –Choose -1: f(-1) = 6 … it works It always works… so it is a functionIt always works… so it is a function Domain = Z (all integers) Codomain = {4, 5, 6} f(x) = 6

22 Other Properties of Functions Functions can have up to two different and very interesting properties.Functions can have up to two different and very interesting properties. –A function can be onto –A function can be one-to-one In order to have one of these properties, it first must be a function. If it is not a function than these properties are irrelevantIn order to have one of these properties, it first must be a function. If it is not a function than these properties are irrelevant

23 Onto Functions An onto function is one for which “when you go through the process of determining that something is a function, you end up arriving at each and every value in the Codomain”An onto function is one for which “when you go through the process of determining that something is a function, you end up arriving at each and every value in the Codomain” Onto is a property that you observe when you are determining if something is a functionOnto is a property that you observe when you are determining if something is a function

24 Onto example If you want to know whether this is onto first you have to figure out if it is a function or not.If you want to know whether this is onto first you have to figure out if it is a function or not. Choose 1: f(1) = 11Choose 1: f(1) = 11 Choose 2: f(2) = 12Choose 2: f(2) = 12 Choose 3: f(3) = 13Choose 3: f(3) = 13 Choose 4: f(4) = 14Choose 4: f(4) = 14 It definitely is a function because every domain value took us to a value in the CodomainIt definitely is a function because every domain value took us to a value in the Codomain Is it onto?Is it onto? Yes. Because we covered all of the Codomain values in our computations.Yes. Because we covered all of the Codomain values in our computations. Domain = {1, 2, 3, 4} Codomain = {11, 12, 13, 14} f(x) = x + 10

25 Determine whether it is a functionDetermine whether it is a function Choose 1: f(1) = 0Choose 1: f(1) = 0 Choose 2: f(2) = 1Choose 2: f(2) = 1 Choose 3: f(3) = 2Choose 3: f(3) = 2 So it is a function.So it is a function. Is it onto?Is it onto? No, we never arrived at the value 3 which is in the CodomainNo, we never arrived at the value 3 which is in the Codomain Domain = {1, 2, 3,} Codomain = {0, 1, 2, 3} f(x) = x -1

26 Is it a function?Is it a function? Choose 1: f(1) = 5Choose 1: f(1) = 5 Choose 2: f(2) = 5Choose 2: f(2) = 5 Choose 3: f(3) = 5Choose 3: f(3) = 5 So it is a functionSo it is a function Is it onto?Is it onto? Yes. We reached every value in the CodomainYes. We reached every value in the Codomain Domain = {1, 2, 3,} Codomain = {5} f(x) = 5

27 One-to-One To be one-to-one something first must be a function. If it is a function, then it might be one-to-one itTo be one-to-one something first must be a function. If it is a function, then it might be one-to-one it “Each value in the Codomain that is reached can only be reached by one value in the domain”“Each value in the Codomain that is reached can only be reached by one value in the domain”

28 How does this work? We must ask if it is a function?We must ask if it is a function? Choose 1: f(1) = 2Choose 1: f(1) = 2 Choose 2: f(2) = 3Choose 2: f(2) = 3 Choose 3: f(3) = 4Choose 3: f(3) = 4 It is a function.It is a function. Is it one-to-one? WellIs it one-to-one? Well –we only reached the value 2 by using x = 1. –we only reached the value 3 by using x = 2. –we only reached the value 4 by using x = 3. So it is one-to-oneSo it is one-to-one Domain = {1, 2, 3,} Codomain = {1, 2, 3, 4} f(x) = x + 1

29 Is it a function?Is it a function? –Choose 1: f(1) = 5 –Choose 2: f(2) = 5 –Choose 3: f(3) = 5 Is it one-to-one?Is it one-to-one? –No, because we reached the value 5 in three different ways. Domain = {1, 2, 3,} Codomain = {5} f(x) = 5

30 Is it a function?Is it a function? –f(-2) = 4, f(-1) = 1, f(0) = 0, f(1) = 1, f(2)=4 So it is a functionSo it is a function Is it one-to-one?Is it one-to-one? –No. We can reach the value 4 in two ways. Domain = {-2, -1, 0, 1, 2} Codomain = {0, 1, 2, 3, 4, 5, 6} f(x) = x*x

31 Is it a function?Is it a function? Is it onto?Is it onto? Is it one-to-one?Is it one-to-one? If it has all of these properties then we call it a bijection.If it has all of these properties then we call it a bijection. Any function that is a bijection has an inverse that we can compute.Any function that is a bijection has an inverse that we can compute. Domain = {2, 4, 6, 8} Codomain = {4, 8, 12, 16} f(x) = 2x

32 What is an inverse? An inverse of a function is another function that reverses the process of the original function.An inverse of a function is another function that reverses the process of the original function. To create an inverseTo create an inverse –Make the old Codomain the new domain –Make the old domain the new Codomain –Swap the f(x) and the x in the formula –Use algebra to get the f(x) back by itself

33 Inverse Example New domain = {4, 8, 12, 16}New domain = {4, 8, 12, 16} New Codomain = {2, 4, 6, 8}New Codomain = {2, 4, 6, 8} To compute the new formula reverse the f(x) and the xTo compute the new formula reverse the f(x) and the x x = 2f(x)x = 2f(x) Then solve for f(x)Then solve for f(x) f(x) = x / 2 … so that is our inversef(x) = x / 2 … so that is our inverse Domain = {2, 4, 6, 8} Codomain = {4, 8, 12, 16} f(x) = 2x

34 Function Composition We also have the ability to put functions together – this is called compositionWe also have the ability to put functions together – this is called composition f ◦ g which reads “f compose g”f ◦ g which reads “f compose g” This means I insert the value of the function g into the function f.This means I insert the value of the function g into the function f. f(x) = x+5 g(x) = 2x + 3f(x) = x+5 g(x) = 2x + 3 The composition says put the value of g into fThe composition says put the value of g into f f(2x+3) = (2x+3) + 5 = 2x + 8f(2x+3) = (2x+3) + 5 = 2x + 8

35 What is f ◦ g ? What is g ◦ f? What is f ◦ f? What is g ◦ g ? What is f ◦ g for g(2)? Assume we have two functions with Domains and Codomains over all integers f(x) = 3x – 2 g(x) = x * x


Download ppt "Relations and Functions CSRU 1100. Binary Relations A binary relation is a mapping between two sets as defined by a rule."

Similar presentations


Ads by Google