[MUSIC] Calculus study functions and this course is no exception. We're going to be studying functions in this course, alright? Functions like f of x or the sine function or the square root function. And that raises a question what are functions?If If we're going to be studying functions, we should know what they are. And that question is pretty metaphysical. I mean what are numbers? What are numbers for? I mean that question doesn't make a lot of sense does it? I, you know, it's not like a number four is a physical object that I can go look at it and see if it's got polka dots or it's striped or something, right? But I know four objects when I see them, right? I sort understand what numbers do more than what they are in some metaphysical sense. The same is true about functions, right? I'm not really going to tell you what a function is. What I'm going to tell you is what a function does. This is what a function does. A function assigns to each number in its domain another number. And this definition doesn't say anything about how the function does that assignment. Let's see an example. Just make up some example. Suppose I've got some function, I'll call it f, f for function. Maybe this function assigns to the number two, the number four. So, I'll write f(2) is 4 or f(3) is 9 Or f(4) is 16 of f(5) is 25. I'm just making this up. This is a function. And I'm telling you what number it assigns to each number, right? f assigns the number two, the number four. f(3) is 9, right? So, f assigns to the number three, the number nine. Well, look, I'm not going to just list off every single assignment that f makes. So instead, one way to talk about these assignments is to use a rule, like f(x) = x^2. And this single rule explains how all of these assignments are made, alright? This rule said that f assigns to the number x, the number x^2. So in particular, f assigns the number five, five squared or 25, or f assigns the number four, four squared which is sixteen or f assigns the number three, three squared which is nine, alright? So, a lot of times, when you actually want to talk about how these assignments are being made, use some sort of rule like this: and you write f of x is something, to compute the output value, right? So, a function assigns to each number in its domain another number. One way to do that is with a rule. Of course, this definition of function involves another word, domain. What is a domain? Unless, I say otherwise, the domain consists of all numbers for which the rule makes sense, right? A function assigns to each number in its domain another number. And the domain is just the numbers that I can plug in. Let's take a look to see what I mean by this. Suppose I've got a function f(x) = 1 / x. So, that's a function given by a rule. It takes an input x and produces the output 1 / x, right? It assigns the number x, the number 1 / x. But this rule doesn't always make sense, right? I'm dividing by x, alright? And to divide by x, what do I need? Well, I must have that x is not zero, not permitted to divide by zero. So, I can plug in any number for x except for zero. And that's when this rule makes sense. So, I'll summarize that by saying that the domain of f is all real numbers except zero. So, a function takes some input and produces some output. That's what it does. But how is that supposed to make us feel, you know? How are we supposed to imagine that? Well, here's one metaphor that you could use to try to think about what a function is actually doing, right? You could imagine a, a conveyor belt with the function, you know, And you could imagine the numbers coming in. Boom. Being hit by the function and then going out transformed somehow, by whatever the rule is of the function. Here's what I'm talking about. I've got a conveyor belt here, I got this big box, and imagine if that big box is the function. And in here, I've got the input, imagine the number five. Let's see what this machine is going to do. Maybe this is the function f(x) = x^2 + x and I've got this number five here. And I'll start the conveyer belt going so the number five starts moving through the machine and when the machine is done processing it, it comes out the other side and now, it's the number 30, alright. Because f(5) is 5^2 + 5, which is 25 + 5 is 20. So, we have seen how you can write down a function by using a, a rule involving these, these mathematical symbols, right? x^2 + x. You can also write down a function just using English words. So, let's see an example of that, just make up a new function here. I'll call it R(x) and I'll define · R(x) to be thrice, that means three times, thrice the square root of x. And here, I've computed some, some values of the function, you know, like the function that four is six. Well, why is that? Well, R(4) would be three times the square root of four, which is three times two which is six. Okay. Now, of course, when I do the calculation this way, you know, it's not too surprising that instead of writing this out in words, thrice the square root of x, I mean I could have just written three times the square root of x. So, maybe you're not too impressed with this. The point is that you can define a function just by writing down what the function is supposed to do using English words. So, we've seen an example of a function that we defined just in terms of algebra, f(x) = x^2 + x. I've also seen an example of a function that I define entirely with just English words. We can kind of combine those two things, alright? We can use the English to sort of pick out different kinds of of algebra. Let's see an example of that now. So, here's another function I just made up. g(x) is x^22 if x is bigger than or equal to five. And twice x if x is less than five. The point here is that I'm using just a little bit of English. So, this word, if, in order to select based on how big x is, a different algebraic rule for calculating the function and this is a little abstract. Let me just do with some calculations and that might convince you, you know, how, how this notation is, this so-called piecewise notation works. So, what is g(1)? Well, let's take a look. One is less than five so that means I use this second rule for calculating g, so it's two times one which is two. What's g of, say, four? Well, four is still less than five so I use the second rule again. Twice the input, two times four and that means the output is eight. But what is, say, g(5)? Ooh. Five is not less than five. Five is greater than or equal to five. So, this if is telling me to use the first of the two rules for calculating g so I'm going to use five squared as the output and that will be 25. Or g(10). Well, ten is definitely bigger than or equal to five and it's bigger than five. So, I again use the first rule and the output to this function is computed as ten squared or 100. So, this is, you know, really more complicated than just using some algebra, right? I'm using these if statements to select which of these two rules g will use to compute its output. in principle, functions can be really complicated. I mean, all the examples we've seen are just doing various kinds of algebra. I mean, maybe different algebra, depending upon which value of x I'm plugging in. But it's all, you know, adding, subtracting, multiplying, dividing that sort of thing. But you can do really complicated things with, with functions. let's see an example of something that is you know really different than doing straight up algebra. I'll do a much crazier example. Alright. C(x) is the number of even digits in the number x, when x is a whole number. It is zero if x isn't a whole number, so otherwise. And it is a really different and crazy function, right? So, C of, say, 7236 is two, and why is that? This is a whole number so I use the first part of the rule. And the number of even digits in this number, well, I count them. That's odd, even, odd, even. So, two and six are the two even digits. The value of that function is two. Well, let's take a look at this number here, 60,202. That again is a whole number, so the value of the function at 60,202 is the number of even digits in x. And this number has how many even digits? One, two, three, four, five, they're all even digits so that value is five. Here's another example. Here's another 5-digit number. 53,531. Again, it's a whole number so I use the first part of the rule, the number of even digits. I count how many of these digits are even. Five is odd, odd, odd, odd, odd. There are no even digits. So, the value of this function is zero at this point. Now, if I plug in a number that's not a whole number like this, this is not a whole number, then I use the otherwise part of the definition. And the function at that point is just a zero. So, we can use English to define a function but you got to be careful, alright? Sometimes, when you write another definition of a function, you might write down something that's more ambiguous than, than you intended. So, let's try to define a function. Just making this stuff up, I'll call the function B(x) for bad. And I'll say that the value of B(x) is some rearrangement of the digits of x. And it's okay that I'm using English to define my functions. There's nothing wrong with that. But this definition is too ambiguous to be the definition of a function. here's a definition of what goes wrong. What is the function's value at 352? Well, the function takes its input and rearranges the digits somehow, alright? So, you might think that the functions value at 352 is 325. Because 325 is some rearrangement of the digits of 352, right, I took the five and the two, swapped their positions. But then, the functions value at 352 should also be 235 because 235 is also a rearrangement of 352. The function's value with 352 should also be 532 because 532 is some rearrangement of the digits of 352. This is terrible, alright? A function is suppose to take its input and produce unambiguously a single output value. But this so-called function takes this single input value and purportedly produces all these possible outputs. This thing here is not a function, alright? A function takes one input and produces one output. [MUSIC]