CSRU 1100 Relations and Functions Binary Relations A
CSRU 1100 Relations and Functions
Binary Relations A binary relation is a mapping between two sets as defined by a rule.
3 Requirements for a Relation • 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 Rule: This defines how the domain relates to the codomain.
Relation Example • Let A={1, 2, 3, 4} be the domain • Let 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), (3, 10), (4, 11)}
Or we can be more concrete • Domain: The set of all students at Fordham • Codomain: 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 fall
Some relations are special • 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).
4 Components of All Functions • Every 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
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)
Simple rules • 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)}
More Advanced Rules • Rules can also be written in the following style – f(a) = a + 4 – g(b) = b * b + 2 – h(c) = 5 • These would read – “f of a equals a plus 4” – “g of b equals b times b plus 2” – “h of c equals 5”
Rules continued • When we see rules we often ask what their value might be when given concrete values. • Take the formula from the previous page • f(a) = a+4 • What is its value when a equals 7? • Answer: 11
More Rules • 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. • Try out the following formulas and related questions on the next slide.
Formula Problems • f(x) = 2 x + 3 • g(x) = 7 • What is f(5)? • What is f(8)? • What is f(-4)? • What is g(3)? • What is g(7)? • What is g(-10)?
So what is a function really? • 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 Codomain
Explanation • 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? – To find out, we will go through each value of the domain
Domain = {1, 2, 3} Codomain = {5, 6, 7, 8} f(x) = x + 5 • Let 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 = 7 – 7 is in my Codomain. It is still working. • Let 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. • Therefore, this is a function.
Domain = {1, 2, 3} Codomain = {5, 6, 7} f(x) = x + 5 • • Almost identical. Taking 1 from the domain works Taking 2 from the domain works 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 = Z (all integers) Codomain = Z (all integers) f(x) = x + 5 • 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 Codomain • Choose 1. f(1) = 6 … it’s in the Codomain • Choose -1. f(-1) = 4. . . it’s in the Codomain • But we can’t do this forever
Dealing with infinite sets • 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. • If you can’t find any domain values that don’t work, can you make an argument that all the domain values do work.
Domain = Z (all integers) Codomain = Z (all integers) f(x) = x + 5 • 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 function
Domain = Z (all integers) Codomain = {4, 5, 6} f(x) = 6 • Ok 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 function
Other Properties of Functions • 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 irrelevant
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” • Onto is a property that you observe when you are determining if something is a function
Onto example Domain = {1, 2, 3, 4} Codomain = {11, 12, 13, 14} f(x) = x + 10 • 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) = 11 • Choose 2: f(2) = 12 • Choose 3: f(3) = 13 • Choose 4: f(4) = 14 • It definitely is a function because every domain value took us to a value in the Codomain • Is it onto? • Yes. Because we covered all of the Codomain values in our computations.
Domain = {1, 2, 3, } Codomain = {0, 1, 2, 3} f(x) = x -1 • • Determine whether it is a function Choose 1: f(1) = 0 Choose 2: f(2) = 1 Choose 3: f(3) = 2 So it is a function. Is it onto? No, we never arrived at the value 3 which is in the Codomain
Domain = {1, 2, 3, } Codomain = {5} f(x) = 5 • • Is it a function? Choose 1: f(1) = 5 Choose 2: f(2) = 5 Choose 3: f(3) = 5 So it is a function Is it onto? Yes. We reached every value in the Codomain
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 it • “Each value in the Codomain that is reached can only be reached by one value in the domain”
How does this work? Domain = {1, 2, 3, } Codomain = {1, 2, 3, 4} f(x) = x + 1 • • • We must ask if it is a function? Choose 1: f(1) = 2 Choose 2: f(2) = 3 Choose 3: f(3) = 4 It is a function. Is 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-one
Domain = {1, 2, 3, } Codomain = {5} f(x) = 5 • Is it a function? – Choose 1: f(1) = 5 – Choose 2: f(2) = 5 – Choose 3: f(3) = 5 • Is it one-to-one? – No, because we reached the value 5 in three different ways.
Domain = {-2, -1, 0, 1, 2} Codomain = {0, 1, 2, 3, 4, 5, 6} f(x) = x*x • Is it a function? – f(-2) = 4, f(-1) = 1, f(0) = 0, f(1) = 1, f(2)=4 • So it is a function • Is it one-to-one? – No. We can reach the value 4 in two ways.
Domain = {2, 4, 6, 8} Codomain = {4, 8, 12, 16} f(x) = 2 x • • Is it a function? Is it onto? Is it one-to-one? 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.
What is an inverse? • An inverse of a function is another function that reverses the process of the original function. • To 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
Inverse Example Domain = {2, 4, 6, 8} Codomain = {4, 8, 12, 16} f(x) = 2 x • • • New domain = {4, 8, 12, 16} New Codomain = {2, 4, 6, 8} To compute the new formula reverse the f(x) and the x • x = 2 f(x) • Then solve for f(x) • f(x) = x / 2 … so that is our inverse
Function Composition • We also have the ability to put functions together – this is called composition • f ◦ g which reads “f compose g” • This means I insert the value of the function g into the function f. • f(x) = x+5 g(x) = 2 x + 3 • The composition says put the value of g into f • f(2 x+3) = (2 x+3) + 5 = 2 x + 8
Assume we have two functions with Domains and Codomains over all integers f(x) = 3 x – 2 g(x) = x * x What is f ◦ g ? What is g ◦ f? What is f ◦ f? What is g ◦ g ? What is f ◦ g for g(2)?
- Slides: 35