1 00:00:00,290 --> 00:00:02,014 Cosine. 2 00:00:02,014 --> 00:00:07,562 [MUSIC] 3 00:00:07,562 --> 00:00:12,420 I'd like to approximate cosine of x when x is near zero. 4 00:00:12,420 --> 00:00:15,732 I'm really asking for more than just say, 5 00:00:15,732 --> 00:00:20,000 an approximation to cosine of 0.12 or something. 6 00:00:20,000 --> 00:00:21,840 Right, I want more than just an 7 00:00:21,840 --> 00:00:24,320 approximation that's good at a single point. 8 00:00:24,320 --> 00:00:27,860 This is really what I want to do here. This is going to be my, my goal. 9 00:00:27,860 --> 00:00:32,480 It's going to be to find a polynomial, 10 00:00:32,480 --> 00:00:34,900 and hopefully not a very high degree polynomial. 11 00:00:34,900 --> 00:00:40,630 I'll call that polynomial P of x so that the following happens. 12 00:00:40,630 --> 00:00:46,970 The distance between P of x and cosine of x is less than 1 13 00:00:46,970 --> 00:00:53,580 100th whenever, say, x is between minus 1 and 1. 14 00:00:53,580 --> 00:00:57,490 How can I get started? So to do this, we're going to use 15 00:00:57,490 --> 00:00:59,840 the Taylor series for cosine. 16 00:00:59,840 --> 00:01:05,080 Taylor series for cosine of x is the sum, n goes from 0 to infinity, of 17 00:01:05,080 --> 00:01:11,140 minus 1 to the n over 2 n factorial times x to the 2 n. 18 00:01:11,140 --> 00:01:13,740 The question really boils down to trying to figure out 19 00:01:13,740 --> 00:01:17,670 how many terms I have to take from the Taylor series. 20 00:01:17,670 --> 00:01:22,800 What I'm saying is that cosine of x is approximately the sum 21 00:01:22,800 --> 00:01:25,730 n goes from 0 to some number big N. 22 00:01:25,730 --> 00:01:31,440 Of its Taylor series minus 1 to the n, over 2 n factorial times x to the 2 n. 23 00:01:31,440 --> 00:01:36,950 And the issue here is, I need to know exactly how big that N needs to be. 24 00:01:36,950 --> 00:01:38,400 And that depends on x. 25 00:01:38,400 --> 00:01:40,820 I mean, if x is really big, I'm going to want to take 26 00:01:40,820 --> 00:01:44,619 more terms from my Taylor series to get a good approximation. 27 00:01:45,830 --> 00:01:48,260 But my goal here isn't to get an approximation 28 00:01:48,260 --> 00:01:50,070 for cosine that's good everywhere. 29 00:01:50,070 --> 00:01:53,270 I just want an approximation for cosine that's good 30 00:01:53,270 --> 00:01:55,920 on this interval, the interval from minus one to one. 31 00:01:55,920 --> 00:01:59,890 And then I've quantified exactly how good of an approximation I want. 32 00:01:59,890 --> 00:02:03,590 I want that approximation to be within 1 100th. 33 00:02:03,590 --> 00:02:08,570 I'll use Taylor's theorem to get some idea about the size of the remainder. 34 00:02:08,570 --> 00:02:09,090 Okay. 35 00:02:09,090 --> 00:02:14,130 So the function that I'm studying here is cosine, so let's call that f. 36 00:02:14,130 --> 00:02:16,060 And what does Taylor's theorem say? 37 00:02:16,060 --> 00:02:21,530 Well, it says that the difference between cosine and that 38 00:02:21,530 --> 00:02:25,980 big Nth partial sum of it's Taylor series around zero, so 39 00:02:25,980 --> 00:02:28,330 that's what I'm writing out here, the nth derivative of that 40 00:02:28,330 --> 00:02:31,190 with 0 divided by n factorial times x to the n. 41 00:02:31,190 --> 00:02:36,200 Well this is the remainder term, big R sub big N of x, 42 00:02:36,200 --> 00:02:39,220 and what Taylor's theorem tells me, is it tells me something about big 43 00:02:39,220 --> 00:02:40,690 R sub N of x. 44 00:02:40,690 --> 00:02:46,590 Tells me that big R sub N of x is equal to f the big 45 00:02:46,590 --> 00:02:52,360 N plus 1th derivative of f, evaluated at point z divided by big N 46 00:02:52,360 --> 00:02:57,820 plus 1 factorial times x to the big N plus 1, and z is just 47 00:02:57,820 --> 00:03:02,590 some number between 0, that's the point that I'm taking the Taylor series around. 48 00:03:03,600 --> 00:03:04,660 And x. 49 00:03:04,660 --> 00:03:07,840 I'm assuming that x is between minus 1 and 1. 50 00:03:07,840 --> 00:03:11,140 And that assumption is telling me something about 51 00:03:11,140 --> 00:03:13,230 the size of at least this term here. 52 00:03:13,230 --> 00:03:13,820 Right? 53 00:03:13,820 --> 00:03:19,820 So if x is in the closed interval between minus 1 and 1, then 54 00:03:19,820 --> 00:03:23,410 what do I know about x to the big N plus 1 th power? 55 00:03:23,410 --> 00:03:25,360 Well then I know that the absolute value of x 56 00:03:25,360 --> 00:03:28,695 to big N plus 1th power is no bigger than 1. 57 00:03:28,695 --> 00:03:30,640 And consequently, 58 00:03:30,640 --> 00:03:36,080 the absolute value of big R sub N of x is no bigger than the 59 00:03:36,080 --> 00:03:42,260 absolute value of the N plus first derivative, evaluated as mystery point z. 60 00:03:42,260 --> 00:03:45,280 Divided by N plus 1 factorial. 61 00:03:45,280 --> 00:03:47,100 And I don't have to include this term because 62 00:03:47,100 --> 00:03:50,510 in absolute value, this term is no bigger than 1. 63 00:03:50,510 --> 00:03:55,190 I also know something about the derivatives of cosine, right. 64 00:03:55,190 --> 00:03:56,140 What I know 65 00:03:56,140 --> 00:04:02,020 is that the n plus first derivative of cosine at z. 66 00:04:02,020 --> 00:04:04,670 Well, what happens if I differentiate cosine a bunch of times? 67 00:04:04,670 --> 00:04:06,710 I don't know how many times I'm differentiating it. 68 00:04:06,710 --> 00:04:09,760 But as I differentiate cosine, all I'm going to get 69 00:04:09,760 --> 00:04:13,340 is maybe a plus or minus sine of z, or 70 00:04:13,340 --> 00:04:16,560 maybe a plus or minus cosine of z, depending you 71 00:04:16,560 --> 00:04:19,680 know, what big N plus 1 is actually equal to. 72 00:04:19,680 --> 00:04:21,170 But look at these functions, no matter 73 00:04:21,170 --> 00:04:26,030 what z is, neither of these are larger than 1 in absolute value. 74 00:04:26,030 --> 00:04:29,280 So this is telling me that the absolute value of the big N 75 00:04:29,280 --> 00:04:34,100 plus 1th derivative of f at the point z is no bigger than 1. 76 00:04:34,100 --> 00:04:38,430 We'll use that fact to give a nicer bound on the remainder. 77 00:04:38,430 --> 00:04:42,810 So putting together this fact and this fact, this is what I know. 78 00:04:42,810 --> 00:04:46,120 I know that the remainder is no bigger, 79 00:04:46,120 --> 00:04:51,820 in absolute value, than 1 over big N plus 1 factorial. 80 00:04:51,820 --> 00:04:54,050 And now we're back to that question from the beginning. 81 00:04:54,050 --> 00:04:57,240 How big does N have to be to guarantee 82 00:04:57,240 --> 00:05:00,880 that the remainder is bounded by one 1 100th? 83 00:05:00,880 --> 00:05:05,695 Let me write that down, alright? I'm looking for big N, so that 1 over big 84 00:05:05,695 --> 00:05:11,500 N plus 1 factorial is less than 100th. Well I know some factorials, right? 85 00:05:11,500 --> 00:05:13,970 I know that 4 factorial is 24. 86 00:05:13,970 --> 00:05:17,120 So four isn't a good choice for big N plus 1. 87 00:05:17,120 --> 00:05:19,760 But if this were five factorial. 88 00:05:19,760 --> 00:05:23,030 I had a 1 over 5 factorial. And that's 1 over 120. 89 00:05:23,030 --> 00:05:26,240 And a 120 if it's less than 100. 90 00:05:26,240 --> 00:05:30,080 So if big N plus 1 is 5, that's surely good enough. 91 00:05:30,080 --> 00:05:33,430 So N equals 4 is good enough. 92 00:05:33,430 --> 00:05:35,895 But let's think about the Taylor series for cosine. 93 00:05:35,895 --> 00:05:36,966 The Taylor 94 00:05:36,966 --> 00:05:42,916 series for cosine is cosine of x is equal to 1 minus x squared 95 00:05:42,916 --> 00:05:48,271 over 2 plus x to the 4th over 24, minus x to the 6th 96 00:05:48,271 --> 00:05:54,810 over 6 factorial which is 720. And then it keeps on going. 97 00:05:54,810 --> 00:05:59,210 And the thing to notice here is that there's no x to the 5th term. 98 00:05:59,210 --> 00:06:02,490 Why is that relevant? Well, it means that 99 00:06:02,490 --> 00:06:07,150 if I'm going to sum through the x to the 4th term, if I'm going to set big N equal 100 00:06:07,150 --> 00:06:13,270 4, I might as well set big N equals 5. Because that will improve the error bound. 101 00:06:13,270 --> 00:06:16,050 But it doesn't actually affect the Taylor series at 102 00:06:16,050 --> 00:06:18,190 all, because there is no x to the 5th term. 103 00:06:18,190 --> 00:06:21,560 So let's just make this N equals 5, and 104 00:06:21,560 --> 00:06:25,220 that's going to improve my error estimate somewhat, for free. 105 00:06:25,220 --> 00:06:26,780 Let's summarize what we've found. 106 00:06:26,780 --> 00:06:27,480 Okay, 107 00:06:27,480 --> 00:06:31,590 so what we've got is that cosine of x is 1 108 00:06:31,590 --> 00:06:37,000 minus x squared over 2 plus x to the 4th over 24. 109 00:06:37,000 --> 00:06:40,840 Plus a remainder term, where I'm imagining that I'm 110 00:06:40,840 --> 00:06:43,840 summing through the non-existent x to the 5th term, right? 111 00:06:43,840 --> 00:06:49,030 So I can get away with using this remainder term, as if I'm summing through 112 00:06:49,030 --> 00:06:51,630 the x to the 5th term, because there is no x to the 5th term. 113 00:06:51,630 --> 00:06:52,760 All right, the next term is actually 114 00:06:52,760 --> 00:06:54,390 x to the 6th. All right. 115 00:06:54,390 --> 00:06:57,390 And then I know something about how big this remainder term is. 116 00:06:57,390 --> 00:07:01,290 It's estimated right up here. So what do I know about r sub five? 117 00:07:01,290 --> 00:07:08,570 Well, r sub 5 of x is no bigger than 1 over 5 plus 1 factorial. 118 00:07:08,570 --> 00:07:11,660 That's 1 over 6 factorial, that's 1 over 720. 119 00:07:11,660 --> 00:07:13,720 And that was our goal. 120 00:07:13,720 --> 00:07:18,117 Well, that was our goal! I wanted to write down a polynomial, 121 00:07:18,117 --> 00:07:22,770 here it is. 1 minus x squared over 2 plus x to the 4th 122 00:07:22,770 --> 00:07:28,474 over 24 and this polynomial is approximately cosine of x with an error no 123 00:07:28,474 --> 00:07:35,160 worse than 1 over 720 and originally I just wanted to get within a 100th. 124 00:07:35,160 --> 00:07:36,730 And I've done way better than that. 125 00:07:36,730 --> 00:07:39,430 I mean, this polynomial is an awfully good approximation of 126 00:07:39,430 --> 00:07:42,890 cosine, as long as x is between minus 1 and 1. 127 00:07:42,890 --> 00:07:45,820 This is one of the reasons to love Taylor series. 128 00:07:46,830 --> 00:07:49,480 We've been doing approximations, but thus far the 129 00:07:49,480 --> 00:07:52,750 approximations have really been at a single point. 130 00:07:52,750 --> 00:07:56,800 Now, we're getting approximations that are good at an entire interval. 131 00:07:56,800 --> 00:08:03,015 That's an extremely important idea, and if you want to read some 132 00:08:03,015 --> 00:08:09,534 more about this, the phrase to search for is uniform convergence. 133 00:08:09,534 --> 00:08:15,024 [NOISE]