 Welcome back to our lecture series, Math 31-20, Transition to Advanced Mathematics for Students at Southern Utah University. As usual, I'll be a professor today, Dr. Andrew Missildine. In lecture 32, we're gonna talk about the notion of function composition. This is a topic that many of us have probably seen in a calculus or a pre-calculus setting. It's a very common operation that one talks about with functions. But as we are going through our more advanced coverage of functions, it makes sense that we talk about this within our new perspectives of functions. So what does it mean to compose two functions together? Now, suppose we're given two functions, F, which is a function from B to C, and G, which is a function from A to B. Then we can talk about the composition of the two functions, the composite FG, which is usually denoted using this notation right here. You have this F circle G. In the latex world, this would be backslash-circ, as in for circle. It's your circle product there. F circle G here, we would actually read this as like F compose G or F of G. This is a function from A to C defined by the following rule. That the composite of F and G evaluated at X where X is an element that belongs to the domain A, which A is the domain of F of G, but it's also the domain of G here. You define this by the rule that F of G of X is equal to F of G of X. So when you say it out loud, I mean, you actually read it the way, you read them as the exact same thing here. So F of G of X equals F of G of X here, over here. In this situation, just to make sure this makes sense, G of X is a number. It's a something that belongs to the set B. G of X belongs to B here. And as such, B is the domain of F. So it can input into F and then produce something else that belongs in C right here. So this F compose with G of X, what it does is you just first evaluate the element using the function G, then whatever the image of G is, sorry, the image of X with respect to G, you put the image inside of F and that then outputs the, it gives you the image of F of G there. So people often like to think of it using the following analogy here. Like if you have some type of assembly line, you have some function G like so, you have some function F like so. They always draw these machines as if they're like little hubba-bubbas or something like these bubblegum. These look like bubblegum candies to me. So you stick X inside of the G machine, it transforms it and it produces a G of X is this number that pops out of it. G of X pops out, then G of X is exactly what you put inside of the next function F and what it then spits out will be F of G of X right there. And so then the composition is when you put these two processes together, you stick X into the composite, the tandem of the two things and that then creates F of G of X. And I should caution you that there's a few things you should be cautious about here. First of all, the order of operations here matters immensely. Like if you switch the order around assuming that's even possible that dramatically changes the process. Like in the morning, putting your socks on then your shoes is a very different process than putting your shoes on then your socks. If you're not convinced, try it out sometime and see if things feel the same way. This of course, assuming that you can even reverse the role. Like the order of operations here matters. This is a non-commutative process, but even if you can, right? Because G sends something from A to B and F sends something from B to C. If you try to switch that thing around, that is, if you look at G of F, what's gonna happen here is F wants to send B to C then you have to go from C somehow into A and that then maps back to B, right? I mean, what if C and A aren't the same set? Like they might not be related to each other any manner. So this actually might be complete nonsense. The composite, when you reverse it around might be a nonsensical statement. See, you have to be very cautious about that. But even if you can, like if for example, if C were equal to A in that situation, then you could talk about G of F. G of F would be a map from B to A then back to B again. So it's a map from B to B. If on the other hand F of G here, this will be a map from A to B, which then goes back to A. Again, as A and B aren't the same set, these aren't the same function necessarily. For two functions to be the same, they have to have the same domains and co-domains. But then even still, if we make all of these things equal to each other, you have G of F, which is in a function from A to A, and then you have an F of G, which is a function from A to A. So even if we can get all of our ducks in the row and make sure that the domains and co-domains are the same things, these things can still disagree with each other. We'll see an example of that shortly. Another thing I do wanna make mentioned here, when we talk about all of these compositions that when it comes to this, it doesn't actually have to be the case that B is the same thing here. All that matters, we can generalize this a little bit. We could say that F is a map from D to C. We can make composition work so long as B is a subset of D, then this idea of composition would make sense. Because if you take something in A, you map it over to B using G, then G of X lives in B. Since B is a subset of D, then it is inside of the domain of F, and then you can map it over to C. So in more generality, all that's required for composition to hold is the statement we now see on the screen that G is a function from A to B, F is a function from D to C, and so long as the co-domain is a subset of the domain of F, then the composition then applies, it then exists. All right, so let's look at an example of such a thing. Let's use some examples similar to what we've seen in previous lessons here. Let's take the set A to be the numbers one, two, three, four, we'll take B to be the set of numbers one, two, three, four, five, and then to diversify a little bit, we'll take C to be the set three, four, five, six, seven, okay? And so then let's consider two functions here. So F is a function from A to B. So again, A is one, two, three, four, B is one, two, three, four, five. So F will be the function where one goes to two, two goes to two, three goes to four, four goes to one. We've seen this exact function before. G we're gonna define to be a function from B to C given by the rule that one goes to six, two goes to three, three goes to four, four goes to seven, and five goes to five. And so what I'm gonna do is illustrate both of these functions simultaneously here on the screen. So looking at this diagram right here, we see the function diagram for F. So F sends one to two, it sends two to two, it sends four to one, and sends three to four. We've seen this exact function before in previous lessons. I'm gonna then gonna put right next to it the function G, which G sends one to six, it sends two to three, it sends three to four, it sends four to seven, and it sends five to five like so. So this is then an illustration of the function G. Now we wanna think of the composite as the squishing of these two processes together. So you're gonna see that here in the blue graph on the bottom where the middleman of B has been removed. And so we take the domain to be A, the co-domain to be C, and then what happens here? Like we could ask ourselves, what happens to one? One is in the domain of A there, it's in the domain of G of F I should say. Well, when you take the composite, one goes to two via F, and then two goes to three via G. So the composite G of F will send one to three. And so we see this arrow right here, one goes to three. All right, what about two? All right, I claim that two is gonna map to three using the function G of F. And that's because two goes to two using F, and then two goes to three using G. So if we follow the path here, two goes to two, and then just like it did with one, two is gonna go to three right there. So the composite sends two to three, like so. Let's do the next one. F sends three to four, and then G sends four to seven. So the composite will be that three goes to seven. You see like so. And then lastly, we have that four goes to one, one goes to six. Therefore the composite G of F will send four to six, like so. And so we can then see this calculation here. What does G of F do to the numbers one, two, three, four? Now be aware that G does stuff with three, and it also does stuff with five, because those are in the domains of B there, the domain of G is B, three and five are in there. But as three and five don't live inside the range of F, I never need though to know that information when you do the composite. This is what I was saying earlier, that as long as the co-domain of the first set, in particular, as long as the range honestly of the first set lives inside the domain of the second set, then this composite makes sense. There might be things in this second domain that you never utilize, because it doesn't exist inside the image of the first function. So this gives us a symbolic calculation of the composite. So the idea is you string these things together. One goes to two, two goes to three, so the composite is one, three. Three goes to four, four goes to seven, so the composite will then be three, seven. One more example, four goes to one, four goes to one, one goes to six. So when you squish those things together, when you compose those things together, you get four goes to six right there. Do pay attention to the order here. This is actually the outside function. The second function is the outside function here. The notation's a little bit backwards sometimes, so do pay attention to the order here. So G of F means you do F first than G. You have to read that right to left. Let's look at some functions that we're probably more familiar with, like in the pre-calculus or the calculus setting. If you have a function F of X, which is equal to X cubed, be aware that this will be a function from the real numbers to the real numbers. And then you take the function G of X to equal E to the X. So again, we're thinking of this as a function from the real numbers to the real numbers. If you compose those together, F of G, this will be a function from the real numbers to the real numbers. How do you actually compute the formula? Well, much like you do in the pre-calculus setting, you put G of X inside of F of X. G of X has the formula E to the X, and then you're gonna stick that inside of the formula for F. So you get an E to the X cubed. Simplify that by using usual algebraic properties. You get the function E to the three X, like so. Now, let me illustrate like I was mentioning beforehand. If you switch the things around, if you take G of F of X here, this is still a function from R to R. So it makes sense to consider this function, but the formula is very, very different here. You take G of F of X. This time, you're gonna stick X cubed inside of the natural exponential. So you get E to the X cubed power. These are not the same function. An illustration of the graph would give you a clear evidence. These are not the same function. So when function composites can be reversed, because that itself is a hard situation to begin with, but in situations like this where your co-domain and your domain are equal to each other, you can possibly reverse these processes, but if you do, you don't get the same function. In general, this operation is non-commutative, but this idea of composition agrees with what we've seen in calculus and in precalculus settings. All right, so in our previous lecture, number 31, we introduced the notions of injectivity, surjectivity for a function to be bijective. How does that relate to this operation of composition? It turns out that function composition is a very well-behaved operation of functions and properties are actually inherited from the factor functions to the composite. Now, the first thing I wanna mention is that if you have three functions, so F is a function from A to B, G is a function from B to C, and H is a function from C to D, then the triple composite, that is you can put all three of these functions together, we can talk about F of G, which, sorry, H of G, excuse me. H of G would be a function, note that goes from B to D, okay? You can compose that with F so that H of G of F here, that would be a function from A to D, okay? You can also do the composition another way around, like if you take G of F here, G of F would be a function from A to C, H is a function from C to D, so if we compose those together, this gives you a function from A to D. So both this function and that function are functions that map from A to D. So there is the possibility that they could be equal to each other. And in fact, the composition of functions is an associative operation. That is, if you compose the first two, then the third, this is the same thing as composing the second two, then the first. The order in which you do the parentheses does not matter, it produces the same function, all right? And we can actually do the proof of that first, that's currently on the screen here. Now to show that two functions are equal to each other, the general strategy is the following. To show that two, like if you wanna show that F is equal to G, well, first of all, they have to have the same domain and co-domain. So if F and G are both functions from sets, say A to B, then what you do is you take a typical element of your domain and then you show, you have to argue that F of X is equal to G of X for all values X in the domain. If that happens, that then implies that F equals G, all right? So to show that two functions are equal to each other, you show that they have the same evaluations for every element of the domain. So take a typical element of the domain, call it little A, and so let's look at H of G of F of A. By definition, this is gonna be H of G evaluated at F of A, but then when you apply the definition of composition to H of G there, you're gonna get H of G of F of A. Now going the other way around, of course, if you have H of G composite F of A, by definition, this is H of G composite F of A, which by definition, this gives you H of G of F of A. You get the exact same thing here. So this equals that. And as it didn't depend on the choice of A whatsoever, the principle we had just mentioned applies. Since these two functions agree with each other on all evaluations, that means the two functions are equal to each other, all right? So composition of functions is associative. Now let's get back to this business about surjective and injective. If the two functions F and G involved in a composite are both surjective, then their composite will be surjective as well. If the two functions F and G involved in a composition are both injective, then their composite will be injective as well. And then finally, if both the two functions F and G are involved in a composition are both bijective, then their composite will be bijective as well. So the composite will inherit these properties from its two composition factors. Let's prove those things. Now to prove that something is surjective, that's an existential statement. I have to show that given every element of the co-domain, there exists an element in the domain that maps onto it. So let's see the proof of part B then, a part B, which we can see right here. So when you look at the function here, the function we care about is G of F. F is a function from A to B. G is a function from B to C. So G of F is a function from A to C. So to show that it's surjective, we have to take a typical element of the co-domain called little C. Now, since by assumption G is a surjective function, there exists some element in its domain, which is B, called little B, that makes it onto, right? There has to exist some element in its domain such that G of B maps onto C, okay? So G of B equals C. The surjectivity of G gives you that. Now, I should mention that B, so let's see what we did here. So C lives inside of C by the on-to-ness of G. We get that there exists some B inside of B such that G of B equals C, okay? But since B lives inside of big B, that's the co-domain of F. Since F is likewise onto, there's gonna exist some element A inside of its domain such that F of A is equal to B, okay? And so that's exactly what's stated right here. Since F is surjective, there exists some element A inside of its domain, such that F of A equals B. So the surjectivity of B, excuse me, the surjectivity of F implies that F of A equals B here. Now we're gonna, this is now our typical, the element we're looking for, right? The domain of G of F is A. Little A lives inside of that. Let's see if little A maps to C, okay? So G of F, evaluate at A. By definition of composition, this is G of F of A. Now F of A by construction is equal to B. And likewise G of B by construction is equal to C. This shows that there is something in the domain of G composed F that maps onto C. This shows that G of F is a surjective function. This then proves part B. Now for part C, we wanna show that G composed with F is an injective function. We wanna show that it's one to one. So what we're gonna do is we're gonna take two elements of the domain of G composite F, which since the domain of G composite F is A, I'm gonna call them A1 and A2. It's very useful in these proofs to use mnemonic devices as we have these sets A and B and C. It's very useful to use the mnemonic device that lowercase letters belong to the uppercase set. So A1, A2 are both elements of capital A. Much like before, little C belong to big C, little B belong to big B. These mnemonic devices can very much help the clarity of the proofs you're reading and writing. All right, so let's take two elements of the domain and suppose that their evaluation, that their evaluation is equal to the same thing, right? So A1, A2 are chosen such that G of F of A1 is equal to G of F of A2, okay? Now by definition of composition, G of F of A1 is equal to G of F of A1. And likewise, G of F of A2 is equal to G of F of A2. Now notice this equation right here. We have a statement that G, evaluated at some number, is equal to G evaluated at a possibly different number. Since G is injective, it has to be that outputs agree only when input agrees. So therefore, these elements F of A1 and F of A2, which belong to capital B here, by the injectivity of G here, we can basically cancel it out and we get the following statement that F of A1 must have equaled F of A2. Now, F is itself an injective statement, an injective function, excuse me. And now we have this statement that an image of F equals another image of F that can only happen if the input were the same. So because F is itself injective, this implies that A1 equals A2, and that's exactly what we needed. So we had that G of F of A1 equals G of F of A2. We now have inferred that A1 equals A2. That shows that F is an injective function that then proves C. Now the proof of part D is super easy. How do you show that G of F is bijective if F and G are both bijective? Well, since F and G are both bijective, they're gonna be one-to-one and onto. Now, by parts B, since they're both onto, the composites onto, by part C, since they're both one-to-one, their composite will be one-to-one. And therefore, since the composite is both one-to-one and onto, it is bijective. So we see quite quickly that the last condition bijectivity follows from parts A and B. All right, and so that then gives us our lesson about composition of functions. And a lot of this stuff might have been familiar to you, but hopefully this last conversation about surjective and injective compositions was beneficial. If you learned anything in this lecture video, please like it. Like all the videos, honestly, in this channel. Subscribe to the channel to see more videos like this in the future. If you like this video, share it with friends and colleagues who might benefit from it as well. And finally, if you have any questions, please post them in the comments below and I'll be glad to answer them as soon as I can.