Transcription
Welcome to the second presentation on functions. So let's take off where we left off before. I still apologize--in retrospect, that that whole foul food example. Well, maybe it was helpful, so I'm going to leave it there. Let's do some more problems. I think the best thing is to keep doing problems with you, and I think you'll see the example, and hopefully you'll actually see that functions are kind of fun. Let's do some more problems.
Let's start off with an example, not too different than what we saw before. Let's say that g(x) is equal to 1 if x is even, and it equals 0 if x is odd. And let's say f(x) is equal to x + 3 * g(x). And let's say--I'm going to make it really complicated--well, actually I'm not going to make it any more complicated now. So let's try some problems. So let's give an example. What is f(5)?
Well, it's really pretty straightforward. We take this 5 and we replace it for x in the function f. So f(5) is equal to 5 + 3 * g(5), right? We just literally took this 5 and replaced it everywhere where we see an x. If instead of a 5, I had like a dog here, it would be f(dog) would equal dog + 3 * g(dog). Not that that would necessarily make any sense, but you get the idea. So f(5) equals 5 + 3 * g(5). But what does that equal? So the 5 stays the same, plus 3 times--well, what's g(5)? Well, if we put 5 here, if 5 is even we do 1, if five is odd we do 0. Well, 5 is odd so it's a 0. So g(5) is equal to 0. So this is 3 * 0. So this equals just 5, right, because 3 * 0 is equal to 0.
Well, what would be f(6)? Well, f(6) would equal 6 + 3 * g(6). And once again, that equals 6 plus--well, this time g(6) is, well, 6 is even, so 1. So g(6) is equal to 1. So this equals 6 + 3 * 1. So this equals 6 + 3, which equals 9. I think you might be getting the idea now. At first, when you see a problem with a lot of these functions, it seems very confusing. But if you just keep taking what's inside of the parentheses and replacing that for x and just keep moving along that way, you make a lot of progress on these problems.
Let's try a harder one. Let's say I said that f(x) is equal to x² + 1. Let's say that g(x) is equal to 2x + f(x) - 3. And h(x) is equal to 5x. Now I'm going to give you a tough problem. What is h(g(x))? No. What is h(g of--let's pick a number--let's say 3? h(g(3)). Actually, we'll do examples in the future where we actually could leave the x there and we'll solve for it. But let's say this particular example, what is h(g(3))?
At first, you might say wow, this is crazy, Sal, I don't know how to even start here. But you just take it step-by-step. What can we figure out? Can we figure out what g(3) is? Well, sure. We could take the 3 and put it into the function g and see what it spits out. So let's work on g(3) first. So, g(3) equals--well, it's 2 * 3, right, we're just replacing wherever we see an x with a 3. So it's 2 * 3, so that's 6, plus f(--what, we'll just replace the x again. 3 - 3), right? So this g(3) is equal to 6 + f(what? 3 - 3 is 0). Now we have to figure out f(0) is. We have a definition here for f, so we just figure it out. f(0) is equal to--well, you replace the 0 here. So you get 0², which is 0 + 1. So it's f(0) is 1. So you take that and you replace it for f(0). So you get g(3) is equal to 6 + 1. So g(3) is equal to 7, right? Now we know what g(3) is equal to. We can substitute that back here. So that's the same thing--we know g(3) is equal to 7, so that's the same thing as h(7). And h(7) is just equal to 5 * 7 = 35.
So I think you're probably a little confused here, and I would have been if I was in your shoes. But the important thing is when you first see this problem you're like what can I tackle first? h(g(3)), it seems very confusing. Well, g(3), can I tackle that? Sure. I have a definition of what the function g does when it's given an x, or in this case, was given a 3. And that's what we did. We figured out what g(3) was first. And g(3), we just have to do the 3, and we said well that's 6 + f(3 - 3), right? Because we just replaced that x with that 3. And we just kept solving. We figured out what f(0) is up here. And we got g(3) = 7. Then we substituted that back in right here. We got h(7) is equal to 35 because it was 5 * 7.
Let's do some more problems. Actually, let's do another example with the same set of functions. I don't want to keep confusing you with new functions. Let me erase this as fast as I can. I think I'm getting faster at this erasing business. You can sit and think a little bit about what we just did while I erase.
So let's do another problem. What is f(h(10))? Well, first we want to figure out what h(10) is, right? Well, we could do it in a different way as we'll see later. But we can figure out what h(10) is pretty easily. We take the 10, substitute it in for x. h(10) is equal to 5 * x. In this case x is 10 so it equals 50. So we know h(10) equals 50. So we know h(10) equals 50, so we substitute that back in here. So we say f(h(10)) is the same thing as f(50). And then f(50) is, I think pretty straightforward at this point. You just take that 50 and replace it back here. Well, it's 50² + 1. Well, 50² is 2,500 + 1. That equals 2,501.
What is g(h(1))? Well, we take h(1), h(1) is 5, so this is equal to g(5). And g(5), we just replace the 5 here, so g(5) is equal to 2 * 5 + f(5 - 3). We just take wherever we saw an x and replace it with a 5. Well, that's equal to 2 * 5 is 10, plus f(5 - 3). Well, 5 - 3 is 2. Plus f(2). What's f(2)? Well, 2² + 1 is 5, right? f(2) is 5--2² + 1. So that equals 10 + 5 which equals 15.
If you're still confused, don't worry. I'm about to record some more problems that will give you even more examples of function problems. See you in the next presentation. Bye.