Cosine. [MUSIC] I'd like to approximate cosine of x when x is near zero. I'm really asking for more than just say, an approximation to cosine of 0.12 or something. Right, I want more than just an approximation that's good at a single point. This is really what I want to do here. This is going to be my, my goal. It's going to be to find a polynomial, and hopefully not a very high degree polynomial. I'll call that polynomial P of x so that the following happens. The distance between P of x and cosine of x is less than 1 100th whenever, say, x is between minus 1 and 1. How can I get started? So to do this, we're going to use the Taylor series for cosine. Taylor series for cosine of x is the sum, n goes from 0 to infinity, of minus 1 to the n over 2 n factorial times x to the 2 n. The question really boils down to trying to figure out how many terms I have to take from the Taylor series. What I'm saying is that cosine of x is approximately the sum n goes from 0 to some number big N. Of its Taylor series minus 1 to the n, over 2 n factorial times x to the 2 n. And the issue here is, I need to know exactly how big that N needs to be. And that depends on x. I mean, if x is really big, I'm going to want to take more terms from my Taylor series to get a good approximation. But my goal here isn't to get an approximation for cosine that's good everywhere. I just want an approximation for cosine that's good on this interval, the interval from minus one to one. And then I've quantified exactly how good of an approximation I want. I want that approximation to be within 1 100th. I'll use Taylor's theorem to get some idea about the size of the remainder. Okay. So the function that I'm studying here is cosine, so let's call that f. And what does Taylor's theorem say? Well, it says that the difference between cosine and that big Nth partial sum of it's Taylor series around zero, so that's what I'm writing out here, the nth derivative of that with 0 divided by n factorial times x to the n. Well this is the remainder term, big R sub big N of x, and what Taylor's theorem tells me, is it tells me something about big R sub N of x. Tells me that big R sub N of x is equal to f the big N plus 1th derivative of f, evaluated at point z divided by big N plus 1 factorial times x to the big N plus 1, and z is just some number between 0, that's the point that I'm taking the Taylor series around. And x. I'm assuming that x is between minus 1 and 1. And that assumption is telling me something about the size of at least this term here. Right? So if x is in the closed interval between minus 1 and 1, then what do I know about x to the big N plus 1 th power? Well then I know that the absolute value of x to big N plus 1th power is no bigger than 1. And consequently, the absolute value of big R sub N of x is no bigger than the absolute value of the N plus first derivative, evaluated as mystery point z. Divided by N plus 1 factorial. And I don't have to include this term because in absolute value, this term is no bigger than 1. I also know something about the derivatives of cosine, right. What I know is that the n plus first derivative of cosine at z. Well, what happens if I differentiate cosine a bunch of times? I don't know how many times I'm differentiating it. But as I differentiate cosine, all I'm going to get is maybe a plus or minus sine of z, or maybe a plus or minus cosine of z, depending you know, what big N plus 1 is actually equal to. But look at these functions, no matter what z is, neither of these are larger than 1 in absolute value. So this is telling me that the absolute value of the big N plus 1th derivative of f at the point z is no bigger than 1. We'll use that fact to give a nicer bound on the remainder. So putting together this fact and this fact, this is what I know. I know that the remainder is no bigger, in absolute value, than 1 over big N plus 1 factorial. And now we're back to that question from the beginning. How big does N have to be to guarantee that the remainder is bounded by one 1 100th? Let me write that down, alright? I'm looking for big N, so that 1 over big N plus 1 factorial is less than 100th. Well I know some factorials, right? I know that 4 factorial is 24. So four isn't a good choice for big N plus 1. But if this were five factorial. I had a 1 over 5 factorial. And that's 1 over 120. And a 120 if it's less than 100. So if big N plus 1 is 5, that's surely good enough. So N equals 4 is good enough. But let's think about the Taylor series for cosine. The Taylor series for cosine is cosine of x is equal to 1 minus x squared over 2 plus x to the 4th over 24, minus x to the 6th over 6 factorial which is 720. And then it keeps on going. And the thing to notice here is that there's no x to the 5th term. Why is that relevant? Well, it means that if I'm going to sum through the x to the 4th term, if I'm going to set big N equal 4, I might as well set big N equals 5. Because that will improve the error bound. But it doesn't actually affect the Taylor series at all, because there is no x to the 5th term. So let's just make this N equals 5, and that's going to improve my error estimate somewhat, for free. Let's summarize what we've found. Okay, so what we've got is that cosine of x is 1 minus x squared over 2 plus x to the 4th over 24. Plus a remainder term, where I'm imagining that I'm summing through the non-existent x to the 5th term, right? So I can get away with using this remainder term, as if I'm summing through the x to the 5th term, because there is no x to the 5th term. All right, the next term is actually x to the 6th. All right. And then I know something about how big this remainder term is. It's estimated right up here. So what do I know about r sub five? Well, r sub 5 of x is no bigger than 1 over 5 plus 1 factorial. That's 1 over 6 factorial, that's 1 over 720. And that was our goal. Well, that was our goal! I wanted to write down a polynomial, here it is. 1 minus x squared over 2 plus x to the 4th over 24 and this polynomial is approximately cosine of x with an error no worse than 1 over 720 and originally I just wanted to get within a 100th. And I've done way better than that. I mean, this polynomial is an awfully good approximation of cosine, as long as x is between minus 1 and 1. This is one of the reasons to love Taylor series. We've been doing approximations, but thus far the approximations have really been at a single point. Now, we're getting approximations that are good at an entire interval. That's an extremely important idea, and if you want to read some more about this, the phrase to search for is uniform convergence. [NOISE]