 Hello, and welcome to the screencast where we're going to focus on a different property of functions that has a lot of importance in understanding how functions work. We've previously looked at the property of injectivity. We say that a function is injective if it has no collisions. That means if every pair of distinct elements in the domain must map to a pair of distinct elements in the co-domain. Injectivity is a property that involves starting with something in the domain, namely a pair of distinct points, and then deciding something about the co-domain that is whether that pair collides or not. The property we're going to look at now takes things from the opposite point of view by starting in the co-domain and then determining information about the domain. So to set this up, let's look at two examples from earlier videos. The first example is the round function, and remember this maps the real numbers into the integers by accepting a real number as input and then producing the next higher integer as output. For example, round of 2.6 is 3. This is clearly not an injection as we've seen earlier because, for example, round of 2.6 and 2.2 round of the same thing. But let's look at it from the co-domain point of view. Namely, if I start with a point in the co-domain, can I always find at least one point in the domain that maps to it? Let's see if that's the case here by playing with some examples. Let's pick a random integer from the co-domain, let's say 17. Again, this is in the co-domain. Is there a point in the real numbers that maps to 17? Well, sure, for example, 16.9 does or 16.5 or just the number 17 itself, and this is not because 17 is anything special. If I choose any point, let's say y in the co-domain, that's an integer, then I know I can construct a point in the domain that maps to it. For example, I could use y itself or y minus 0.1 if you like. So every point in the co-domain of this function has at least one element in the domain that maps to it. Said differently, every point in the co-domain is actually an output of this function. Or another way, the co-domain of this function is equal to the range of this function. Every point that can be hit by the function actually is hit by the function. So since every point in the co-domain is actually hit by the function, we might call this the everything's covered property because no point in the co-domain is left quote unquote uncovered by the function. Here's a different example. The function that maps the set of all GVSU students and staff to the set of eight digit integer strings by mapping a person to his or her ID number. We call those G numbers around here. We've seen previously that this is a function because no single person has two different ID numbers, so there's no splitting. And we've also seen that this is an injection because given two different people, they will map to two different G numbers. So does this function have this so called everything's covered property? I think the answer is no. Think about it. There are 100 million eight digit strings available in the co-domain of this function. GVSU has around 25,000 students and a few more faculty and staff. So unless there are some people with many different G numbers, which is not possible, not all of those G numbers are going to have corresponding people attached to them. There are some numbers in other words that are going to be uncovered. They will not appear as outputs of this function. In fact, I believe the process for generating G numbers forces the first three digits to be zero, one, zero. And if that's true, then nobody can possibly have a G number that starts with say 999. So some functions have this everything's covered property and some don't. And it seems like whether the entire co-domain is covered by a function is important, so we're going to give this a name. We say that a function f from a to b is a surjection if the range of f equals the co-domain of f. This means that for every y and b, the co-domain, there exists an x and a, the domain, such that f of x equals y. Sometimes we say a surjective function is on to or that it maps a on to b. The word surjective is formed from the French preposition sur, which basically means on to like a surcharge or a surname. And injective means basically to throw. So a surjective function literally throws the domain on to the co-domain and covers it all. Let's look at three more examples of surjectivity because it's a slightly more subtle idea than injectivity. And then we'll end with a concept check. First, let's look at the function that maps the set of all 2 by 2 matrices with real number entries on to the real numbers by mapping a matrix to its determinant. And remember, the determinant of a 2 by 2 matrix is calculated by this formula here. And for example, the determinant of the matrix 3401 is equal to 3. This is a surjective function because every point in the co-domain has at least one matrix that maps to it. For example, if you chose the number squared of 2 from the co-domain, the one matrix that maps to it is the matrix squared of 2, 0, 0, 1. There are a lot more matrices that map to this number 2, of course. For example, 1, 0, 0, squared of 2. But the point is that there is at least one matrix that does actually hit the target. You can generalize this to any point in the co-domain. If we let x be any real number, then the matrix x, 0, 0, 1 will map to x. So notice that if we want to prove that a function is surjective, this often involves a constructive proof. You choose the elements in the co-domain and you build the element of the domain that maps to it. We're going to talk a lot more about that in the next video. Here's a non-example of surjectivity. We're going to let f go from the real numbers to the real numbers be the function defined by f of x equals x squared. Now this is not surjective because it's not the case that every point in the co-domain is covered. Not every point in the co-domain has at least one element of the domain that maps to it. And say that differently, there exists a point in the co-domain where nothing maps to it. In fact, there are a lot of such points. For example, y equals negative 1. That's a real number, but you cannot get negative 1 as the output of this function because we're squaring things. So in fact, there are a lot of points in the co-domain that are not covered by this function. The fact that there's at least one point in the co-domain that's not covered makes this not surjective. However, and this is an important point, if I change the co-domain, the function might become surjective. If I kept the co-domain at r and keep the same formula but change the co-domain to the half open interval from zero to infinity, then now the function is a surjection. Because if I chose any y value in this interval, then I could simply plug in square root of y to my function. As we can see, if I put in square root of y, I get as output square root of y squared, which is equal to y, which was our original target we wanted to hit. So whether or not a function is surjective depends heavily upon the co-domain of this function. So that must be specified clearly when you define the function in the first place. Finally, as with injections, this all becomes really easy if one of the sets we're working with is finite. If the domain of the function is finite, we saw in an earlier video that it's easy to check if the function is injective because we can just do an exhaustive search through all the outputs that are generated for collisions. Likewise, if the co-domain of the function is finite, we can do an exhaustive search through the co-domain and check to see if every point in the co-domain is hit. For example, let F be the function from the integers to Z5, which consists of the integer 0 through 4. And let this function be defined by F of n equals n mod 5. Now, the domain, of course, is infinite, but the co-domain is finite with a cardinality of 5. So I can just check through all five points in the co-domain and see if each one is hit. For example, if I choose 0 in the co-domain, I know that I could put in 0 into the function and hit it. I could also put in 5 or 10 or 20 and a bunch of other points. Likewise, 1 is hit by 1 or 6 or a lot of other points. 2 is hit by 2. 3 is hit by 3. And 4 is hit by 4. So I can just directly check that this function is a surjection if the co-domain is finite. So now let's end off with a concept check here. Here are three functions that map the rational numbers into the integers. Remember, a rational number is just a number that can be written of the form A divided by B where A and B are integers and B is non-zero. So which of the following are surjective? So take a look closely at these functions and pause the video, make your selection, and hit play again when you're ready. So the answer here is just A and C. Let's rule out B, first of all. Why is the function in B not a surjection? Well, not every point in the co-domain of this function, which is the entire set of integers, is actually hit. And that's because since I'm squaring the numerator and squaring the denominator and then adding them to get the output, no integer that is less than or equal to zero is ever going to appear as the output of this function. So there are points in the integers that are not covered. For example, zero, negative one, negative two, none of those points are covered by this function here. Now as for why the functions in A and C are surjections, we're going to end on a cliffhanger here and save that for the next video. We're going to discuss at length just exactly how do you prove that a function is a surjection. So stay tuned.