1 00:00:00,500 --> 00:00:03,840 GILBERT STRANG: OK, I'm going to explain Fourier series, 2 00:00:03,840 --> 00:00:06,300 and that I can't do in 10 minutes. 3 00:00:06,300 --> 00:00:09,460 It'll take two, maybe three, sessions 4 00:00:09,460 --> 00:00:15,690 to see enough examples to really use the idea. 5 00:00:15,690 --> 00:00:20,640 Let me start with what we're looking for. 6 00:00:20,640 --> 00:00:23,190 We have a function. 7 00:00:23,190 --> 00:00:29,100 And we want to write it as a combination of cosines 8 00:00:29,100 --> 00:00:30,920 and sines. 9 00:00:30,920 --> 00:00:35,880 So those our basis functions-- the cosines and the sine. 10 00:00:35,880 --> 00:00:39,600 And a n's and the b n's are the coefficients 11 00:00:39,600 --> 00:00:41,480 that we have to look for. 12 00:00:41,480 --> 00:00:47,790 That tells us how much of cosine nx is in the big function 13 00:00:47,790 --> 00:00:49,270 f of x. 14 00:00:49,270 --> 00:00:55,000 Notice that the cosines start at n equals 0, because cosine of 0 15 00:00:55,000 --> 00:00:55,950 is 1. 16 00:00:55,950 --> 00:01:00,020 So there's an a0 in our sum. 17 00:01:00,020 --> 00:01:05,090 But there isn't a b0, because n equals zero of the sine 18 00:01:05,090 --> 00:01:08,680 would be zero, and we don't get anything there. 19 00:01:08,680 --> 00:01:11,820 So we're looking for the a n's and b n's. 20 00:01:11,820 --> 00:01:16,000 And, really, I want to show you, at the same time, 21 00:01:16,000 --> 00:01:21,580 the complex form with coefficient cn. 22 00:01:21,580 --> 00:01:25,830 And now n goes from minus infinity to infinity. 23 00:01:25,830 --> 00:01:28,820 That's really the more beautiful form 24 00:01:28,820 --> 00:01:36,490 because that one formula for cn does the job, 25 00:01:36,490 --> 00:01:41,390 whereas here I will need a separate formula for a n 26 00:01:41,390 --> 00:01:43,641 and for bn. 27 00:01:43,641 --> 00:01:44,140 OK. 28 00:01:46,740 --> 00:01:52,440 So this is natural when the function is real, 29 00:01:52,440 --> 00:01:56,220 but in the end, and for the discrete Fourier transform, 30 00:01:56,220 --> 00:01:58,560 and for the fast Fourier transform, 31 00:01:58,560 --> 00:02:00,490 the complex case will win. 32 00:02:00,490 --> 00:02:05,170 And, of course, everybody sees that e to the inx, 33 00:02:05,170 --> 00:02:10,250 by Euler's great formula, is a combination of cosine nx 34 00:02:10,250 --> 00:02:11,370 and sine nx. 35 00:02:11,370 --> 00:02:16,470 So, I can use those, or I can use cosine and sine. 36 00:02:16,470 --> 00:02:17,860 OK. 37 00:02:17,860 --> 00:02:21,360 So, how do you find these numbers? 38 00:02:21,360 --> 00:02:23,600 The key is orthogonality. 39 00:02:23,600 --> 00:02:28,030 So that's the first central idea here in Fourier series, 40 00:02:28,030 --> 00:02:30,460 is the idea of orthogonality. 41 00:02:30,460 --> 00:02:31,540 Now what does that mean? 42 00:02:31,540 --> 00:02:33,390 That means perpendicular. 43 00:02:33,390 --> 00:02:36,930 And for a vector, and a second vector, 44 00:02:36,930 --> 00:02:40,100 we have an idea of what perpendicular means. 45 00:02:40,100 --> 00:02:42,670 The 90 degree angle between them. 46 00:02:42,670 --> 00:02:47,730 And we check that by the dot product-- or inner product, 47 00:02:47,730 --> 00:02:52,250 whichever name you like-- between the two vectors 48 00:02:52,250 --> 00:02:54,090 should be 0. 49 00:02:54,090 --> 00:02:54,590 OK. 50 00:02:54,590 --> 00:03:01,560 But here we have functions-- like cosine functions. 51 00:03:01,560 --> 00:03:06,780 So here's one cosine, and here's a different cosine. 52 00:03:06,780 --> 00:03:13,840 So those are two different basis functions-- say, cosine of 7x 53 00:03:13,840 --> 00:03:16,155 and cosine of 12 x. 54 00:03:18,920 --> 00:03:23,310 The coefficients a7 and a12 would tell us 55 00:03:23,310 --> 00:03:27,840 how much of cosine 7x is in the function. 56 00:03:27,840 --> 00:03:32,180 You see, we're separating the function into frequencies. 57 00:03:32,180 --> 00:03:37,800 We're looking into pure oscillations, pure harmonics. 58 00:03:37,800 --> 00:03:42,140 And we expect, probably, that's the lower harmonics 59 00:03:42,140 --> 00:03:46,930 the smoother ones cos x, cos 2x, cos 3x, 60 00:03:46,930 --> 00:03:49,270 have most of the energy. 61 00:03:49,270 --> 00:03:54,660 And the high harmonics, cosine 12x, cosine 100x, 62 00:03:54,660 --> 00:03:57,340 probably those are quickly alternating, 63 00:03:57,340 --> 00:04:02,990 those contain noise, and high frequency. 64 00:04:02,990 --> 00:04:05,360 Quick changes in the function will show up 65 00:04:05,360 --> 00:04:07,210 in the high frequencies. 66 00:04:07,210 --> 00:04:08,470 OK. 67 00:04:08,470 --> 00:04:13,480 So what's the answer to this integral-- cosine 68 00:04:13,480 --> 00:04:21,589 of 7x times cosine of 12x dx, over the range minus pi to pi? 69 00:04:21,589 --> 00:04:25,220 Orthogonality comes in, the answer is 0. 70 00:04:25,220 --> 00:04:27,140 That's the crucial fact. 71 00:04:27,140 --> 00:04:32,460 That's what makes it possible to separate out a7 and a12 72 00:04:32,460 --> 00:04:34,040 and get hold of them. 73 00:04:34,040 --> 00:04:36,480 So let me show you how to do that. 74 00:04:36,480 --> 00:04:42,780 So I'm going to use this fact, which is the function 75 00:04:42,780 --> 00:04:46,300 version of 90 degree angle. 76 00:04:46,300 --> 00:04:49,775 So, you see, it's a little like a dot product. 77 00:04:53,190 --> 00:04:56,730 Well, let me remember, a dot product would be something 78 00:04:56,730 --> 00:05:09,650 like c1 d1 plus c2 d2 equals 0, if I had a vector c1 c2 79 00:05:09,650 --> 00:05:12,610 and a vector d1 d2. 80 00:05:12,610 --> 00:05:15,730 That would be the dot product, and it would be 0 81 00:05:15,730 --> 00:05:17,600 if the vectors are orthogonal. 82 00:05:17,600 --> 00:05:21,020 Here, instead of adding, I'm integrating 83 00:05:21,020 --> 00:05:23,480 because I have functions. 84 00:05:23,480 --> 00:05:26,710 So just that's the meaning of dot product-- 85 00:05:26,710 --> 00:05:29,120 the integral of one function times 86 00:05:29,120 --> 00:05:31,090 the other function gives 0. 87 00:05:31,090 --> 00:05:31,820 OK. 88 00:05:31,820 --> 00:05:33,320 I'll use that now. 89 00:05:33,320 --> 00:05:35,450 OK, how will I use this? 90 00:05:35,450 --> 00:05:40,850 I will look what I want. 91 00:05:40,850 --> 00:05:43,310 This is my goal. 92 00:05:43,310 --> 00:05:52,850 I'll multiply both sides of this equation by cosine kx. 93 00:05:52,850 --> 00:05:55,050 And then I'll integrate. 94 00:05:55,050 --> 00:05:59,820 And the beauty is, that when I multiply by cosine kx, 95 00:05:59,820 --> 00:06:06,520 and I integrate, everything goes to zero except what I want. 96 00:06:06,520 --> 00:06:13,880 By the way, all the sines times cosine kx integrate to 0. 97 00:06:13,880 --> 00:06:17,980 All the sines are orthogonal to all the cosines. 98 00:06:17,980 --> 00:06:21,120 And all the cosines will be orthogonal to all 99 00:06:21,120 --> 00:06:22,260 the other cosines. 100 00:06:22,260 --> 00:06:27,150 So let me show you what I get. 101 00:06:27,150 --> 00:06:32,930 So I multiply my f of x by cosine kx, 102 00:06:32,930 --> 00:06:36,420 and I integrate from minus pi to pi. 103 00:06:36,420 --> 00:06:37,240 OK? 104 00:06:37,240 --> 00:06:41,610 Now, on the right-hand side, this is my integral 105 00:06:41,610 --> 00:06:46,530 from minus pi to pi, of my big sum of all these terms, 106 00:06:46,530 --> 00:06:56,300 0 to infinity, a n cos nx, etcetera-- including the sines 107 00:06:56,300 --> 00:06:58,150 but I'm not even put them in because they're 108 00:06:58,150 --> 00:07:04,152 going to get killed by this integration-- times cosine kx 109 00:07:04,152 --> 00:07:05,940 dx. 110 00:07:05,940 --> 00:07:12,370 All I did was take the f of x equal that formula, 111 00:07:12,370 --> 00:07:20,180 multiplied both sides by cosine kx, and integrated. 112 00:07:20,180 --> 00:07:23,550 And, now the orthogonality pays off, 113 00:07:23,550 --> 00:07:26,930 because this times this, when I integrate 114 00:07:26,930 --> 00:07:29,690 gives 0, with one exception. 115 00:07:29,690 --> 00:07:36,230 When n equals k, then I do get the integral. 116 00:07:36,230 --> 00:07:46,550 The only term I get is ak, cosine kx, twice dx. 117 00:07:46,550 --> 00:07:50,840 Only k equal n survives this process. 118 00:07:50,840 --> 00:07:53,200 And then that integral of cosine squared 119 00:07:53,200 --> 00:07:59,730 happens to be pi, so this is just ak times pi. 120 00:07:59,730 --> 00:08:02,880 Look, I've discovered what ak is. 121 00:08:02,880 --> 00:08:08,590 I've discovered the k Fourier cosine coefficient. 122 00:08:08,590 --> 00:08:11,290 I just divide by pi. 123 00:08:11,290 --> 00:08:16,250 So can I just divide by pi to get this formula for ak? 124 00:08:16,250 --> 00:08:18,180 Ak is 1 over pi. 125 00:08:18,180 --> 00:08:24,120 The integral from minus pi to pi of my function, times 126 00:08:24,120 --> 00:08:28,320 cosine kx dx. 127 00:08:28,320 --> 00:08:30,330 That's the formula. 128 00:08:30,330 --> 00:08:34,880 That tells me the coefficient. 129 00:08:34,880 --> 00:08:38,549 And I could only do that with orthogonality 130 00:08:38,549 --> 00:08:42,059 to knock out all but one term. 131 00:08:42,059 --> 00:08:46,170 And now, if I wanted the sine coefficients, 132 00:08:46,170 --> 00:08:52,220 bk, it would be the same formula except that would be a sine. 133 00:08:52,220 --> 00:08:55,740 And if I wanted the complex coefficient, 134 00:08:55,740 --> 00:09:00,980 ck, it turns out it'd be the same formula expect-- 135 00:09:00,980 --> 00:09:04,390 well maybe it's 2 pi there, 1 over 2 pi-- 136 00:09:04,390 --> 00:09:08,810 and this becomes an e to the minus ikx. 137 00:09:08,810 --> 00:09:14,720 In a complex case, the complex conjugate e to the minus ikx 138 00:09:14,720 --> 00:09:15,910 shows up. 139 00:09:15,910 --> 00:09:19,880 So this is really the dot product, the inner product, 140 00:09:19,880 --> 00:09:22,180 of the function with the cosine. 141 00:09:22,180 --> 00:09:23,050 OK. 142 00:09:23,050 --> 00:09:25,050 So let me do some examples. 143 00:09:29,700 --> 00:09:34,930 Maybe I should write up the sine formula that I just mentioned. 144 00:09:34,930 --> 00:09:43,250 So bk is the integral 1 over pi, the integral of my function, 145 00:09:43,250 --> 00:09:47,360 times sine kx dx. 146 00:09:47,360 --> 00:09:50,600 And there's one exception. 147 00:09:50,600 --> 00:09:55,500 A0 has a little bit different formula, 148 00:09:55,500 --> 00:09:58,380 the pi changes to 2 pi. 149 00:09:58,380 --> 00:10:00,030 I'm sorry about that. 150 00:10:00,030 --> 00:10:04,990 When k is 0 or it's the integral of 1, from minus pi to pi, 151 00:10:04,990 --> 00:10:06,140 and I get 2 pi. 152 00:10:06,140 --> 00:10:15,610 So, a0 is 1 over 2 pi-- the integral of f of x times 153 00:10:15,610 --> 00:10:20,980 when k is zero cosine-- this is 1 dx. 154 00:10:20,980 --> 00:10:22,970 That has a simple meaning. 155 00:10:22,970 --> 00:10:30,766 That's the average of f of x. 156 00:10:34,870 --> 00:10:36,050 OK. 157 00:10:36,050 --> 00:10:42,360 So the basis function was just 1 when k was zero. 158 00:10:42,360 --> 00:10:46,610 When k is 0, the function of my cosine is just one, 159 00:10:46,610 --> 00:10:51,320 and I get the integral of the function 160 00:10:51,320 --> 00:10:55,250 times 1 divided by 2 pi. 161 00:10:55,250 --> 00:10:57,980 Could we just do an example? 162 00:10:57,980 --> 00:11:00,020 So I want to take a function. 163 00:11:00,020 --> 00:11:02,610 And in this video why don't I take 164 00:11:02,610 --> 00:11:07,250 an easy, but very important, function-- the delta function. 165 00:11:07,250 --> 00:11:11,010 So I plan to use these formulas on the delta function. 166 00:11:11,010 --> 00:11:14,090 Let me draw a little picture of the delta function. 167 00:11:14,090 --> 00:11:17,850 I'm only going between minus pi and pi, 168 00:11:17,850 --> 00:11:20,820 and the delta function, as we know, is 0, 169 00:11:20,820 --> 00:11:26,690 it's infinite, at the spike, and 0 again. 170 00:11:26,690 --> 00:11:31,270 The reason I wanted to draw it is, that's an even function. 171 00:11:31,270 --> 00:11:36,560 That's a function which is symmetric between x and minus 172 00:11:36,560 --> 00:11:37,570 x. 173 00:11:37,570 --> 00:11:42,520 And in that case, there will be no sines. 174 00:11:42,520 --> 00:11:45,680 Sine functions are odd. 175 00:11:45,680 --> 00:11:52,870 The integral from minus pi to pi of an odd function gives 0. 176 00:11:52,870 --> 00:12:00,170 The odd means that when you cross x equals 0 177 00:12:00,170 --> 00:12:05,860 you get minus the result for x greater than 0. 178 00:12:05,860 --> 00:12:10,110 So my point is, this is an even function-- 179 00:12:10,110 --> 00:12:17,390 delta of x is the same as delta of minus x, and only cosines. 180 00:12:21,070 --> 00:12:23,920 Good. 181 00:12:23,920 --> 00:12:28,690 The sine coefficients automatically dropped our 0 so, 182 00:12:28,690 --> 00:12:30,490 of course, the integral would show it. 183 00:12:30,490 --> 00:12:33,880 But we see it even before we integrate. 184 00:12:33,880 --> 00:12:37,820 OK I'm ready for the delta function. 185 00:12:37,820 --> 00:12:43,010 So I'm going to write delta of x, 186 00:12:43,010 --> 00:12:45,040 and we remember what the delta function 187 00:12:45,040 --> 00:12:50,930 is-- a combination of cosines. 188 00:12:54,710 --> 00:12:55,330 OK. 189 00:12:55,330 --> 00:12:59,100 That's the delta function between minus pi and pi. 190 00:12:59,100 --> 00:13:00,210 OK. 191 00:13:00,210 --> 00:13:02,690 And what's our formula for the a n? 192 00:13:02,690 --> 00:13:07,770 Well, you remember we had a special formula for a0, which 193 00:13:07,770 --> 00:13:14,930 was 1/2 pi times the integral, from minus pi to pi, 194 00:13:14,930 --> 00:13:22,110 of our function, which is delta, times the basis function, which 195 00:13:22,110 --> 00:13:26,140 n equals 0, the basis function is 1 dx. 196 00:13:26,140 --> 00:13:28,210 OK, we know the answer to that. 197 00:13:28,210 --> 00:13:31,400 We can integrate the delta function. 198 00:13:31,400 --> 00:13:34,910 The one key thing about the integral of the delta function 199 00:13:34,910 --> 00:13:40,990 is, it's always 1-- if we cross x equals 0, which we will. 200 00:13:40,990 --> 00:13:43,510 So that integral is 1 so I'm getting 1/2 pi. 201 00:13:46,180 --> 00:13:50,260 What about the other for a coefficient? 202 00:13:50,260 --> 00:13:52,960 So that's 1/pi, now. 203 00:13:52,960 --> 00:14:00,520 The integral from minus pi to pi of all of my function times 204 00:14:00,520 --> 00:14:02,387 cosine kxdx. 205 00:14:05,380 --> 00:14:06,490 You know what I'm doing. 206 00:14:06,490 --> 00:14:09,520 I'm using my formula to find the coefficients. 207 00:14:09,520 --> 00:14:13,180 My formula says take the function, whatever it is-- 208 00:14:13,180 --> 00:14:16,290 and in this example, it's the delta function-- 209 00:14:16,290 --> 00:14:19,010 multiply by the cosine, integrate, 210 00:14:19,010 --> 00:14:22,200 and divide by the factor pi. 211 00:14:22,200 --> 00:14:23,000 OK. 212 00:14:23,000 --> 00:14:25,780 Well, of course, we can do that integral. 213 00:14:25,780 --> 00:14:28,610 Because when you integrate a delta function, 214 00:14:28,610 --> 00:14:36,410 times some other function, all the action is at x equals 0. 215 00:14:36,410 --> 00:14:40,660 At x equals 0, this function is 1. 216 00:14:40,660 --> 00:14:44,190 And I don't care what it is elsewhere, it's just 1. 217 00:14:44,190 --> 00:14:48,820 So this is the same as integrating delta of x times 1, 218 00:14:48,820 --> 00:14:52,670 which gives us-- well, the interval the delta function 1. 219 00:14:52,670 --> 00:14:56,520 So that integral is one, so I'm getting 1/pi. 220 00:14:59,100 --> 00:15:01,110 Good. 221 00:15:01,110 --> 00:15:02,020 OK. 222 00:15:02,020 --> 00:15:05,090 So now, do you want me to write out 223 00:15:05,090 --> 00:15:06,720 the series for the delta function? 224 00:15:06,720 --> 00:15:09,280 It looks kind of unusual. 225 00:15:09,280 --> 00:15:13,370 This is telling us something quite remarkable. 226 00:15:13,370 --> 00:15:18,740 It's telling us that all these coefficients are the same. 227 00:15:18,740 --> 00:15:22,870 All the frequencies, all the harmonics, 228 00:15:22,870 --> 00:15:27,840 are in the delta function in equal amounts. 229 00:15:27,840 --> 00:15:33,710 Usually, we would see a big drop off of the coefficients ak, 230 00:15:33,710 --> 00:15:37,000 but for the delta function, which is so singular, 231 00:15:37,000 --> 00:15:39,940 all a big spike at one point, there's 232 00:15:39,940 --> 00:15:43,690 no drop off and no decay in the coefficients, 233 00:15:43,690 --> 00:15:45,170 they just constant. 234 00:15:45,170 --> 00:15:45,740 OK. 235 00:15:45,740 --> 00:15:52,010 So I'm saying that the delta function is the constant term, 236 00:15:52,010 --> 00:16:04,200 1/2pi, and then 1/pi times cosine of x, and cosine of 2x, 237 00:16:04,200 --> 00:16:05,390 and so on. 238 00:16:10,760 --> 00:16:12,480 OK. 239 00:16:12,480 --> 00:16:15,540 All frequencies there are the same. 240 00:16:15,540 --> 00:16:21,530 And I'll stop with that one example here. 241 00:16:21,530 --> 00:16:24,520 So the key points were orthogonality, 242 00:16:24,520 --> 00:16:29,390 the formulas for the the coefficients, and this example. 243 00:16:29,390 --> 00:16:31,200 Thank you.