1 00:00:00,500 --> 00:00:02,350 The Fourier Coefficients applet lets 2 00:00:02,350 --> 00:00:05,300 us explore the approximation of periodic functions 3 00:00:05,300 --> 00:00:07,450 by Fourier series. 4 00:00:07,450 --> 00:00:10,660 This is the opening screen of the applet. 5 00:00:10,660 --> 00:00:13,780 On the right, you see a series of sliders controlling 6 00:00:13,780 --> 00:00:15,840 coefficients. 7 00:00:15,840 --> 00:00:19,590 And they're the coefficients of the sine terms in a Fourier 8 00:00:19,590 --> 00:00:24,780 series, as you can see by clicking this formula box. 9 00:00:24,780 --> 00:00:28,720 So at this point, what we're studying is an odd function, 10 00:00:28,720 --> 00:00:33,510 a sine series, and the sliders let us control the coefficients 11 00:00:33,510 --> 00:00:35,480 of sine of k*t. 12 00:00:38,340 --> 00:00:41,720 If I click the cosine box, I'd see coefficients 13 00:00:41,720 --> 00:00:45,430 of the cosine functions. 14 00:00:45,430 --> 00:00:50,550 Let's go back to sine and start to play 15 00:00:50,550 --> 00:00:54,590 with the tool a little bit. 16 00:00:54,590 --> 00:00:57,670 What will happen if I move the b_2 slider? 17 00:00:57,670 --> 00:01:00,670 I should get multiples of the sine of 2t 18 00:01:00,670 --> 00:01:03,040 showing up on my graphing window. 19 00:01:03,040 --> 00:01:06,920 If I push b_2 to the right, I get positive multiples 20 00:01:06,920 --> 00:01:09,695 of the sine of 2t. 21 00:01:09,695 --> 00:01:13,070 The sine of 2t goes through two full periods 22 00:01:13,070 --> 00:01:15,270 when t ranges from 0 to 2pi. 23 00:01:18,750 --> 00:01:22,340 And if b_2 is negative, I get negative multiples 24 00:01:22,340 --> 00:01:23,140 of the sine of 2t. 25 00:01:26,560 --> 00:01:31,730 What happens if I change b_1 in this tool? 26 00:01:31,730 --> 00:01:35,960 This will add a multiple of the sine of t to the function 27 00:01:35,960 --> 00:01:37,790 that I already have. 28 00:01:37,790 --> 00:01:39,930 If I push this to the right, I'm going 29 00:01:39,930 --> 00:01:42,490 to get positive multiples of the sine of 2t, 30 00:01:42,490 --> 00:01:45,350 and you can see the alteration in the yellow graph 31 00:01:45,350 --> 00:01:46,870 when I do that. 32 00:01:46,870 --> 00:01:51,930 When I push b_1 to the left, I'm adding negative multiples 33 00:01:51,930 --> 00:01:55,290 of the sine of t. 34 00:01:55,290 --> 00:01:58,330 You get quite a variety of interesting functions 35 00:01:58,330 --> 00:02:01,940 by playing with these various sliders. 36 00:02:01,940 --> 00:02:05,390 But it's even more fun to try to match 37 00:02:05,390 --> 00:02:11,660 a target periodic function by means of sine or cosine series. 38 00:02:11,660 --> 00:02:14,650 And the tool has built into it a whole family 39 00:02:14,650 --> 00:02:17,550 of target functions to try for. 40 00:02:17,550 --> 00:02:20,860 Right now, the target function is 0. 41 00:02:20,860 --> 00:02:25,450 But we can select target A instead, and what we have now 42 00:02:25,450 --> 00:02:27,720 is a square wave. 43 00:02:27,720 --> 00:02:30,080 Actually, this isn't the standard square wave 44 00:02:30,080 --> 00:02:32,700 that we deal with in the course, quite. 45 00:02:32,700 --> 00:02:37,260 It is periodic, of period 2pi, and alternates 46 00:02:37,260 --> 00:02:40,280 between positive and negative values, 47 00:02:40,280 --> 00:02:44,900 but those values are pi over 4 and minus pi over 4, 48 00:02:44,900 --> 00:02:48,450 instead of plus 1 and minus 1, as they are 49 00:02:48,450 --> 00:02:50,940 for the standard square wave. 50 00:02:50,940 --> 00:02:53,900 That's chosen so that the Fourier coefficients come 51 00:02:53,900 --> 00:02:57,340 out more neatly, as we'll see. 52 00:02:57,340 --> 00:03:00,260 So let's try to approximate this function 53 00:03:00,260 --> 00:03:03,870 by a finite trigonometric sum. 54 00:03:03,870 --> 00:03:08,210 I'm going to push the Reset key here to reset all 55 00:03:08,210 --> 00:03:11,160 the coefficients to zero, and start trying to match 56 00:03:11,160 --> 00:03:16,320 the function that I have at hand with multiples of sine of k*t. 57 00:03:16,320 --> 00:03:22,170 Let's begin with the sine function itself, sine of t. 58 00:03:22,170 --> 00:03:25,040 Well, I don't know what to do. 59 00:03:25,040 --> 00:03:29,300 Let's just set it so the maxima coincide. 60 00:03:29,300 --> 00:03:29,870 Why not? 61 00:03:29,870 --> 00:03:33,120 Maybe that will be an appropriate amount 62 00:03:33,120 --> 00:03:36,970 of the sine of t function to put into the pot 63 00:03:36,970 --> 00:03:42,660 when I'm trying to mix up the square wave. 64 00:03:42,660 --> 00:03:45,810 Let's go on to b_2 now. 65 00:03:45,810 --> 00:03:49,670 I'm going to push the b_2 slider to the right. 66 00:03:49,670 --> 00:03:54,370 When I do that, you see a hump forming 67 00:03:54,370 --> 00:03:57,860 on the left-hand side of the positive part 68 00:03:57,860 --> 00:03:59,130 of the square wave. 69 00:03:59,130 --> 00:04:01,950 If push b_2 to the left, the same kind of hump 70 00:04:01,950 --> 00:04:06,880 forms on the right-hand side of that positive part 71 00:04:06,880 --> 00:04:08,180 of the square wave. 72 00:04:08,180 --> 00:04:11,390 Neither one of them seems to be doing us very much good. 73 00:04:11,390 --> 00:04:17,540 And in fact, it's creating an asymmetry in the Fourier series 74 00:04:17,540 --> 00:04:19,930 that's not present in our target function. 75 00:04:19,930 --> 00:04:22,960 It's not respecting the symmetry that you 76 00:04:22,960 --> 00:04:27,910 see around pi over 2 in the square wave itself. 77 00:04:27,910 --> 00:04:30,920 So I suspect that b_2 is not going to be useful to us, 78 00:04:30,920 --> 00:04:33,020 that the sine of 2t is not going to be 79 00:04:33,020 --> 00:04:39,050 a constituent in the Fourier series for square wave. 80 00:04:39,050 --> 00:04:41,240 In fact, I think that none of the even sines 81 00:04:41,240 --> 00:04:42,920 will be of any use to us. 82 00:04:42,920 --> 00:04:46,550 And I can get rid of them and look only at the odd terms 83 00:04:46,550 --> 00:04:50,200 by clicking this Odd Terms box. 84 00:04:50,200 --> 00:04:54,340 This leaves the sine function that we had in place. 85 00:04:54,340 --> 00:04:57,690 It eliminates all the odd terms in the series. 86 00:04:57,690 --> 00:05:04,830 It eliminates all the even coefficients and leaves us only 87 00:05:04,830 --> 00:05:05,945 with the odd ones. 88 00:05:05,945 --> 00:05:07,320 But there are more of them, so we 89 00:05:07,320 --> 00:05:09,403 should be able to do a better job of approximating 90 00:05:09,403 --> 00:05:11,240 the square wave. 91 00:05:11,240 --> 00:05:12,590 So let's continue. 92 00:05:12,590 --> 00:05:16,680 Let's try changing b_3 to get a good approximation. 93 00:05:16,680 --> 00:05:18,810 Well, I could push b_3 to the left, 94 00:05:18,810 --> 00:05:21,980 and I get a sharper spike in the middle. 95 00:05:21,980 --> 00:05:23,130 That doesn't look too good. 96 00:05:23,130 --> 00:05:25,510 It looks better to push b_3 to the right 97 00:05:25,510 --> 00:05:27,020 and flatten out the top. 98 00:05:27,020 --> 00:05:30,780 But when I do that, the top becomes too low. 99 00:05:30,780 --> 00:05:35,240 And so maybe I made a mistake in choosing b_1 so 100 00:05:35,240 --> 00:05:37,260 that the maxima agreed. 101 00:05:37,260 --> 00:05:40,040 Maybe I should have made b_1 a little bit bigger. 102 00:05:40,040 --> 00:05:41,750 Now you can see the white curve there-- 103 00:05:41,750 --> 00:05:44,870 that's giving me the multiple of the sine wave itself, 104 00:05:44,870 --> 00:05:47,570 the one that I'm controlling by this slider. 105 00:05:47,570 --> 00:05:51,030 And I guess I should push it up so that my flat part comes 106 00:05:51,030 --> 00:05:53,500 closer to the top of the square wave. 107 00:05:53,500 --> 00:05:55,940 Maybe that's a better approximation. 108 00:05:55,940 --> 00:05:58,140 Well, I can continue playing this game, 109 00:05:58,140 --> 00:06:04,050 trying out various multiples of higher sine functions, 110 00:06:04,050 --> 00:06:06,615 and going back to try to fix up what I had before. 111 00:06:09,240 --> 00:06:11,610 In fact, what we should be trying to do 112 00:06:11,610 --> 00:06:15,670 is create a least squares fit. 113 00:06:15,670 --> 00:06:18,880 You should try to look at the root-mean-square distance 114 00:06:18,880 --> 00:06:21,940 between the Fourier series and the target function, 115 00:06:21,940 --> 00:06:24,670 and minimize that distance. 116 00:06:24,670 --> 00:06:26,820 That distance can be read out in this tool 117 00:06:26,820 --> 00:06:30,125 by clicking the Distance button down here. 118 00:06:30,125 --> 00:06:32,750 And so the root-mean-square distance 119 00:06:32,750 --> 00:06:34,595 between the green curve and the yellow one 120 00:06:34,595 --> 00:06:38,770 is 0.24 and so on, in this case. 121 00:06:38,770 --> 00:06:41,670 Let me come down here and kill the formula. 122 00:06:41,670 --> 00:06:44,050 We know the formula well now, and it 123 00:06:44,050 --> 00:06:48,860 makes the screen a little less cluttered if we get rid of it. 124 00:06:48,860 --> 00:06:56,330 And let me reset the values of the coefficients to zero, 125 00:06:56,330 --> 00:07:00,020 and start to try to approximate this square wave 126 00:07:00,020 --> 00:07:04,110 again by watching the root-mean-square distance 127 00:07:04,110 --> 00:07:07,020 between the Fourier series that I'm creating 128 00:07:07,020 --> 00:07:08,610 and the target function. 129 00:07:08,610 --> 00:07:12,030 So I'll start with b_1 in this case, If I move it down, 130 00:07:12,030 --> 00:07:13,470 the distance increases. 131 00:07:13,470 --> 00:07:18,650 If I move it up, the distance decreases more and more slowly. 132 00:07:18,650 --> 00:07:21,810 But now when b_1 becomes greater than one, 133 00:07:21,810 --> 00:07:22,880 it starts to increase. 134 00:07:22,880 --> 00:07:24,610 So let me push it down again. 135 00:07:24,610 --> 00:07:28,910 I can use these little arrow keys to step the value of b_1. 136 00:07:28,910 --> 00:07:30,480 That's very convenient. 137 00:07:30,480 --> 00:07:34,080 I'm just watching the root-mean-square distance, 138 00:07:34,080 --> 00:07:35,190 this number up here. 139 00:07:35,190 --> 00:07:37,870 I'm trying to make that as small as possible. 140 00:07:37,870 --> 00:07:39,770 It's a measure of the closeness of fit. 141 00:07:39,770 --> 00:07:41,800 Ah, it just started to increase again. 142 00:07:41,800 --> 00:07:43,150 Let me step up. 143 00:07:43,150 --> 00:07:46,120 And I found the value of one. 144 00:07:46,120 --> 00:07:47,580 I didn't set it to one. 145 00:07:47,580 --> 00:07:50,870 I set it to the value that minimized this number. 146 00:07:50,870 --> 00:07:54,800 And that's the right quantity of the sine wave 147 00:07:54,800 --> 00:07:59,960 to put in, if you want to mix up the square wave, or rather pi 148 00:07:59,960 --> 00:08:02,170 over 4 times the square wave. 149 00:08:02,170 --> 00:08:05,110 Let's look at b_3. 150 00:08:05,110 --> 00:08:07,970 Again, if I decrease b3, things get worse. 151 00:08:07,970 --> 00:08:10,390 The root-mean-square distance increases. 152 00:08:10,390 --> 00:08:15,000 But if I increase b_3 above the value of zero, 153 00:08:15,000 --> 00:08:16,880 that number is getting smaller. 154 00:08:16,880 --> 00:08:17,920 Now it's growing again. 155 00:08:17,920 --> 00:08:21,640 I think I'll stop there and use these arrow keys. 156 00:08:21,640 --> 00:08:26,200 That's better, that's better, that's better, that's worse. 157 00:08:26,200 --> 00:08:27,320 Let me go back. 158 00:08:27,320 --> 00:08:31,100 And I find the value 0.33 for b_3. 159 00:08:31,100 --> 00:08:35,539 That's the optimal amount of the sine of 3t 160 00:08:35,539 --> 00:08:38,110 to put in if you want to mix up the formula 161 00:08:38,110 --> 00:08:40,960 for this square wave. 162 00:08:40,960 --> 00:08:43,080 I'll do one more. 163 00:08:43,080 --> 00:08:47,410 Any guesses for what the optimal value of b_5 should be? 164 00:08:47,410 --> 00:08:48,670 It's not going to be negative. 165 00:08:48,670 --> 00:08:51,290 That will increase the root-mean-square distance. 166 00:08:51,290 --> 00:08:55,640 Let's push it up in the positive direction. 167 00:08:55,640 --> 00:08:58,200 That's about right. 168 00:08:58,200 --> 00:09:01,325 That's worse, that's better, that's 169 00:09:01,325 --> 00:09:03,762 better, better, better, worse. 170 00:09:03,762 --> 00:09:04,470 I come down here. 171 00:09:04,470 --> 00:09:05,095 That's optimal. 172 00:09:08,380 --> 00:09:10,670 We've discovered by experimentation with this 173 00:09:10,670 --> 00:09:15,850 applet that the optimal value of b_5 is 0.200. 174 00:09:15,850 --> 00:09:18,500 Each one of these coefficients seems 175 00:09:18,500 --> 00:09:23,280 to have optimal value equal to the reciprocal of the index. 176 00:09:23,280 --> 00:09:27,590 1/3 in this case, 1 in this case, 1/5 in this case. 177 00:09:27,590 --> 00:09:30,640 And I predict that the optimal value of b_7 178 00:09:30,640 --> 00:09:37,600 is going to be 1/7, which is about 0.14. 179 00:09:37,600 --> 00:09:38,605 There you go. 180 00:09:38,605 --> 00:09:39,520 it's right in there. 181 00:09:42,030 --> 00:09:46,350 So this applet lets you understand the true meaning 182 00:09:46,350 --> 00:09:48,420 of the Fourier coefficients. 183 00:09:48,420 --> 00:09:52,310 They're the multiples of the sine waves or the cosine waves 184 00:09:52,310 --> 00:09:57,700 which give you the optimal fit, in terms of a finite Fourier 185 00:09:57,700 --> 00:10:00,620 series, to the target function.