1 00:00:13,530 --> 00:00:16,290 MICHALE FEE: So who remembers what that's called? 2 00:00:16,290 --> 00:00:17,950 A spectrograph. 3 00:00:17,950 --> 00:00:19,600 Good. 4 00:00:19,600 --> 00:00:22,525 And it's a spectrogram of me. 5 00:00:26,470 --> 00:00:28,050 Good morning, class. 6 00:00:28,050 --> 00:00:28,660 OK. 7 00:00:28,660 --> 00:00:31,780 So it's a spectrogram of speech. 8 00:00:31,780 --> 00:00:36,700 And so we are going to continue today 9 00:00:36,700 --> 00:00:39,590 on the topic of understanding-- 10 00:00:39,590 --> 00:00:41,590 developing methods for understanding 11 00:00:41,590 --> 00:00:46,030 how to characterize and understand 12 00:00:46,030 --> 00:00:47,460 temporally structured signals. 13 00:00:47,460 --> 00:00:49,540 So that is the microphone recording 14 00:00:49,540 --> 00:00:52,810 of my voice saying "good morning, class." 15 00:00:52,810 --> 00:00:56,020 And then this is a spectrogram of that signal where 16 00:00:56,020 --> 00:00:58,120 at each moment in time, you can actually 17 00:00:58,120 --> 00:01:01,220 extract the spectral structure of that signal. 18 00:01:01,220 --> 00:01:04,989 And you can see that the information in speech signals 19 00:01:04,989 --> 00:01:12,970 is actually carried in parts of the signal in the way the power 20 00:01:12,970 --> 00:01:16,850 in the signal at different frequencies changes over time. 21 00:01:16,850 --> 00:01:20,410 And your ears detect these changes in frequency 22 00:01:20,410 --> 00:01:22,480 and translate that into information 23 00:01:22,480 --> 00:01:25,030 about what I'm saying. 24 00:01:25,030 --> 00:01:31,420 And so we're going to today start on a-- well, 25 00:01:31,420 --> 00:01:33,550 we sort of started last time, but we're really 26 00:01:33,550 --> 00:01:37,870 going to get going on this in the next three lectures. 27 00:01:37,870 --> 00:01:41,530 We're going to develop a powerful set of tools 28 00:01:41,530 --> 00:01:44,230 for characterizing and understanding 29 00:01:44,230 --> 00:01:46,780 the temporal structure of signals. 30 00:01:46,780 --> 00:01:52,390 So this is the game plan for the next three lectures. 31 00:01:52,390 --> 00:01:55,420 Today we're going to cover Fourier series-- 32 00:01:55,420 --> 00:01:56,710 complex Fourier series. 33 00:01:56,710 --> 00:01:59,620 We're going to extend that to the idea of the Fourier 34 00:01:59,620 --> 00:02:00,760 transform. 35 00:02:00,760 --> 00:02:02,460 And then so the Fourier transform 36 00:02:02,460 --> 00:02:06,940 is sort of a very general mathematical approach 37 00:02:06,940 --> 00:02:10,150 to understanding the temporal structure of signals. 38 00:02:10,150 --> 00:02:12,340 That's more of a-- 39 00:02:12,340 --> 00:02:15,820 you think of that more in terms of doing 40 00:02:15,820 --> 00:02:22,360 analytical calculations or sort of conceptual understanding 41 00:02:22,360 --> 00:02:27,380 of what Fourier decomposition is. 42 00:02:27,380 --> 00:02:33,160 But then there's a very concrete algorithm 43 00:02:33,160 --> 00:02:37,020 for characterizing spectral structure of signals called 44 00:02:37,020 --> 00:02:38,290 the fast Fourier transform. 45 00:02:38,290 --> 00:02:43,480 And that's one class of methods where you sample signals 46 00:02:43,480 --> 00:02:47,710 discretely in time and get back discrete power 47 00:02:47,710 --> 00:02:49,120 at discrete frequencies. 48 00:02:49,120 --> 00:02:51,580 So that's called a discrete Fourier transform. 49 00:02:51,580 --> 00:02:53,770 And most often that's used to compute 50 00:02:53,770 --> 00:02:56,170 the power spectrum of signals. 51 00:02:56,170 --> 00:02:59,570 And so that's what we're going to cover today. 52 00:02:59,570 --> 00:03:02,400 And then in the next lecture, we're 53 00:03:02,400 --> 00:03:04,990 going to cover a number of topics leading up 54 00:03:04,990 --> 00:03:06,257 to spectral estimation. 55 00:03:06,257 --> 00:03:08,590 We're going to start with the convolution theorem, which 56 00:03:08,590 --> 00:03:11,650 is a really powerful way of understanding 57 00:03:11,650 --> 00:03:15,550 the relationship between convolution 58 00:03:15,550 --> 00:03:18,160 in the time domain and multiplication of things 59 00:03:18,160 --> 00:03:19,690 in the frequency domain. 60 00:03:19,690 --> 00:03:22,450 And the convolution theorem is really powerful, 61 00:03:22,450 --> 00:03:25,000 allowing you to kind of think about, intuitively 62 00:03:25,000 --> 00:03:27,550 understand the spectral structure of different kinds 63 00:03:27,550 --> 00:03:31,682 of signals that you can build by convolving different sort 64 00:03:31,682 --> 00:03:33,800 of basic elements. 65 00:03:33,800 --> 00:03:39,010 So if you understand the Fourier decomposition of a square pulse 66 00:03:39,010 --> 00:03:43,790 and a train of pulses or a Gaussian, 67 00:03:43,790 --> 00:03:47,920 you can basically just by kind of thinking about it 68 00:03:47,920 --> 00:03:49,330 figure out the spectral structure 69 00:03:49,330 --> 00:03:52,600 of a lot of different signals by just combining those things 70 00:03:52,600 --> 00:03:53,710 sort of like LEGO blocks. 71 00:03:53,710 --> 00:03:55,060 It's super cool. 72 00:03:55,060 --> 00:03:58,120 We're going to talk about noise and filtering. 73 00:03:58,120 --> 00:04:00,850 We're going to talk about the Shannon-Nyquist sampling 74 00:04:00,850 --> 00:04:03,040 theorem, which tells you how fast you 75 00:04:03,040 --> 00:04:06,400 have to sample a signal in order to perfectly reconstruct it. 76 00:04:06,400 --> 00:04:08,100 It turns out it's really amazing. 77 00:04:08,100 --> 00:04:10,180 If you have a signal in time, you 78 00:04:10,180 --> 00:04:12,910 can sample that signal at regular intervals 79 00:04:12,910 --> 00:04:15,910 and perfectly reconstruct the signal 80 00:04:15,910 --> 00:04:20,230 if that signal doesn't have frequency components that 81 00:04:20,230 --> 00:04:21,130 are too high. 82 00:04:21,130 --> 00:04:23,650 And so that's captured in this Shannon-Nyquist sampling 83 00:04:23,650 --> 00:04:24,190 theorem. 84 00:04:24,190 --> 00:04:28,220 That turns out to actually be a topic of current debate. 85 00:04:28,220 --> 00:04:31,150 There was a paper published recently 86 00:04:31,150 --> 00:04:34,930 by somebody claiming to be able to get around the sampling 87 00:04:34,930 --> 00:04:38,800 theorem and record neural signals without having 88 00:04:38,800 --> 00:04:41,830 to guarantee the conditions under which 89 00:04:41,830 --> 00:04:45,820 the Shannon-Nyquist sampling theorem claims. 90 00:04:45,820 --> 00:04:50,350 And Markus Meister wrote a scathing rebuttal 91 00:04:50,350 --> 00:04:53,650 to that basically claiming that they're full of baloney. 92 00:04:53,650 --> 00:04:58,360 And so those folks who wrote that paper maybe 93 00:04:58,360 --> 00:05:00,700 should have taken this class. 94 00:05:00,700 --> 00:05:02,910 So anyway, you don't want to be on the wrong end 95 00:05:02,910 --> 00:05:06,520 of Markus Meister's blog post. 96 00:05:06,520 --> 00:05:09,330 So pay attention. 97 00:05:09,330 --> 00:05:11,748 So then we're going to get into spectral estimation. 98 00:05:11,748 --> 00:05:13,290 Then in the last lecture, we're going 99 00:05:13,290 --> 00:05:14,940 to talk about spectrograms. 100 00:05:14,940 --> 00:05:17,340 We're going to talk about how to compute spectrograms 101 00:05:17,340 --> 00:05:20,280 and understand really how to take the data 102 00:05:20,280 --> 00:05:22,830 and break it into samples called windowing, 103 00:05:22,830 --> 00:05:26,280 how to multiply those samples by what's called a taper 104 00:05:26,280 --> 00:05:29,100 to avoid contaminating the signal with lots 105 00:05:29,100 --> 00:05:30,918 of noise that's unnecessary. 106 00:05:30,918 --> 00:05:33,460 We're going to understand the idea of time bandwidth product. 107 00:05:33,460 --> 00:05:35,220 How do you choose the width of that window 108 00:05:35,220 --> 00:05:37,470 to emphasize different parts of the data? 109 00:05:37,470 --> 00:05:41,460 And then we're going to end with some advanced filtering 110 00:05:41,460 --> 00:05:48,690 methods that are commonly used to control different frequency 111 00:05:48,690 --> 00:05:51,390 components of signals in your data. 112 00:05:51,390 --> 00:05:53,830 So a bunch of really powerful things. 113 00:05:53,830 --> 00:05:57,000 Here's what we're going to talk about today. 114 00:05:57,000 --> 00:05:59,250 We're going to continue with this Fourier series. 115 00:05:59,250 --> 00:06:01,693 We started with symmetric functions last time. 116 00:06:01,693 --> 00:06:03,360 We're going to finish that and then talk 117 00:06:03,360 --> 00:06:05,100 about asymmetric functions. 118 00:06:05,100 --> 00:06:08,610 We're going to extend that to complex Fourier series, 119 00:06:08,610 --> 00:06:10,950 introduce the Fourier transform and the discrete Fourier 120 00:06:10,950 --> 00:06:13,980 transform and this algorithm and the fast Fourier transform, 121 00:06:13,980 --> 00:06:17,940 and then I'm going to show you how to compute power spectrum. 122 00:06:17,940 --> 00:06:22,770 So just to make it clear, all of this stuff 123 00:06:22,770 --> 00:06:25,110 is basically going to be to teach you 124 00:06:25,110 --> 00:06:27,990 how to use one line of MATLAB. 125 00:06:27,990 --> 00:06:30,720 One function, FFT. 126 00:06:30,720 --> 00:06:37,170 Now, the problem is it's really easy to do this wrong. 127 00:06:37,170 --> 00:06:39,780 It's really easy to use this but not 128 00:06:39,780 --> 00:06:44,340 understand what you're doing and come up with the wrong answer. 129 00:06:44,340 --> 00:06:47,580 So all of these things that we're going to talk about today 130 00:06:47,580 --> 00:06:49,920 are just the kind of basics that you 131 00:06:49,920 --> 00:06:53,680 need to understand in order to use this very powerful function 132 00:06:53,680 --> 00:06:54,180 in MATLAB. 133 00:06:56,760 --> 00:06:58,830 All right. 134 00:06:58,830 --> 00:06:59,890 So let's get started. 135 00:06:59,890 --> 00:07:03,665 So last time, we introduced the idea of a Fourier series. 136 00:07:03,665 --> 00:07:05,040 We talked about the idea that you 137 00:07:05,040 --> 00:07:07,330 can approximate any periodic function. 138 00:07:07,330 --> 00:07:10,680 So here I'm just taking a square wave that alternates 139 00:07:10,680 --> 00:07:12,990 between positive and negative. 140 00:07:12,990 --> 00:07:15,300 It's periodic with a period capital T. 141 00:07:15,300 --> 00:07:16,870 So it's a function of time. 142 00:07:16,870 --> 00:07:21,150 It's a even function or a symmetric function, 143 00:07:21,150 --> 00:07:23,970 because you can see that it's basically mirror 144 00:07:23,970 --> 00:07:27,040 symmetry around the y-axis. 145 00:07:27,040 --> 00:07:29,970 It's even because even polynomials also 146 00:07:29,970 --> 00:07:33,060 have that property of being symmetric. 147 00:07:33,060 --> 00:07:36,690 We can approximate this periodic function 148 00:07:36,690 --> 00:07:41,490 T as a sum of sine waves or cosine waves, in this case. 149 00:07:41,490 --> 00:07:47,310 We can approximate that as a cosine wave of the same period 150 00:07:47,310 --> 00:07:49,120 and the same amplitude. 151 00:07:49,120 --> 00:07:53,760 So we can approximate as a coefficient times cosine 2 pi 152 00:07:53,760 --> 00:07:58,210 f0 t where f0 is just 1 over the period. 153 00:07:58,210 --> 00:08:00,940 So if the period is one second, then the frequency 154 00:08:00,940 --> 00:08:03,610 is 1 hertz, 1 over 1 second. 155 00:08:03,610 --> 00:08:08,740 We often use this different representation 156 00:08:08,740 --> 00:08:12,170 of frequency, which is usually called omega, 157 00:08:12,170 --> 00:08:15,400 which is angular frequency. 158 00:08:15,400 --> 00:08:19,920 And it's just 2 pi times this oscillation frequency. 159 00:08:19,920 --> 00:08:23,620 And it has units of radians per second. 160 00:08:23,620 --> 00:08:26,470 So we talked about the fact that you 161 00:08:26,470 --> 00:08:31,480 can approximate this periodic function as a sum of cosines. 162 00:08:31,480 --> 00:08:33,520 We talked about the idea that you only 163 00:08:33,520 --> 00:08:36,610 need to consider cosines that are integer multiples of omega 164 00:08:36,610 --> 00:08:40,600 0, because those are the only cosine functions, 165 00:08:40,600 --> 00:08:43,780 those are the only functions, that also are 166 00:08:43,780 --> 00:08:47,200 periodic at frequency omega 0. 167 00:08:47,200 --> 00:08:51,370 So a function cosine 3 omega 0 t is also 168 00:08:51,370 --> 00:08:54,390 periodic at frequency omega 0. 169 00:08:54,390 --> 00:08:56,740 Does that make sense? 170 00:08:56,740 --> 00:09:01,510 So now we can approximate any periodic function. 171 00:09:01,510 --> 00:09:04,720 In this case, any even or symmetric periodic 172 00:09:04,720 --> 00:09:12,340 function as a sum of cosines of frequencies that are 173 00:09:12,340 --> 00:09:14,133 integer multiples of omega 0. 174 00:09:14,133 --> 00:09:15,550 And each one of those cosines will 175 00:09:15,550 --> 00:09:17,320 have a different coefficient. 176 00:09:17,320 --> 00:09:23,050 So here's an example where I'm approximating this square wave 177 00:09:23,050 --> 00:09:27,232 here as a sum of cosines of these different frequencies. 178 00:09:27,232 --> 00:09:28,690 And it turns out for a square wave, 179 00:09:28,690 --> 00:09:33,460 you only need the odd multiples of omega 0. 180 00:09:33,460 --> 00:09:35,920 So here's what this approximation 181 00:09:35,920 --> 00:09:38,800 looks like for the case where you only have a single cosine 182 00:09:38,800 --> 00:09:39,730 function. 183 00:09:39,730 --> 00:09:43,088 You can add another cosine of 3 omega 0 t 184 00:09:43,088 --> 00:09:45,130 and you can see that that function starts getting 185 00:09:45,130 --> 00:09:46,960 a little bit more square. 186 00:09:46,960 --> 00:09:49,720 You can add a cosine 5 omega 0 t. 187 00:09:49,720 --> 00:09:51,310 And as you keep adding those things, 188 00:09:51,310 --> 00:09:54,470 again, with the correct coefficients in front of these, 189 00:09:54,470 --> 00:09:56,650 you can see that the function more and more 190 00:09:56,650 --> 00:10:00,950 closely approximates the square wave that we're trying to-- 191 00:10:00,950 --> 00:10:01,590 yes, Habiba 192 00:10:01,590 --> 00:10:04,320 AUDIENCE: Why do we only need the odd multiples? 193 00:10:04,320 --> 00:10:06,310 MICHALE FEE: It just, in general, you 194 00:10:06,310 --> 00:10:08,050 need all the multiples. 195 00:10:08,050 --> 00:10:09,685 But for this particular function, 196 00:10:09,685 --> 00:10:10,810 you only need the odd ones. 197 00:10:22,210 --> 00:10:23,230 Here's another example. 198 00:10:23,230 --> 00:10:28,770 So in this case, we are summing together cosine functions 199 00:10:28,770 --> 00:10:33,870 to approximate a train of pulses. 200 00:10:33,870 --> 00:10:36,330 So the signal we're trying to approximate here 201 00:10:36,330 --> 00:10:42,130 just has a pulse every one unit of time, one period. 202 00:10:42,130 --> 00:10:44,100 And you can see that to approximate this, 203 00:10:44,100 --> 00:10:47,370 we can basically just sum up all the cosines 204 00:10:47,370 --> 00:10:50,370 of all frequencies n omega 0. 205 00:10:50,370 --> 00:10:55,350 And you can see that at time 0, all of those functions 206 00:10:55,350 --> 00:10:56,820 are positive. 207 00:10:56,820 --> 00:11:02,400 And so all of those positive contributions to that sum 208 00:11:02,400 --> 00:11:03,620 all add up. 209 00:11:03,620 --> 00:11:06,030 And as you add them up, you get a big peak. 210 00:11:06,030 --> 00:11:08,190 That's called constructive interference. 211 00:11:08,190 --> 00:11:11,700 So all those peaks add up. 212 00:11:11,700 --> 00:11:16,650 And you also get those peaks all adding up one period away. 213 00:11:16,650 --> 00:11:20,910 One period of cosine omega 0. 214 00:11:20,910 --> 00:11:22,380 You can see they add up again. 215 00:11:22,380 --> 00:11:24,300 So you can see this is a periodic function. 216 00:11:24,300 --> 00:11:27,540 In this time window between those peaks, 217 00:11:27,540 --> 00:11:29,910 you can see that you have positive peaks of some 218 00:11:29,910 --> 00:11:33,360 of those cosines, negative peaks, positive, negative. 219 00:11:33,360 --> 00:11:35,220 They just sort of all add up. 220 00:11:35,220 --> 00:11:38,430 They interfere with each other destructively 221 00:11:38,430 --> 00:11:41,850 to give you a 0 in the intervals between the peaks. 222 00:11:41,850 --> 00:11:43,090 Does that make sense? 223 00:11:43,090 --> 00:11:46,260 And so basically, by choosing the amplitude 224 00:11:46,260 --> 00:11:47,790 of these different cosine functions, 225 00:11:47,790 --> 00:11:52,140 you can basically build any arbitrary periodic function 226 00:11:52,140 --> 00:11:52,980 down here. 227 00:11:52,980 --> 00:11:56,460 Does that makes sense? 228 00:11:56,460 --> 00:11:57,030 All right. 229 00:11:57,030 --> 00:11:59,250 There's one more element that we need 230 00:11:59,250 --> 00:12:03,270 to add here for our Fourier series for even functions. 231 00:12:03,270 --> 00:12:05,730 Anybody have any idea what that is? 232 00:12:05,730 --> 00:12:10,020 Notice here I've shifted this function up a little bit. 233 00:12:10,020 --> 00:12:12,630 So it's not centered at 0. 234 00:12:12,630 --> 00:12:13,730 A constant term. 235 00:12:13,730 --> 00:12:15,900 What's called a DC term. 236 00:12:15,900 --> 00:12:18,780 We basically take the average of that function. 237 00:12:18,780 --> 00:12:19,830 We add it here. 238 00:12:19,830 --> 00:12:22,760 That's called a DC term. 239 00:12:22,760 --> 00:12:25,380 a 0 over 2 is essentially the average 240 00:12:25,380 --> 00:12:28,330 of the function we're trying to approximate. 241 00:12:28,330 --> 00:12:28,830 All right. 242 00:12:28,830 --> 00:12:30,060 Good. 243 00:12:30,060 --> 00:12:32,250 We can now write that as a sum. 244 00:12:32,250 --> 00:12:36,810 y even of t equals a0 over 2 plus a sum 245 00:12:36,810 --> 00:12:41,090 over all these different n's of a sub n, 246 00:12:41,090 --> 00:12:45,010 which is a coefficient, times cosine n omega 0 t. 247 00:12:45,010 --> 00:12:47,460 Omega 0 is 1 over-- 248 00:12:47,460 --> 00:12:52,570 is 2 pi over this time interval here, the periodicity. 249 00:12:55,160 --> 00:12:55,660 All right. 250 00:12:55,660 --> 00:12:56,630 Good. 251 00:12:56,630 --> 00:12:59,670 How do we find those coefficients? 252 00:12:59,670 --> 00:13:02,690 So I just told you that the first coefficient, the a 0 253 00:13:02,690 --> 00:13:05,540 over 2, is just the average of our function t 254 00:13:05,540 --> 00:13:10,240 over one time window from minus t over 2 to plus t over 2. 255 00:13:10,240 --> 00:13:12,440 It's just the integral of that function 256 00:13:12,440 --> 00:13:13,970 over one period divided by t. 257 00:13:13,970 --> 00:13:16,340 And that gives you the average, which is a 0 over 2. 258 00:13:19,350 --> 00:13:20,850 All right, any questions about that? 259 00:13:20,850 --> 00:13:22,150 It's pretty straightforward. 260 00:13:22,150 --> 00:13:24,930 What about this next coefficient, a1? 261 00:13:24,930 --> 00:13:28,470 So the a1 coefficient is just the overlap of our function 262 00:13:28,470 --> 00:13:30,810 y of t with this cosine. 263 00:13:35,830 --> 00:13:41,280 We're just multiplying y0 times cosine of omega 0 t 264 00:13:41,280 --> 00:13:49,680 integrating over time and then multiplying by 2 over t. 265 00:13:49,680 --> 00:13:51,780 So that's the answer. 266 00:13:51,780 --> 00:13:54,520 And I'm going to explain why that is. 267 00:13:58,520 --> 00:14:01,550 That is just a correlation. 268 00:14:01,550 --> 00:14:05,140 It's just like asking how much-- 269 00:14:05,140 --> 00:14:10,720 let's say we had a neuron with a receptive field of cosine omega 270 00:14:10,720 --> 00:14:11,650 0 t. 271 00:14:11,650 --> 00:14:15,310 We're asking how well does our signal overlap 272 00:14:15,310 --> 00:14:17,165 with that receptive field. 273 00:14:17,165 --> 00:14:18,040 Does that make sense? 274 00:14:18,040 --> 00:14:21,660 We're just correlating our signal 275 00:14:21,660 --> 00:14:27,060 with some basis function, with some receptive field. 276 00:14:27,060 --> 00:14:32,600 And we're asking how much overlap is there. 277 00:14:32,600 --> 00:14:35,510 The a2 coefficient is just the overlap of the function 278 00:14:35,510 --> 00:14:39,300 y with cosine 2 omega 0 t. 279 00:14:39,300 --> 00:14:41,520 And the a sub n coefficient is just 280 00:14:41,520 --> 00:14:43,900 the overlap with cosine n omega 0 t. 281 00:14:46,455 --> 00:14:47,080 Just like that. 282 00:14:49,740 --> 00:14:53,300 And you can see that this average that we took up here 283 00:14:53,300 --> 00:14:55,460 just is the generalization of this 284 00:14:55,460 --> 00:15:00,830 to the overlap of our function to cosine 0 omega 0 t. 285 00:15:00,830 --> 00:15:04,840 Cosine 0 omega 0 t is just 1. 286 00:15:04,840 --> 00:15:11,022 And so this coefficient a0 just looks the same as this. 287 00:15:11,022 --> 00:15:12,730 It's just that in this case, it turns out 288 00:15:12,730 --> 00:15:15,770 to be the average of the function. 289 00:15:15,770 --> 00:15:19,230 Any questions about that? 290 00:15:19,230 --> 00:15:23,110 So that is, in general, how you calculate those coefficients. 291 00:15:23,110 --> 00:15:25,800 So you would literally just take your function, 292 00:15:25,800 --> 00:15:30,703 multiply it by a cosine of some frequency, integrate it, 293 00:15:30,703 --> 00:15:31,620 and that's the answer. 294 00:15:35,860 --> 00:15:39,250 Let's just take a look at what some of these coefficients 295 00:15:39,250 --> 00:15:42,220 are for some really simple functions. 296 00:15:42,220 --> 00:15:45,940 So there I've rewritten what each of those coefficients 297 00:15:45,940 --> 00:15:48,160 is as an integral. 298 00:15:48,160 --> 00:15:50,600 And now let's consider the following function. 299 00:15:50,600 --> 00:15:52,720 So let's say our function is 1. 300 00:15:52,720 --> 00:15:54,970 It's just a constant at 1. 301 00:15:54,970 --> 00:16:00,790 So you can see that this integral from minus t over 2 302 00:16:00,790 --> 00:16:05,800 to t over 2, that integral is just t multiplied by 2 over t 303 00:16:05,800 --> 00:16:09,790 gives that coefficient as just 2. 304 00:16:09,790 --> 00:16:13,360 If our function is cosine omega 0 t, 305 00:16:13,360 --> 00:16:17,320 you can see that if you put a cosine in here, that averages 306 00:16:17,320 --> 00:16:18,610 to 0. 307 00:16:18,610 --> 00:16:22,270 If you put a cosine in here, you get cosine squared. 308 00:16:22,270 --> 00:16:29,590 The integral of cosine squared is just half 309 00:16:29,590 --> 00:16:31,970 of basically the full range. 310 00:16:31,970 --> 00:16:33,460 So that's just t over 2. 311 00:16:33,460 --> 00:16:35,470 When you multiply by 2 over t, you get 1. 312 00:16:38,010 --> 00:16:42,030 And the coefficient a2 for a function cosine omega t 313 00:16:42,030 --> 00:16:45,690 is 0, because the integral of cosine omega 0 t times 314 00:16:45,690 --> 00:16:47,550 cosine 2 omega 0 t is 0. 315 00:16:50,170 --> 00:16:50,800 All right. 316 00:16:50,800 --> 00:16:53,380 If we have a function cosine 2 omega 0 t, 317 00:16:53,380 --> 00:16:57,176 then these coefficients are 0, and that coefficient is 1. 318 00:16:57,176 --> 00:17:00,460 You can see that you have this interesting thing here. 319 00:17:00,460 --> 00:17:03,910 If your function is cosine omega 0 t, 320 00:17:03,910 --> 00:17:07,450 then the only coefficient that's non-zero 321 00:17:07,450 --> 00:17:10,250 is the one that you're overlapping with cosine omega 0 322 00:17:10,250 --> 00:17:10,750 t. 323 00:17:10,750 --> 00:17:14,170 It's only this first coefficient that's non-zero. 324 00:17:14,170 --> 00:17:18,069 If your function has a frequency 2 omega 0 t, 325 00:17:18,069 --> 00:17:21,025 then the only coefficient that's non-zero is the a2. 326 00:17:24,520 --> 00:17:28,349 So what that means is that if the function has 327 00:17:28,349 --> 00:17:32,220 maximal overlap, if it overlaps one of those cosines, then 328 00:17:32,220 --> 00:17:34,490 it has 0 overlap with all the others. 329 00:17:37,450 --> 00:17:40,570 And we can say that set of cosine functions, 330 00:17:40,570 --> 00:17:44,370 cosine omega 0 t, cosine 2 omega 0 t, 331 00:17:44,370 --> 00:17:46,840 forms what's called an orthogonal basis set. 332 00:17:46,840 --> 00:17:50,610 We're going to spend a lot of time talking about basis set 333 00:17:50,610 --> 00:17:52,890 later, but I'm just going to throw this word out 334 00:17:52,890 --> 00:17:55,380 to you so that you've heard it when 335 00:17:55,380 --> 00:17:58,200 I come back to the idea of basis sets later. 336 00:17:58,200 --> 00:18:01,690 You're going to see this connection. 337 00:18:01,690 --> 00:18:04,600 So the basic idea is that what we're doing 338 00:18:04,600 --> 00:18:08,630 is we're taking our signal, which is a vector. 339 00:18:08,630 --> 00:18:11,420 It's a set of points in time. 340 00:18:11,420 --> 00:18:15,190 We can think of that as a vector in a high dimensional space. 341 00:18:15,190 --> 00:18:20,950 And we're simply expressing it in a new basis set of cosines 342 00:18:20,950 --> 00:18:22,370 of different frequencies. 343 00:18:22,370 --> 00:18:25,750 So each of those functions, cosine n omega t, 344 00:18:25,750 --> 00:18:29,140 is like a vector in a basis set. 345 00:18:29,140 --> 00:18:31,960 Our signal like a vector. 346 00:18:31,960 --> 00:18:36,130 And what we're doing is when we're doing these projections, 347 00:18:36,130 --> 00:18:38,320 we're simply computing the projection 348 00:18:38,320 --> 00:18:42,670 of that vector, our signal, onto these different basis 349 00:18:42,670 --> 00:18:45,940 functions, these different basis vectors. 350 00:18:45,940 --> 00:18:51,790 So we're just finding the coefficient 351 00:18:51,790 --> 00:18:55,210 so that we can express our signal 352 00:18:55,210 --> 00:18:58,420 as a sum of a coefficient times a basis vector 353 00:18:58,420 --> 00:19:02,690 plus another coefficient times another basis vector and so on. 354 00:19:02,690 --> 00:19:05,410 So for example, in the simple standard basis 355 00:19:05,410 --> 00:19:10,090 where this vector is 0 1 and that vector is 1 0, 356 00:19:10,090 --> 00:19:12,550 you can write down an arbitrary vector 357 00:19:12,550 --> 00:19:18,010 as a coefficient times this plus another coefficient times that. 358 00:19:18,010 --> 00:19:20,750 That make sense? 359 00:19:20,750 --> 00:19:22,370 And how do we find those coefficients? 360 00:19:22,370 --> 00:19:25,340 We just take our vector and dot it 361 00:19:25,340 --> 00:19:28,790 onto each one of these basis vectors, x2. 362 00:19:28,790 --> 00:19:29,870 Does that make sense? 363 00:19:32,710 --> 00:19:36,230 You don't need to know this for this section, 364 00:19:36,230 --> 00:19:38,210 but we're going to come back to this. 365 00:19:38,210 --> 00:19:40,870 I would like you to eventually kind of combine 366 00:19:40,870 --> 00:19:47,110 these views of taking signals and looking at projections 367 00:19:47,110 --> 00:19:50,170 of those into new basis sets. 368 00:19:50,170 --> 00:19:54,750 And as you know, how you see things depends 369 00:19:54,750 --> 00:19:58,140 on how you're looking at them, the direction that you 370 00:19:58,140 --> 00:19:58,840 look at them. 371 00:19:58,840 --> 00:19:59,840 That's what we're doing. 372 00:19:59,840 --> 00:20:03,220 When we take a signal and we project it onto a function, 373 00:20:03,220 --> 00:20:06,060 we're taking a particular view of that function. 374 00:20:09,960 --> 00:20:22,760 So as you know, the view you have on something 375 00:20:22,760 --> 00:20:26,130 has a big impact on what you see. 376 00:20:26,130 --> 00:20:26,630 Right? 377 00:20:34,240 --> 00:20:37,810 So that's all we're doing is we're taking functions 378 00:20:37,810 --> 00:20:41,590 and finding the projection on which we 379 00:20:41,590 --> 00:20:45,010 can see something interesting. 380 00:20:45,010 --> 00:20:46,000 That's it. 381 00:20:46,000 --> 00:20:48,280 That's all spectral analysis is. 382 00:20:48,280 --> 00:20:51,190 And the particular views we're looking at 383 00:20:51,190 --> 00:20:55,510 are projections onto different periodic functions. 384 00:20:55,510 --> 00:20:57,700 Cosines of different frequencies. 385 00:20:57,700 --> 00:20:58,270 All right? 386 00:20:58,270 --> 00:21:00,980 And what you find is that for periodic signals, 387 00:21:00,980 --> 00:21:04,450 there are certain views where something magically pops out 388 00:21:04,450 --> 00:21:08,020 and you see what's there that you can't see when you just 389 00:21:08,020 --> 00:21:11,340 look at the time domain. 390 00:21:11,340 --> 00:21:14,020 All right. 391 00:21:14,020 --> 00:21:17,960 So we looked at even functions or symmetric functions. 392 00:21:17,960 --> 00:21:20,740 Now let's take a look at odd functions 393 00:21:20,740 --> 00:21:22,150 are antisymmetric functions. 394 00:21:22,150 --> 00:21:27,100 These are called odd because the odd polynomials like x cubed 395 00:21:27,100 --> 00:21:28,100 looks like this. 396 00:21:28,100 --> 00:21:29,920 If it's negative on one side, it's 397 00:21:29,920 --> 00:21:31,070 positive on the other side. 398 00:21:31,070 --> 00:21:31,570 Same here. 399 00:21:31,570 --> 00:21:34,630 If it's negative here, then it's positive there. 400 00:21:34,630 --> 00:21:40,810 So we can now write down Fourier series for odd or antisymmetric 401 00:21:40,810 --> 00:21:41,600 functions. 402 00:21:41,600 --> 00:21:43,142 What do you think we're going to use? 403 00:21:43,142 --> 00:21:46,700 Instead of cosines, we're going to use sines, because sines 404 00:21:46,700 --> 00:21:50,860 are symmetric around-- 405 00:21:50,860 --> 00:21:52,760 antisymmetric around the origin. 406 00:21:52,760 --> 00:21:54,760 And we're still going to consider functions that 407 00:21:54,760 --> 00:21:56,740 are periodic with period t. 408 00:21:56,740 --> 00:21:59,170 We can take any antisymmetric function 409 00:21:59,170 --> 00:22:05,020 and approximate it as a sum of sine waves of frequency 2 410 00:22:05,020 --> 00:22:08,770 pi over t or, again, omega 0. 411 00:22:08,770 --> 00:22:11,650 And integer multiples of that omega 0. 412 00:22:14,740 --> 00:22:15,240 All right. 413 00:22:15,240 --> 00:22:18,840 So again, our odd functions can be approximated 414 00:22:18,840 --> 00:22:23,810 as a sum of components, contributions 415 00:22:23,810 --> 00:22:28,150 of different frequencies with a coefficient times 416 00:22:28,150 --> 00:22:31,010 sine of omega 0 t plus another coefficient times 417 00:22:31,010 --> 00:22:34,130 sine of 2 omega 0 t and so on. 418 00:22:34,130 --> 00:22:36,640 And we can write that as a sum that looks like this. 419 00:22:36,640 --> 00:22:40,990 So a sum over n from 1 to infinity of coefficient b 420 00:22:40,990 --> 00:22:46,380 sub n times sine of n omega 0 t. 421 00:22:46,380 --> 00:22:48,120 And why is there no DC term here? 422 00:22:51,018 --> 00:22:51,990 Good. 423 00:22:51,990 --> 00:22:55,390 Because an antisymmetric function can't have a DC 424 00:22:55,390 --> 00:22:55,890 offset. 425 00:22:59,550 --> 00:23:05,760 So for arbitrary functions, you can write down any arbitrary 426 00:23:05,760 --> 00:23:10,520 periodic function as the sum of a symmetric part 427 00:23:10,520 --> 00:23:12,000 and an antisymmetric part. 428 00:23:12,000 --> 00:23:13,620 So we can write down an arbitrary 429 00:23:13,620 --> 00:23:19,980 function as a sum of these cosines 430 00:23:19,980 --> 00:23:21,750 plus a sum of sine waves. 431 00:23:26,280 --> 00:23:27,690 So that's Fourier series. 432 00:23:27,690 --> 00:23:28,740 Any questions about that? 433 00:23:33,010 --> 00:23:35,650 So this is kind of messy. 434 00:23:35,650 --> 00:23:41,170 And it turns out that there's a much simpler way of writing out 435 00:23:41,170 --> 00:23:46,700 functions as sums of periodic functions. 436 00:23:46,700 --> 00:23:48,860 So rather than using cosines and sines, 437 00:23:48,860 --> 00:23:51,830 we're going to use complex exponentials. 438 00:23:51,830 --> 00:23:56,270 And that is what complex Fourier series does. 439 00:23:56,270 --> 00:23:57,590 All right, so let's do that. 440 00:23:57,590 --> 00:24:02,660 So you probably recall that you can write down 441 00:24:02,660 --> 00:24:10,200 a complex exponential e to the i omega t as a cosine omega 442 00:24:10,200 --> 00:24:13,940 t plus i sine omega t. 443 00:24:13,940 --> 00:24:17,760 So e to the i omega t is just a generalization 444 00:24:17,760 --> 00:24:19,890 of sines and cosines. 445 00:24:19,890 --> 00:24:21,950 So the way to think about this is 446 00:24:21,950 --> 00:24:24,970 e to the i omega t is a complex number. 447 00:24:24,970 --> 00:24:27,120 If we plot it in a complex plane where 448 00:24:27,120 --> 00:24:29,910 we look at the real part along this axis, 449 00:24:29,910 --> 00:24:33,840 the imaginary part along that axis, e to the i omega 450 00:24:33,840 --> 00:24:36,060 t just lives on this circle. 451 00:24:36,060 --> 00:24:40,870 No matter what omega t is, e to the i omega t just 452 00:24:40,870 --> 00:24:43,870 sits on this circle in the complex plane, the unit 453 00:24:43,870 --> 00:24:47,670 circle in the complex plane. 454 00:24:47,670 --> 00:24:53,200 e to the i omega t is a function of time. 455 00:24:53,200 --> 00:24:58,400 It simply has a real part that looks like cosine. 456 00:24:58,400 --> 00:25:05,960 So the real part of this as you increase t or the phase omega t 457 00:25:05,960 --> 00:25:11,330 is the real part just oscillates sinusoidally back and forth 458 00:25:11,330 --> 00:25:14,090 like this as a cosine. 459 00:25:14,090 --> 00:25:18,210 The imaginary part just oscillates back and forth 460 00:25:18,210 --> 00:25:20,700 as a sine. 461 00:25:20,700 --> 00:25:22,890 And when you put them together, something 462 00:25:22,890 --> 00:25:25,770 that goes back and forth this way as a cosine 463 00:25:25,770 --> 00:25:29,970 and up and down that way as a sine just traces out a circle. 464 00:25:29,970 --> 00:25:33,850 So e to the i omega traces out a circle in this direction, 465 00:25:33,850 --> 00:25:37,020 and as time increases, it just goes around and around 466 00:25:37,020 --> 00:25:37,950 like this. 467 00:25:37,950 --> 00:25:41,580 E to the minus i omega t just goes the other way. 468 00:25:44,110 --> 00:25:46,130 That make sense? 469 00:25:46,130 --> 00:25:50,630 Got the real part that's going like this, the imaginary part 470 00:25:50,630 --> 00:25:53,810 that's going like this. 471 00:25:53,810 --> 00:25:55,910 And you put those together and they just 472 00:25:55,910 --> 00:25:58,530 go around in a circle. 473 00:25:58,530 --> 00:26:03,010 So you can see it's a way of combining cosine 474 00:26:03,010 --> 00:26:04,640 and sine together in one function. 475 00:26:07,003 --> 00:26:08,420 So what we're going to do is we're 476 00:26:08,420 --> 00:26:13,820 going to rewrite our Fourier series as instead of sines 477 00:26:13,820 --> 00:26:15,320 and cosines, we're going to stick 478 00:26:15,320 --> 00:26:17,750 in e to the-- we're going to replace the sines 479 00:26:17,750 --> 00:26:22,350 and cosines with e to the i omega t and e to the minus i 480 00:26:22,350 --> 00:26:22,940 omega t. 481 00:26:22,940 --> 00:26:29,860 So we're just going to solve these two functions for cosine 482 00:26:29,860 --> 00:26:32,650 and sine, and we're going to take this and plug it 483 00:26:32,650 --> 00:26:36,382 into our Fourier series and see what we get. 484 00:26:36,382 --> 00:26:37,090 So let's do that. 485 00:26:37,090 --> 00:26:40,600 And remember, 1 over i is just minus i. 486 00:26:44,570 --> 00:26:47,030 So here's our Fourier series with our sum 487 00:26:47,030 --> 00:26:48,723 of cosines, our sum of sines. 488 00:26:48,723 --> 00:26:50,390 We're just going to replace those things 489 00:26:50,390 --> 00:26:53,510 with the e to the i omega t plus e to the minus 490 00:26:53,510 --> 00:26:55,260 i omega t and so on. 491 00:26:55,260 --> 00:26:56,150 So there we go. 492 00:26:56,150 --> 00:26:57,200 Just replacing that. 493 00:26:57,200 --> 00:27:00,010 There's a 1/2 there. 494 00:27:00,010 --> 00:27:02,940 And now we're just going to do some algebra. 495 00:27:02,940 --> 00:27:06,690 And we're going to collect either the i omega t's and e to 496 00:27:06,690 --> 00:27:09,658 the minus i omega t's together. 497 00:27:09,658 --> 00:27:10,950 And this is what it looks like. 498 00:27:13,950 --> 00:27:18,120 So you can see that what we're doing 499 00:27:18,120 --> 00:27:21,270 is collecting this into a bunch of terms 500 00:27:21,270 --> 00:27:24,600 that have e to the positive in omega 501 00:27:24,600 --> 00:27:31,080 t here and e to the minus in omega 0 t there. 502 00:27:31,080 --> 00:27:34,530 And now we have still a sum of three things. 503 00:27:34,530 --> 00:27:40,060 So it doesn't really look like we've really gotten anywhere. 504 00:27:40,060 --> 00:27:42,850 But notice something. 505 00:27:42,850 --> 00:27:47,692 If we just put the minus sign into the n, 506 00:27:47,692 --> 00:27:51,130 then we can combine these two into one sum. 507 00:27:51,130 --> 00:27:58,300 And this, if n is 0, what is e to the in omega t? 508 00:27:58,300 --> 00:27:59,920 It's just 1. 509 00:27:59,920 --> 00:28:04,000 So we can also write this as something e to the in omega t 510 00:28:04,000 --> 00:28:06,820 as long as n is 0. 511 00:28:06,820 --> 00:28:07,990 So that's what we do. 512 00:28:07,990 --> 00:28:10,870 Oh, and by the way, these coefficients here 513 00:28:10,870 --> 00:28:16,650 we can just rewrite as sums of those coefficients up there. 514 00:28:16,650 --> 00:28:17,680 Don't worry. 515 00:28:17,680 --> 00:28:19,150 This all looks really complicated. 516 00:28:19,150 --> 00:28:21,700 By the end, it's just boiled down to one simple thing. 517 00:28:21,700 --> 00:28:23,050 That's why we're doing this. 518 00:28:23,050 --> 00:28:24,220 We're simplifying things. 519 00:28:26,820 --> 00:28:30,900 So when you do this, when you rewrite this, 520 00:28:30,900 --> 00:28:34,200 this looks like a sum over n equals 0. 521 00:28:34,200 --> 00:28:38,100 This is a sum over positive n, n equals 1 to infinity. 522 00:28:38,100 --> 00:28:42,360 This is a sum over negative n, minus 1 to minus infinity. 523 00:28:42,360 --> 00:28:47,130 And all those combine into one sum. 524 00:28:47,130 --> 00:28:50,400 So now we can write down any function y of t 525 00:28:50,400 --> 00:28:53,760 as a sum over n equals minus infinity 526 00:28:53,760 --> 00:28:59,310 to infinity of a coefficient a sub n times e to the in omega. 527 00:29:01,960 --> 00:29:06,730 So we went from having this complicated thing, this sum 528 00:29:06,730 --> 00:29:10,360 over our constant terms, sines, and cosines, 529 00:29:10,360 --> 00:29:15,060 and we boiled it down to a single sum. 530 00:29:15,060 --> 00:29:20,910 That's why these complex exponentials are useful. 531 00:29:20,910 --> 00:29:22,680 Because we don't have to carry around 532 00:29:22,680 --> 00:29:26,550 a bunch of different functions, different basis functions 533 00:29:26,550 --> 00:29:32,030 to describe an arbitrary signal y. 534 00:29:32,030 --> 00:29:35,270 But remember, this is just a mathematical trick 535 00:29:35,270 --> 00:29:36,380 to hide sines and cosines. 536 00:29:40,300 --> 00:29:44,525 A very powerful trick, but that's all it's doing. 537 00:29:44,525 --> 00:29:45,775 It's hiding sines and cosines. 538 00:29:48,420 --> 00:29:49,830 All right. 539 00:29:49,830 --> 00:29:53,490 So we've replaced our sums over coastlines and signs 540 00:29:53,490 --> 00:29:56,570 with a sum of complex exponentials. 541 00:29:56,570 --> 00:29:57,740 All right. 542 00:29:57,740 --> 00:30:00,270 Remember what we're doing here. 543 00:30:00,270 --> 00:30:07,550 We're finding a new way of writing down functions. 544 00:30:07,550 --> 00:30:09,800 So what's cool about this, what's 545 00:30:09,800 --> 00:30:13,680 really interesting about this, is that for some functions-- 546 00:30:13,680 --> 00:30:16,430 so what we're doing is we have an arbitrary function y. 547 00:30:16,430 --> 00:30:21,680 And we're writing a down with just some numbers a sub n. 548 00:30:21,680 --> 00:30:26,530 And what's cool about this is that for some functions y, 549 00:30:26,530 --> 00:30:29,380 you can describe that function with just a few 550 00:30:29,380 --> 00:30:33,085 of these coefficients a. 551 00:30:33,085 --> 00:30:34,540 Does that make sense? 552 00:30:34,540 --> 00:30:36,160 So let me just show you an example 553 00:30:36,160 --> 00:30:38,600 of some functions that look really, 554 00:30:38,600 --> 00:30:41,740 really simple when you rewrite them 555 00:30:41,740 --> 00:30:44,320 using these coefficients a. 556 00:30:44,320 --> 00:30:46,250 So here's an example. 557 00:30:46,250 --> 00:30:53,100 So here's a function of n that has three numbers. 558 00:30:53,100 --> 00:30:58,380 a sub minus 1, n equals minus 1 is 1/2, a sub 0 is 0, 559 00:30:58,380 --> 00:31:00,480 and a sub 1 is 1/2. 560 00:31:00,480 --> 00:31:01,950 And all the rest of them are 0. 561 00:31:01,950 --> 00:31:07,610 So really, we only have two non-zero entries in this sum. 562 00:31:07,610 --> 00:31:10,530 So what function is that? 563 00:31:10,530 --> 00:31:12,480 It's just a cosine. 564 00:31:12,480 --> 00:31:15,630 So we have-- let's write this out. 565 00:31:15,630 --> 00:31:18,550 Y equals a sum over all of these things. 566 00:31:18,550 --> 00:31:21,930 1/2 e to the minus-- 567 00:31:21,930 --> 00:31:27,730 the first n is minus 1. e to the minus i omega 0 t plus 1/2 e 568 00:31:27,730 --> 00:31:29,850 to the plus i omega 0 t. 569 00:31:29,850 --> 00:31:32,160 We're just writing out that sum. 570 00:31:32,160 --> 00:31:33,327 And that is just-- 571 00:31:37,660 --> 00:31:41,650 sorry, I didn't tell you what that equation was. 572 00:31:41,650 --> 00:31:46,330 That's Euler's equation. 573 00:31:46,330 --> 00:31:49,150 That's just cosine minus i sine omega t. 574 00:31:49,150 --> 00:31:51,910 That is just cosine plus i sine omega t. 575 00:31:51,910 --> 00:31:52,945 The sines cancel. 576 00:31:55,630 --> 00:31:57,930 And you're left with cosine omega 0 t. 577 00:32:00,890 --> 00:32:06,200 So here's this function of time that goes on infinitely. 578 00:32:06,200 --> 00:32:10,970 If you wanted to write down all the values of cosine omega 0 t, 579 00:32:10,970 --> 00:32:14,130 you'd have to write down an awful lot of numbers. 580 00:32:14,130 --> 00:32:17,735 And here we can write down that same function with two numbers. 581 00:32:23,700 --> 00:32:30,630 So this is a very compact view of that function of time. 582 00:32:36,150 --> 00:32:37,890 Here's another function. 583 00:32:37,890 --> 00:32:40,010 What function do you think that is? 584 00:32:42,700 --> 00:32:48,780 What would be the time domain equivalent of this set 585 00:32:48,780 --> 00:32:54,050 of Fourier coefficients? 586 00:32:54,050 --> 00:32:54,590 Good. 587 00:32:54,590 --> 00:32:56,090 So we're going to do the same thing. 588 00:32:56,090 --> 00:32:57,630 Just write it out. 589 00:32:57,630 --> 00:32:59,370 All these sums are 0. 590 00:32:59,370 --> 00:33:02,400 All these components are 0 except for two of them. 591 00:33:02,400 --> 00:33:05,985 n equals minus 2 and n equals plus 2. 592 00:33:05,985 --> 00:33:08,010 You just put those in there as 1/2 593 00:33:08,010 --> 00:33:18,560 e to the minus 2 omega 0 t plus 1/2 e to the plus 2 omega 0 t. 594 00:33:18,560 --> 00:33:22,490 And that is just if you write that out, those sines cancel, 595 00:33:22,490 --> 00:33:24,770 and you have cosine 2 omega 0 t. 596 00:33:24,770 --> 00:33:27,500 Pretty simple, right? 597 00:33:27,500 --> 00:33:30,240 How about this one? 598 00:33:30,240 --> 00:33:34,070 This is the-- remember, the a's are complex numbers. 599 00:33:34,070 --> 00:33:38,020 The ones we were looking at here had two real numbers. 600 00:33:38,020 --> 00:33:42,920 Here's an example where the a's are imaginary. 601 00:33:42,920 --> 00:33:44,570 One is i over 2. 602 00:33:44,570 --> 00:33:47,920 One is minus i over 2. 603 00:33:47,920 --> 00:33:53,230 That's what the complex Fourier representation 604 00:33:53,230 --> 00:33:56,530 looks like of this function. 605 00:33:56,530 --> 00:33:59,090 We can just plug it in here. 606 00:33:59,090 --> 00:34:03,410 You solve that, you can see that in this case, 607 00:34:03,410 --> 00:34:06,350 the cosines cancel, because this is i over 2 608 00:34:06,350 --> 00:34:10,429 cosine 2 omega t minus i over 2 cosine 2 omega t. 609 00:34:10,429 --> 00:34:15,170 Those cancel and you're left with sine 2 omega 0 t. 610 00:34:15,170 --> 00:34:20,600 So that is what Fourier representation of sine 2 omega 611 00:34:20,600 --> 00:34:22,940 t looks like. 612 00:34:22,940 --> 00:34:26,080 So the functions that have higher frequencies 613 00:34:26,080 --> 00:34:32,409 will have non-zero elements that are further out in n. 614 00:34:37,639 --> 00:34:38,810 Any questions about that? 615 00:34:45,370 --> 00:34:50,639 So again, this set of functions e to the in omega 0 t 616 00:34:50,639 --> 00:34:57,730 form an orthogonal, orthonormal basis set over that [INAUDIBLE] 617 00:34:57,730 --> 00:34:59,253 over that interval. 618 00:34:59,253 --> 00:35:03,830 The a0 coefficient is just the projection 619 00:35:03,830 --> 00:35:08,060 of our function onto e to the 0. 620 00:35:08,060 --> 00:35:09,530 n equals 0. 621 00:35:09,530 --> 00:35:10,760 And that's just the average. 622 00:35:13,690 --> 00:35:17,550 The a1 coefficient is just the projection of our function 623 00:35:17,550 --> 00:35:21,770 e to the minus i omega 0 t. 624 00:35:21,770 --> 00:35:24,540 And in general, the m-th coefficient 625 00:35:24,540 --> 00:35:28,250 is just the projection of our function onto e 626 00:35:28,250 --> 00:35:30,770 to the minus im omega 0 t. 627 00:35:36,310 --> 00:35:39,910 And we can take those coefficients, 628 00:35:39,910 --> 00:35:45,220 plug them into this sum, and reconstruct an arbitrary 629 00:35:45,220 --> 00:35:49,420 periodic function, this y of t. 630 00:35:49,420 --> 00:35:51,970 So we have a way of taking a function 631 00:35:51,970 --> 00:35:56,260 and getting these complex Fourier coefficients. 632 00:35:56,260 --> 00:35:59,590 And we have a way of taking those coefficients 633 00:35:59,590 --> 00:36:03,230 and reconstructing our function. 634 00:36:03,230 --> 00:36:10,090 This is just a bunch of different views function y. 635 00:36:10,090 --> 00:36:12,130 And from all of those different views, 636 00:36:12,130 --> 00:36:16,000 we can reconstruct our function. 637 00:36:16,000 --> 00:36:17,960 That's all it is. 638 00:36:17,960 --> 00:36:24,830 So in general, when we do Fourier decomposition 639 00:36:24,830 --> 00:36:28,880 in a computer in MATLAB on real signals 640 00:36:28,880 --> 00:36:31,730 that you've sampled in time, it's 641 00:36:31,730 --> 00:36:37,780 always done in this kind of discrete representation. 642 00:36:37,780 --> 00:36:41,140 You've got, in this case, discrete frequencies. 643 00:36:41,140 --> 00:36:42,970 When you sample signals, you've got 644 00:36:42,970 --> 00:36:47,470 functions that are discrete in time, and this becomes a sum. 645 00:36:47,470 --> 00:36:49,600 But before we go to the discrete case, 646 00:36:49,600 --> 00:36:51,070 I just want to show you what this 647 00:36:51,070 --> 00:36:55,220 looks like when we go to the case of arbitrary functions. 648 00:36:55,220 --> 00:36:57,790 Remember, this thing was about representing 649 00:36:57,790 --> 00:36:59,260 periodic functions. 650 00:36:59,260 --> 00:37:01,630 You can only represent periodic functions 651 00:37:01,630 --> 00:37:05,140 using these Fourier series. 652 00:37:05,140 --> 00:37:08,830 But before we go on to the Fourier transform algorithm 653 00:37:08,830 --> 00:37:10,840 and discrete Fourier transforms, I just 654 00:37:10,840 --> 00:37:13,960 want to show you what this looks like for the case of arbitrary 655 00:37:13,960 --> 00:37:15,930 functions. 656 00:37:15,930 --> 00:37:18,270 And I'm just showing this to you. 657 00:37:18,270 --> 00:37:21,160 I don't expect you to be able to reproduce any of this. 658 00:37:21,160 --> 00:37:24,220 But you should see what it looks like, for those of you who 659 00:37:24,220 --> 00:37:27,240 haven't seen it already. 660 00:37:27,240 --> 00:37:29,700 So what we're going to do is go from the case 661 00:37:29,700 --> 00:37:32,533 of periodic functions to non-periodic functions. 662 00:37:32,533 --> 00:37:34,200 And the simplest way to think about that 663 00:37:34,200 --> 00:37:36,840 is a periodic function does something here, 664 00:37:36,840 --> 00:37:39,240 and then it just does the same thing here, 665 00:37:39,240 --> 00:37:42,060 and then it just does the same thing here. 666 00:37:42,060 --> 00:37:48,160 So how do we go from this to an arbitrary function? 667 00:37:48,160 --> 00:37:53,084 Well, we're just going to let the period go to infinity. 668 00:37:53,084 --> 00:37:55,440 Does that make sense? 669 00:37:55,440 --> 00:37:57,090 That's actually pretty easy. 670 00:37:57,090 --> 00:37:59,610 We're going to let t go to infinity, which 671 00:37:59,610 --> 00:38:06,990 means the frequencies, which are 2 pi omega 0 or 2 pi over t, 672 00:38:06,990 --> 00:38:09,480 that's going to go to 0. 673 00:38:09,480 --> 00:38:11,910 So our steps. 674 00:38:11,910 --> 00:38:14,220 Remember when we had this discrete Fourier transform 675 00:38:14,220 --> 00:38:20,310 here, we had these steps in frequency as a function of n. 676 00:38:20,310 --> 00:38:24,100 Those steps are just going to get infinitely close together, 677 00:38:24,100 --> 00:38:26,780 the different frequency bins. 678 00:38:26,780 --> 00:38:28,740 So that's what we're going to do now. 679 00:38:28,740 --> 00:38:31,870 You're just going to let those frequency steps go to 0. 680 00:38:31,870 --> 00:38:36,130 And now frequency, in discrete case, 681 00:38:36,130 --> 00:38:42,730 the frequency is just that number, that n times omega 0. 682 00:38:42,730 --> 00:38:44,290 m times omega 0. 683 00:38:44,290 --> 00:38:49,180 Well, omega 0 is going to 0, but the m's are getting really big. 684 00:38:49,180 --> 00:38:51,070 So we can just change-- 685 00:38:51,070 --> 00:38:52,570 we're just going to call that omega. 686 00:38:57,350 --> 00:38:59,405 The omega 0's are going to 0, so the m's 687 00:38:59,405 --> 00:39:00,530 are getting infinitely big. 688 00:39:00,530 --> 00:39:03,500 So we can't really use m anymore or n 689 00:39:03,500 --> 00:39:05,635 to label our frequency steps. 690 00:39:05,635 --> 00:39:07,010 So we're just going to use omega. 691 00:39:10,160 --> 00:39:12,320 We used to call our coefficients, 692 00:39:12,320 --> 00:39:16,370 our Fourier coefficients, we used to label them with m. 693 00:39:16,370 --> 00:39:20,030 We can't use m anymore, because m is getting infinitely big. 694 00:39:20,030 --> 00:39:22,550 So we use this new label omega. 695 00:39:22,550 --> 00:39:27,200 So a sub m becomes a new variable, our Fourier 696 00:39:27,200 --> 00:39:33,330 transform, labeled by the frequency omega. 697 00:39:33,330 --> 00:39:38,220 And we're just going to basically just make 698 00:39:38,220 --> 00:39:39,600 those replacements in here. 699 00:39:39,600 --> 00:39:44,290 So the coefficients become a function of frequency. 700 00:39:44,290 --> 00:39:45,630 That's just an integral. 701 00:39:45,630 --> 00:39:47,910 Remember, t is going to infinity now. 702 00:39:47,910 --> 00:39:50,070 So this has to go from minus infinity 703 00:39:50,070 --> 00:39:56,940 to infinity of our function y times our basis function. 704 00:39:56,940 --> 00:39:59,640 And instead of e to the im omega 0 t, 705 00:39:59,640 --> 00:40:02,970 we just replace m omega 0 with omega. 706 00:40:02,970 --> 00:40:06,060 So e to the minus i omega t. 707 00:40:06,060 --> 00:40:10,420 And that is the Fourier transform. 708 00:40:10,420 --> 00:40:13,880 And we're just going to do the same replacement here, 709 00:40:13,880 --> 00:40:19,990 but instead of summing over n going from minus infinity 710 00:40:19,990 --> 00:40:23,050 to infinity, we have to write this as an integral as well. 711 00:40:23,050 --> 00:40:25,690 And so that we can reconstruct our function 712 00:40:25,690 --> 00:40:31,780 y of t as an integral of our Fourier coefficients 713 00:40:31,780 --> 00:40:36,190 times the e to the i omega t. 714 00:40:36,190 --> 00:40:37,590 See that? 715 00:40:37,590 --> 00:40:38,958 It's essentially the same thing. 716 00:40:38,958 --> 00:40:41,250 It's just that we're turning this sum into an integral. 717 00:40:46,240 --> 00:40:46,740 All right. 718 00:40:46,740 --> 00:40:49,240 So that's called a Fourier transform. 719 00:40:49,240 --> 00:40:51,700 And that's the inverse Fourier transform, this [INAUDIBLE] 720 00:40:51,700 --> 00:40:54,850 from a function to Fourier coefficients. 721 00:40:54,850 --> 00:40:56,680 And this takes your Fourier coefficients 722 00:40:56,680 --> 00:40:58,000 and goes back to your function. 723 00:41:02,880 --> 00:41:04,740 All right, good. 724 00:41:04,740 --> 00:41:07,870 Let me just show you a few simple examples. 725 00:41:07,870 --> 00:41:12,250 So let's start with the function y of t equals 1. 726 00:41:12,250 --> 00:41:14,730 So it's just a constant. 727 00:41:14,730 --> 00:41:16,050 What is the Fourier transform? 728 00:41:16,050 --> 00:41:18,060 So let's plug this into here. 729 00:41:20,730 --> 00:41:24,120 Does anyone know what that integral looks 730 00:41:24,120 --> 00:41:29,570 like of the integral from minus infinity to infinity 731 00:41:29,570 --> 00:41:37,125 of e the minus i omega t dt integrating over time. 732 00:41:37,125 --> 00:41:39,450 It's a delta function. 733 00:41:39,450 --> 00:41:46,350 There's only one value of omega for which that function is not 734 00:41:46,350 --> 00:41:46,850 0. 735 00:41:46,850 --> 00:41:51,792 Remember, so let's say omega equals 1, 1-- you know, 736 00:41:51,792 --> 00:41:53,340 1 hertz. 737 00:41:53,340 --> 00:41:55,380 This is just a bunch of sines and cosines. 738 00:41:55,380 --> 00:42:00,870 So when you integrate over sines and cosines, you get 0. 739 00:42:00,870 --> 00:42:04,770 Integral over time of cosine is just 0. 740 00:42:04,770 --> 00:42:08,840 But if omega is 0, then what is e to the i omega t? 741 00:42:12,850 --> 00:42:15,850 e to the i 0 is 1. 742 00:42:15,850 --> 00:42:20,860 And so we're integrating over 1 times dt. 743 00:42:20,860 --> 00:42:24,675 And that becomes infinity at omega equals 0. 744 00:42:24,675 --> 00:42:26,050 And that's a delta function, it's 745 00:42:26,050 --> 00:42:31,740 0 everywhere except 4 at 0. 746 00:42:31,740 --> 00:42:34,050 So that becomes a delta function. 747 00:42:34,050 --> 00:42:39,990 This Fourier transform of a constant is a delta function. 748 00:42:39,990 --> 00:42:41,710 And that's a really-- 749 00:42:41,710 --> 00:42:44,080 it's a really good one to know. 750 00:42:44,080 --> 00:42:47,500 The Fourier transform of a constant is a delta function. 751 00:42:47,500 --> 00:42:49,960 That's called a Fourier transform pair. 752 00:42:49,960 --> 00:42:53,470 You have a function and another function. 753 00:42:53,470 --> 00:42:55,152 One function is the Fourier transform 754 00:42:55,152 --> 00:42:56,610 of the other function that's called 755 00:42:56,610 --> 00:43:00,100 a Fourier transform pair. 756 00:43:00,100 --> 00:43:02,860 So the Fourier transform of a constant 757 00:43:02,860 --> 00:43:05,820 is just a delta function at 0. 758 00:43:05,820 --> 00:43:07,860 You can invert that. 759 00:43:07,860 --> 00:43:11,370 If you integrate, let's just plug that delta function 760 00:43:11,370 --> 00:43:12,000 into here. 761 00:43:12,000 --> 00:43:17,550 If you integrate delta function times e to the i omega t, 762 00:43:17,550 --> 00:43:21,810 you just get e to the i 0t, which is just 1. 763 00:43:24,680 --> 00:43:27,800 So we can take the Fourier transform of 1, 764 00:43:27,800 --> 00:43:30,230 get a delta function, [INAUDIBLE] inverse Fourier 765 00:43:30,230 --> 00:43:32,480 transform the delta function, and get back 1. 766 00:43:35,010 --> 00:43:37,660 How about this function right here? 767 00:43:37,660 --> 00:43:40,430 This function is e to the i omega 1. 768 00:43:40,430 --> 00:43:44,550 It's a sine wave and a cosine wave, a complex sine 769 00:43:44,550 --> 00:43:48,120 and cosine, at frequency omega 1. 770 00:43:48,120 --> 00:43:51,508 Anybody know what the Fourier transform of that is? 771 00:43:51,508 --> 00:43:53,620 AUDIENCE: [INAUDIBLE] 772 00:43:53,620 --> 00:43:54,370 MICHALE FEE: Yeah. 773 00:43:54,370 --> 00:44:03,730 So it's basically-- you can think of this-- 774 00:44:03,730 --> 00:44:04,790 that's the right answer. 775 00:44:04,790 --> 00:44:07,370 Rather than try to explain it, I'll just show you. 776 00:44:07,370 --> 00:44:11,450 So the Fourier transform of this is just a peak at omega 1. 777 00:44:14,520 --> 00:44:17,220 And we can inverse Fourier transform that and recover 778 00:44:17,220 --> 00:44:18,900 our original function. 779 00:44:18,900 --> 00:44:22,230 So those last few slides are more for the aficionados. 780 00:44:22,230 --> 00:44:23,915 You don't have to know that. 781 00:44:23,915 --> 00:44:25,290 We're going to spend time looking 782 00:44:25,290 --> 00:44:31,290 at the discrete versions of these things. 783 00:44:31,290 --> 00:44:32,830 How about this case? 784 00:44:32,830 --> 00:44:35,400 This is a simple case where you have 785 00:44:35,400 --> 00:44:38,940 a function that the Fourier transform 786 00:44:38,940 --> 00:44:44,000 of which has a peak at omega 1 and a peak at minus omega 1. 787 00:44:44,000 --> 00:44:47,160 The Fourier transform of the inverse Fourier transform 788 00:44:47,160 --> 00:44:50,970 of that is just cosine omega 1t. 789 00:44:50,970 --> 00:44:55,140 So a function, a cosine function with frequency omega 1, 790 00:44:55,140 --> 00:44:59,340 has two peaks, one at frequency omega 1 791 00:44:59,340 --> 00:45:04,310 and another one at frequency minus omega 1. 792 00:45:04,310 --> 00:45:06,660 So that looks a lot like the case 793 00:45:06,660 --> 00:45:10,170 we just talked about where we had this complex Fourier 794 00:45:10,170 --> 00:45:11,040 series. 795 00:45:11,040 --> 00:45:16,140 And we had a peak at n equals 2 and another peak at n 796 00:45:16,140 --> 00:45:18,090 equals minus 2. 797 00:45:18,090 --> 00:45:21,660 And that function that gave us that complex Fourier 798 00:45:21,660 --> 00:45:24,425 series was cosine 2 omega t. 799 00:45:24,425 --> 00:45:25,800 So that's just what we have here. 800 00:45:25,800 --> 00:45:29,010 We have a peak in the spectrum at omega 1, 801 00:45:29,010 --> 00:45:31,860 peak at minus omega 1, and that is 802 00:45:31,860 --> 00:45:34,350 the Fourier decomposition of a function that 803 00:45:34,350 --> 00:45:36,930 is cosine omega 1t. 804 00:45:36,930 --> 00:45:39,050 So it's just like what we saw before 805 00:45:39,050 --> 00:45:43,330 for the case of the complex Fourier series. 806 00:45:46,040 --> 00:45:48,490 So that was Fourier transform. 807 00:45:48,490 --> 00:45:54,770 And now let's talk about the discrete Fourier transform 808 00:45:54,770 --> 00:45:57,290 and the associated algorithm for computing 809 00:45:57,290 --> 00:46:02,210 that very quickly called the Fast Fourier Transform, or FFT. 810 00:46:02,210 --> 00:46:06,620 So you can see computing these Fourier transforms, 811 00:46:06,620 --> 00:46:09,950 if you were to actually try to compute Fourier transforms 812 00:46:09,950 --> 00:46:13,400 by taking a function, multiplying it 813 00:46:13,400 --> 00:46:17,420 by these complex exponentials like writing down 814 00:46:17,420 --> 00:46:22,510 the value of e to the i omega t at a bunch of different omegas 815 00:46:22,510 --> 00:46:25,270 and a bunch of different t's and then integrating 816 00:46:25,270 --> 00:46:32,930 that numerically, that would take forever computationally. 817 00:46:32,930 --> 00:46:35,840 But it turns out that there's-- 818 00:46:35,840 --> 00:46:38,090 so you have to compute that integral 819 00:46:38,090 --> 00:46:42,590 over time for every omega that you're interested in. 820 00:46:42,590 --> 00:46:46,670 It turns out really, really fast algorithm that you 821 00:46:46,670 --> 00:46:48,170 can use for the case where you've 822 00:46:48,170 --> 00:46:52,570 got functions that are sampled in time 823 00:46:52,570 --> 00:46:56,890 and you want to extract the frequencies of that signal 824 00:46:56,890 --> 00:46:59,350 at a discrete set of frequencies. 825 00:47:03,890 --> 00:47:06,440 I'm going to switch from using omega, which 826 00:47:06,440 --> 00:47:07,910 is very commonly used when you're 827 00:47:07,910 --> 00:47:09,380 talking about Fourier transforms, 828 00:47:09,380 --> 00:47:11,670 to just using f, the frequency. 829 00:47:11,670 --> 00:47:15,230 So it's just f is just 2 pi. 830 00:47:15,230 --> 00:47:18,410 So omega is 2 pi f. 831 00:47:18,410 --> 00:47:26,610 So here I'm just rewriting the Fourier transform 832 00:47:26,610 --> 00:47:28,110 and the inverse Fourier transform 833 00:47:28,110 --> 00:47:29,730 with f rather than omega. 834 00:47:29,730 --> 00:47:31,590 So we're going to start using f's now 835 00:47:31,590 --> 00:47:35,010 for the discrete Fourier transform case. 836 00:47:35,010 --> 00:47:36,760 And we're going to consider the case where 837 00:47:36,760 --> 00:47:40,380 we have signals that are sampled at regular intervals delta t. 838 00:47:40,380 --> 00:47:44,390 So here we have a function of time y of t. 839 00:47:44,390 --> 00:47:48,600 And we're going to sample that signal at regular intervals 840 00:47:48,600 --> 00:47:49,260 delta t. 841 00:47:49,260 --> 00:47:51,870 So this is delta t right here. 842 00:47:51,870 --> 00:47:53,820 That time interval there. 843 00:47:53,820 --> 00:47:58,500 So the sampling rate, the sampling frequency, is just 1 844 00:47:58,500 --> 00:47:59,310 over delta t. 845 00:48:04,920 --> 00:48:10,300 So the way this works in the fast Fourier transform 846 00:48:10,300 --> 00:48:13,150 algorithm is you just take those samples 847 00:48:13,150 --> 00:48:17,970 and you put them into a vector in MATLAB, just 848 00:48:17,970 --> 00:48:21,150 some one-dimensional array. 849 00:48:23,950 --> 00:48:29,650 And we're going to imagine that our samples are 850 00:48:29,650 --> 00:48:32,320 acquired at different times. 851 00:48:32,320 --> 00:48:37,690 And let's [INAUDIBLE] minus time step 8, minus 7, minus 6. 852 00:48:37,690 --> 00:48:40,930 Time step 0 is in the middle up to time step 7. 853 00:48:40,930 --> 00:48:43,380 And we're going to say that N is an even number. 854 00:48:43,380 --> 00:48:45,800 The fast Fourier transform works much, 855 00:48:45,800 --> 00:48:48,220 much faster when N is an even number, 856 00:48:48,220 --> 00:48:53,590 and it works even faster when N is a multiple, a power of 2. 857 00:48:53,590 --> 00:48:55,530 So in this case, we have 16 samples. 858 00:48:55,530 --> 00:48:56,950 It's 2 to the 4. 859 00:48:56,950 --> 00:49:05,500 Should usually try to make your samples be a power of 2. 860 00:49:05,500 --> 00:49:08,650 The number of samples. 861 00:49:08,650 --> 00:49:14,110 So there is our function of time sampled at regular intervals t. 862 00:49:19,240 --> 00:49:23,710 So you can see that the t min, the minimum time, 863 00:49:23,710 --> 00:49:27,850 in this vector of sample points in our function 864 00:49:27,850 --> 00:49:31,420 is minus N over 2 delta t. 865 00:49:31,420 --> 00:49:36,800 And that [INAUDIBLE] time is N over 2 minus 1 times delta t. 866 00:49:42,650 --> 00:49:45,290 And that's what the MATLAB code would 867 00:49:45,290 --> 00:49:51,624 look like to generate an array of time values. 868 00:49:51,624 --> 00:49:52,810 Does that make sense? 869 00:49:56,260 --> 00:50:02,030 The FFT algorithm returns the Fourier components 870 00:50:02,030 --> 00:50:06,250 of that function of time. 871 00:50:06,250 --> 00:50:09,070 And it returns the Fourier components 872 00:50:09,070 --> 00:50:14,500 in a vector that has the negative frequencies on one 873 00:50:14,500 --> 00:50:16,780 side and the positive frequencies 874 00:50:16,780 --> 00:50:20,520 on the other side and the constant term 875 00:50:20,520 --> 00:50:22,170 here in the middle. 876 00:50:26,640 --> 00:50:30,630 The minimum frequency is N over 2 times delta F. Oh, 877 00:50:30,630 --> 00:50:34,890 I should say it returns the Fourier components in steps 878 00:50:34,890 --> 00:50:38,040 of delta f where delta F is the sampling rate divided 879 00:50:38,040 --> 00:50:40,500 by the number of time steps that you put into it. 880 00:50:43,680 --> 00:50:45,470 Don't panic. 881 00:50:45,470 --> 00:50:47,280 This is just reference. 882 00:50:47,280 --> 00:50:51,980 I'm showing you how you put the data in 883 00:50:51,980 --> 00:50:55,340 and how you get the data out. 884 00:50:55,340 --> 00:50:57,770 When you put data into the Fourier transform 885 00:50:57,770 --> 00:51:00,840 algorithm, the FFT algorithm, you 886 00:51:00,840 --> 00:51:03,630 put in data that's sampled at times, 887 00:51:03,630 --> 00:51:07,140 and you have to know what those times are. 888 00:51:07,140 --> 00:51:09,510 If you want to make a plot of the data, 889 00:51:09,510 --> 00:51:13,660 you need to make an array of time values. 890 00:51:13,660 --> 00:51:17,792 And they just go from a t min to a t max. 891 00:51:17,792 --> 00:51:19,500 And there's a little piece of MATLAB code 892 00:51:19,500 --> 00:51:23,150 that produces that array of times for you. 893 00:51:25,660 --> 00:51:27,910 What you get back from the Fourier transform, 894 00:51:27,910 --> 00:51:33,920 the FFT, an array of not values of the function of time, 895 00:51:33,920 --> 00:51:38,620 but rather an array of Fourier coefficients. 896 00:51:38,620 --> 00:51:42,010 Just like we stuck in into our-- 897 00:51:42,010 --> 00:51:45,760 when we did the complex Fourier series, 898 00:51:45,760 --> 00:51:47,710 we stuck in a function of time. 899 00:51:47,710 --> 00:51:51,160 And we get out a list of Fourier coefficients. 900 00:51:51,160 --> 00:51:52,460 Same thing here. 901 00:51:52,460 --> 00:51:58,280 We put in a function of time, and we get out 902 00:51:58,280 --> 00:51:59,390 Fourier coefficients. 903 00:51:59,390 --> 00:52:04,550 And the Fourier coefficients are complex numbers associated 904 00:52:04,550 --> 00:52:07,910 with different frequencies. 905 00:52:07,910 --> 00:52:10,940 So let's say the middle coefficient 906 00:52:10,940 --> 00:52:13,280 that you get will be the coefficient 907 00:52:13,280 --> 00:52:15,530 for the constant term. 908 00:52:15,530 --> 00:52:17,870 This coefficient down here will be the coefficient 909 00:52:17,870 --> 00:52:20,840 for the minimum frequency, and that coefficient 910 00:52:20,840 --> 00:52:23,480 will be the coefficient for the maximum frequency, the most 911 00:52:23,480 --> 00:52:24,858 positive frequency. 912 00:52:29,470 --> 00:52:30,345 Does that make sense? 913 00:52:34,504 --> 00:52:37,920 AUDIENCE: [INAUDIBLE] 914 00:52:37,920 --> 00:52:40,010 MICHALE FEE: Ah, OK. 915 00:52:40,010 --> 00:52:44,320 So I was hoping to just kind of skip over that for now. 916 00:52:44,320 --> 00:52:47,750 But when you do a discrete Fourier transform, 917 00:52:47,750 --> 00:52:51,380 turns out that the coefficient for the most negative frequency 918 00:52:51,380 --> 00:52:54,170 is always exactly the same as the coefficient for the most 919 00:52:54,170 --> 00:52:58,130 positive frequency. 920 00:52:58,130 --> 00:53:01,100 And so they're just given in one-- 921 00:53:01,100 --> 00:53:03,950 they're both given in one element of the array. 922 00:53:06,490 --> 00:53:10,610 You could replicate that up here, 923 00:53:10,610 --> 00:53:12,050 but it would be pointless. 924 00:53:12,050 --> 00:53:14,780 And the length of the array would have to be n plus 1. 925 00:53:19,730 --> 00:53:21,215 Yes? 926 00:53:21,215 --> 00:53:24,200 AUDIENCE: [INAUDIBLE] 927 00:53:24,200 --> 00:53:25,410 MICHALE FEE: OK. 928 00:53:25,410 --> 00:53:26,010 Good. 929 00:53:26,010 --> 00:53:29,670 That question always comes up, and it's a great question. 930 00:53:32,530 --> 00:53:34,240 What we're trying to do is to come up 931 00:53:34,240 --> 00:53:39,410 with a way of representing arbitrary functions. 932 00:53:44,980 --> 00:53:49,530 So we can represent symmetric functions 933 00:53:49,530 --> 00:53:53,220 by summing together a bunch of cosines. 934 00:53:53,220 --> 00:53:55,890 We can represent antisymmetric functions 935 00:53:55,890 --> 00:53:58,450 by summing together a bunch of sines. 936 00:53:58,450 --> 00:54:01,290 But if we want to represent an arbitrary function, 937 00:54:01,290 --> 00:54:03,630 we have to use both cosines and sines. 938 00:54:10,080 --> 00:54:13,320 So we have this trick, though, where we can, 939 00:54:13,320 --> 00:54:15,870 instead of using sines and cosines, 940 00:54:15,870 --> 00:54:17,910 using these two separate functions, 941 00:54:17,910 --> 00:54:22,620 we can use a single function which is a complex exponential 942 00:54:22,620 --> 00:54:27,450 to represent things that can be represented by sums of cosines 943 00:54:27,450 --> 00:54:31,080 as well as things that can be represented as sums of signs. 944 00:54:31,080 --> 00:54:33,840 It's an arbitrary function. 945 00:54:33,840 --> 00:54:37,560 And the reason is because the complex exponential has 946 00:54:37,560 --> 00:54:40,200 both a cosine in it and a sine. 947 00:54:45,590 --> 00:54:50,960 So we can represent a cosine as a complex exponential 948 00:54:50,960 --> 00:54:53,180 with a positive frequency, meaning 949 00:54:53,180 --> 00:54:56,300 that it's a complex number that goes 950 00:54:56,300 --> 00:55:02,710 around this direction plus another function 951 00:55:02,710 --> 00:55:06,440 where the complex number is going around in this direction. 952 00:55:06,440 --> 00:55:12,800 So positive frequencies mean as time increases, 953 00:55:12,800 --> 00:55:14,780 this complex number is going around the unit 954 00:55:14,780 --> 00:55:16,100 circle in this direction. 955 00:55:16,100 --> 00:55:18,980 Negative frequencies mean the complex number's 956 00:55:18,980 --> 00:55:20,340 going around in this direction. 957 00:55:20,340 --> 00:55:26,410 And you can see that in order to represent a cosine, 958 00:55:26,410 --> 00:55:28,080 I need to have-- 959 00:55:28,080 --> 00:55:29,680 so let's see if I can do this. 960 00:55:29,680 --> 00:55:33,670 Here's my e to the-- here's my plus frequency going 961 00:55:33,670 --> 00:55:35,540 around this way. 962 00:55:35,540 --> 00:55:38,800 Here's my minus frequency going around this way. 963 00:55:38,800 --> 00:55:40,510 And you can see that I can represent 964 00:55:40,510 --> 00:55:47,530 a cosine if I can make the imaginary parts cancel. 965 00:55:47,530 --> 00:55:50,620 So if I have one function that's going around like this, 966 00:55:50,620 --> 00:55:52,750 another function that's going around like this. 967 00:55:52,750 --> 00:56:00,240 If I add them, then the imaginary part cancels. 968 00:56:00,240 --> 00:56:01,780 The sine cancels. 969 00:56:01,780 --> 00:56:05,410 This plus this is cosine plus cosine. 970 00:56:05,410 --> 00:56:07,390 i sine minus i sine. 971 00:56:07,390 --> 00:56:10,190 So the sines can-- the sine cancels. 972 00:56:10,190 --> 00:56:11,830 And what I'm left with is a sine. 973 00:56:11,830 --> 00:56:15,880 So represent a cosine as a sum of a function that 974 00:56:15,880 --> 00:56:21,700 has a positive frequency and a negative frequency. 975 00:56:21,700 --> 00:56:24,070 You can see that the y component, 976 00:56:24,070 --> 00:56:26,200 the imaginary component, cancels and all 977 00:56:26,200 --> 00:56:29,950 I'm left with is the cosine that's going across like this. 978 00:56:29,950 --> 00:56:33,620 So it's just a mathematical trick. 979 00:56:33,620 --> 00:56:35,270 Positive and negative frequencies 980 00:56:35,270 --> 00:56:43,210 are just a mathematical trick to make either the symmetric part 981 00:56:43,210 --> 00:56:47,260 of the function or antisymmetric part of the function cancel. 982 00:56:47,260 --> 00:56:52,840 So I can just use these positive and negative frequencies 983 00:56:52,840 --> 00:56:54,400 to represent any function. 984 00:56:54,400 --> 00:56:57,130 If I only had positive frequencies, 985 00:56:57,130 --> 00:56:59,620 I wouldn't be able to represent arbitrary functions. 986 00:57:03,720 --> 00:57:06,360 So just one more little thing that you 987 00:57:06,360 --> 00:57:11,460 need to know about the FFT algorithm. 988 00:57:11,460 --> 00:57:15,500 So remember we talked about if you have a function of time, 989 00:57:15,500 --> 00:57:20,200 negative times are over here, positive times are over here. 990 00:57:20,200 --> 00:57:23,230 You can put-- you can sample your function 991 00:57:23,230 --> 00:57:26,110 at different times and put those different samples 992 00:57:26,110 --> 00:57:27,430 into an array. 993 00:57:27,430 --> 00:57:30,880 Before you send this array of time samples 994 00:57:30,880 --> 00:57:33,370 to the FFT algorithm, you just need 995 00:57:33,370 --> 00:57:36,190 to swap the right half of the array 996 00:57:36,190 --> 00:57:38,710 with the left half of the array using a function called 997 00:57:38,710 --> 00:57:40,560 time shifted arrays. 998 00:57:43,370 --> 00:57:44,310 Don't worry about it. 999 00:57:44,310 --> 00:57:47,090 It's just the guts of the FFT algorithm 1000 00:57:47,090 --> 00:57:49,760 wants to have the positive times in the first half 1001 00:57:49,760 --> 00:57:52,850 and the negative times in the second half. 1002 00:57:52,850 --> 00:57:57,400 So you just do this. 1003 00:57:57,400 --> 00:58:04,970 Then you run the FFT function on this time shifted array. 1004 00:58:04,970 --> 00:58:07,690 And what it spits back is an array 1005 00:58:07,690 --> 00:58:10,750 with the positive frequencies in the first half 1006 00:58:10,750 --> 00:58:13,690 and the negative frequencies in the second half. 1007 00:58:13,690 --> 00:58:19,120 And you can just swap those back using the circshift again. 1008 00:58:19,120 --> 00:58:23,770 That is your spectrum. 1009 00:58:23,770 --> 00:58:25,420 Your spectral coefficients. 1010 00:58:25,420 --> 00:58:28,150 Your Fourier coefficients of this function. 1011 00:58:31,980 --> 00:58:33,685 Just MATLAB guts. 1012 00:58:33,685 --> 00:58:34,560 Don't worry about it. 1013 00:58:39,120 --> 00:58:42,430 So here's a piece of code that computes the Fourier 1014 00:58:42,430 --> 00:58:45,460 coefficients of a function. 1015 00:58:45,460 --> 00:58:47,410 So the first thing we're going to do 1016 00:58:47,410 --> 00:58:51,800 is define the number of points that we have in our array. 1017 00:58:51,800 --> 00:58:53,140 2048. 1018 00:58:53,140 --> 00:58:54,980 So it's a power of 2. 1019 00:58:54,980 --> 00:58:57,490 So the FFT algorithm runs fast. 1020 00:58:57,490 --> 00:59:01,940 We're figuring out-- we're going to write down a delta t. 1021 00:59:01,940 --> 00:59:05,470 In this case, it's one millisecond. 1022 00:59:05,470 --> 00:59:10,760 The sampling rate, the sampling frequency is just 1 1023 00:59:10,760 --> 00:59:11,720 over delta t. 1024 00:59:11,720 --> 00:59:14,750 So 1 kilohertz. 1025 00:59:14,750 --> 00:59:19,730 The array of times at which the function sampled 1026 00:59:19,730 --> 00:59:22,480 is just going from minus n over 2 1027 00:59:22,480 --> 00:59:26,390 to plus n over 2 minus 1 times delta t. 1028 00:59:29,870 --> 00:59:33,060 I'm defining the frequency of a sine wave. 1029 00:59:33,060 --> 00:59:37,260 And we're now getting the values of that cosine function 1030 00:59:37,260 --> 00:59:39,870 at those different times. 1031 00:59:39,870 --> 00:59:42,160 Does that make sense? 1032 00:59:42,160 --> 00:59:44,950 We're taking that function of time 1033 00:59:44,950 --> 00:59:48,910 and circularly shifting it by half the array. 1034 00:59:48,910 --> 00:59:55,210 So that's the circularly shifted, the swapped values 1035 00:59:55,210 --> 00:59:56,500 of our function y. 1036 00:59:56,500 --> 00:59:58,315 We stick that into the FFT function. 1037 01:00:00,870 --> 01:00:03,570 It gives you back the Fourier coefficients. 1038 01:00:03,570 --> 01:00:05,640 You just swap it again. 1039 01:00:08,510 --> 01:00:12,290 And that is the spectrum, the Fourier transform [INAUDIBLE] 1040 01:00:12,290 --> 01:00:12,790 signal. 1041 01:00:15,460 --> 01:00:17,250 And now you can write down a vector 1042 01:00:17,250 --> 01:00:22,463 of frequencies of each one of those Fourier coefficients. 1043 01:00:30,360 --> 01:00:34,770 Each one of those segments in that vector y-- 1044 01:00:34,770 --> 01:00:38,850 remember, there are 2,000 of them now, 2,048 of them-- 1045 01:00:38,850 --> 01:00:42,400 each one of those is the Fourier coefficient 1046 01:00:42,400 --> 01:00:46,150 of the function we put in at each one 1047 01:00:46,150 --> 01:00:47,560 of those different frequencies. 1048 01:00:52,120 --> 01:00:54,700 Does that make sense? 1049 01:00:54,700 --> 01:00:56,800 Now let's take a look at a few examples 1050 01:00:56,800 --> 01:00:59,570 of what that looks like. 1051 01:00:59,570 --> 01:01:03,000 So here is a function y of t. 1052 01:01:03,000 --> 01:01:09,230 It's cosine 2 pi f 0 t where f 0 is 20 hertz. 1053 01:01:09,230 --> 01:01:13,040 So it's just a cosine wave. 1054 01:01:13,040 --> 01:01:18,010 You run this code on it. 1055 01:01:18,010 --> 01:01:23,280 And what you get back is an array of complex numbers. 1056 01:01:23,280 --> 01:01:31,430 It has a real and imaginary part as a function of frequency. 1057 01:01:31,430 --> 01:01:34,745 And you get this cosine function. 1058 01:01:34,745 --> 01:01:38,870 It has two peaks, as promised. 1059 01:01:38,870 --> 01:01:44,090 It has a peak at plus 20 hertz and a peak at minus 20 hertz. 1060 01:01:46,630 --> 01:01:51,240 One of those peaks gives you an e 1061 01:01:51,240 --> 01:01:54,790 to the i omega t that goes this way at 20 hertz. 1062 01:01:54,790 --> 01:01:57,370 The other one gives you an e of the i omega t 1063 01:01:57,370 --> 01:01:59,650 that goes this way at 20 hertz. 1064 01:01:59,650 --> 01:02:04,700 And when you add them together, if I can do that, 1065 01:02:04,700 --> 01:02:06,430 it gives you a cosine. 1066 01:02:06,430 --> 01:02:08,973 It goes back and forth at 20 hertz. 1067 01:02:08,973 --> 01:02:09,959 That one. 1068 01:02:18,840 --> 01:02:20,100 Here's a sine wave. 1069 01:02:20,100 --> 01:02:24,770 y equals sine 2 pi f 0 t again at 20 hertz. 1070 01:02:24,770 --> 01:02:26,720 You run that code on it. 1071 01:02:26,720 --> 01:02:29,390 It gives you this. 1072 01:02:29,390 --> 01:02:30,980 Notice that-- OK, sorry. 1073 01:02:30,980 --> 01:02:32,600 Let me just point out one more thing. 1074 01:02:32,600 --> 01:02:37,400 In this case, the peaks are in the real part of y. 1075 01:02:37,400 --> 01:02:41,630 For the sine function, the real part is 0 1076 01:02:41,630 --> 01:02:43,310 and the peaks are in the imaginary part. 1077 01:02:43,310 --> 01:02:48,470 There's a plus i at minus 20 i over 2, 1078 01:02:48,470 --> 01:02:56,230 actually, at minus 20 hertz, a minus i at plus 20 hertz. 1079 01:02:56,230 --> 01:03:00,700 And what that does is when you multiply that coefficient times 1080 01:03:00,700 --> 01:03:06,050 e to the i omega t and that coefficient times whichever 1081 01:03:06,050 --> 01:03:07,550 the opposite one is. 1082 01:03:07,550 --> 01:03:10,560 One going this way, the other one going this way. 1083 01:03:10,560 --> 01:03:13,580 You can see that the real part now cancels. 1084 01:03:13,580 --> 01:03:18,755 And what you're left with is the sine part that doesn't cancel. 1085 01:03:21,460 --> 01:03:24,830 And that is this function sine omega t. 1086 01:03:31,508 --> 01:03:35,160 Any questions about that? 1087 01:03:35,160 --> 01:03:36,342 That's kind of boring. 1088 01:03:36,342 --> 01:03:38,550 We're going to put more interesting functions in here 1089 01:03:38,550 --> 01:03:39,610 soon. 1090 01:03:39,610 --> 01:03:43,110 But I just wanted you to see what this algorithm does 1091 01:03:43,110 --> 01:03:47,722 on the things that we've been talking about all along. 1092 01:03:47,722 --> 01:03:49,430 And it gives you exactly what you expect. 1093 01:03:52,330 --> 01:03:57,850 Remember, we can write down any arbitrary function 1094 01:03:57,850 --> 01:04:02,450 as a sum of sines and cosines. 1095 01:04:04,970 --> 01:04:09,660 Which means we can write down any arbitrary function 1096 01:04:09,660 --> 01:04:21,870 as a sum of these little peaks and these peaks 1097 01:04:21,870 --> 01:04:25,580 at different frequencies. 1098 01:04:25,580 --> 01:04:26,840 Does that make sense? 1099 01:04:26,840 --> 01:04:32,320 So all we have to do is find these coefficients, 1100 01:04:32,320 --> 01:04:34,960 these peaks, what values of these different peaks 1101 01:04:34,960 --> 01:04:39,890 to stick in to reconstruct any arbitrary function. 1102 01:04:39,890 --> 01:04:43,800 And we're going to do a lot of that in the next lecture. 1103 01:04:43,800 --> 01:04:47,210 We're going to look at what different functions here look 1104 01:04:47,210 --> 01:04:50,570 like in the Fourier domain. 1105 01:04:50,570 --> 01:04:54,140 We're going to do that for some segments like a square pulse, 1106 01:04:54,140 --> 01:05:00,660 for trains of pulses, for Gaussian, 1107 01:05:00,660 --> 01:05:02,250 for all kinds of different functions. 1108 01:05:02,250 --> 01:05:04,380 And then using the convolution theorem, 1109 01:05:04,380 --> 01:05:06,990 you can actually just predict in your own mind 1110 01:05:06,990 --> 01:05:11,610 what different combinations of those functions will look like. 1111 01:05:11,610 --> 01:05:14,760 So I want to end by talking about one other really 1112 01:05:14,760 --> 01:05:18,495 critical concept called the power spectrum. 1113 01:05:18,495 --> 01:05:22,020 And it's basically usually what you 1114 01:05:22,020 --> 01:05:28,470 do when you compute the Fourier transform of a function 1115 01:05:28,470 --> 01:05:32,790 is to figure out what the power spectrum is. 1116 01:05:32,790 --> 01:05:34,890 The simple answer is that all you do 1117 01:05:34,890 --> 01:05:37,140 is you square this thing. 1118 01:05:37,140 --> 01:05:39,510 Take the magnitude squared. 1119 01:05:39,510 --> 01:05:41,670 But I'm going to build up to that a little bit. 1120 01:05:44,250 --> 01:05:45,720 So it's called the power spectrum. 1121 01:05:45,720 --> 01:05:50,333 But first we need to understand what we mean by power. 1122 01:05:50,333 --> 01:05:51,750 So we're going to think about this 1123 01:05:51,750 --> 01:05:55,050 in the context of a simple electrical circuit. 1124 01:05:55,050 --> 01:05:57,930 Let's imagine that this function that we're 1125 01:05:57,930 --> 01:06:00,810 computing the Fourier transform of, imagine 1126 01:06:00,810 --> 01:06:02,970 this function is voltage. 1127 01:06:02,970 --> 01:06:05,130 That's where this idea comes from. 1128 01:06:05,130 --> 01:06:07,350 Imagine that this function is the voltage 1129 01:06:07,350 --> 01:06:09,540 that you've measured somewhere in a circuit. 1130 01:06:09,540 --> 01:06:11,280 Let's say in this circuit right here. 1131 01:06:11,280 --> 01:06:14,570 Or current, either way. 1132 01:06:14,570 --> 01:06:19,670 So when you have current flowing through this circuit, 1133 01:06:19,670 --> 01:06:23,060 you can see that sinusoid-- that some oscillatory 1134 01:06:23,060 --> 01:06:25,670 current, some cosine, that drives 1135 01:06:25,670 --> 01:06:27,830 current through this resistor. 1136 01:06:27,830 --> 01:06:33,470 And when current flows to a resistor, it dissipates power. 1137 01:06:33,470 --> 01:06:35,690 And the power dissipated in a resistor 1138 01:06:35,690 --> 01:06:39,110 is just the current times the voltage drop 1139 01:06:39,110 --> 01:06:42,040 across that resistor. 1140 01:06:42,040 --> 01:06:43,780 That means that the power-- 1141 01:06:43,780 --> 01:06:45,430 now, remember, Ohm's law tells you 1142 01:06:45,430 --> 01:06:49,090 that current is just voltage divided by resistance. 1143 01:06:49,090 --> 01:06:50,920 So this is v divided by r. 1144 01:06:50,920 --> 01:06:57,090 So the power is just v squared divided by r. 1145 01:06:57,090 --> 01:07:02,100 So if the voltage is just a sine wave at frequency omega, 1146 01:07:02,100 --> 01:07:08,890 then v is some coefficient, some amplitude at that 1147 01:07:08,890 --> 01:07:11,490 frequency times cosine omega t. 1148 01:07:11,490 --> 01:07:18,820 We can write that voltage using Euler's equation as 1/2 e 1149 01:07:18,820 --> 01:07:22,570 to the minus i omega t plus 1/2 e to the plus i omega t. 1150 01:07:26,110 --> 01:07:29,940 And let's calculate the power associated with that voltage. 1151 01:07:29,940 --> 01:07:37,270 Well, we have to average over one cycle of that oscillation. 1152 01:07:37,270 --> 01:07:39,780 So the average power is just given 1153 01:07:39,780 --> 01:07:43,810 by the square magnitude of the Fourier transform [INAUDIBLE].. 1154 01:07:43,810 --> 01:07:46,260 So let's just plug this into here. 1155 01:07:46,260 --> 01:07:50,130 And what you see is that the power at a given frequency 1156 01:07:50,130 --> 01:07:54,690 omega is just that coefficient magnitude squared over 1157 01:07:54,690 --> 01:08:03,280 resistance times 1/2 e to the minus i omega t magnitude 1158 01:08:03,280 --> 01:08:06,370 squared plus 1/2 e to the plus i over i 1159 01:08:06,370 --> 01:08:09,320 omega t magnitude squared. 1160 01:08:09,320 --> 01:08:14,220 And that's just equal to 1 over r. 1161 01:08:14,220 --> 01:08:18,979 That coefficient magnitude squared over 2. 1162 01:08:18,979 --> 01:08:22,960 So you can see that the power dissipated 1163 01:08:22,960 --> 01:08:29,950 by this sinusoidal voltage is just 1164 01:08:29,950 --> 01:08:32,590 that magnitude squared over 2. 1165 01:08:36,790 --> 01:08:41,500 So we can calculate the power dissipated in any resistor 1166 01:08:41,500 --> 01:08:44,109 simply by summing up the [INAUDIBLE] magnitude 1167 01:08:44,109 --> 01:08:46,979 of those coefficients. 1168 01:08:46,979 --> 01:08:50,930 So let's look at that in a little more detail. 1169 01:08:50,930 --> 01:08:55,069 So let's think for a moment about the energy that 1170 01:08:55,069 --> 01:09:00,580 is dissipated by a signal. 1171 01:09:00,580 --> 01:09:03,939 So energy is just the integral over time. 1172 01:09:03,939 --> 01:09:05,740 Power is per unit time. 1173 01:09:05,740 --> 01:09:07,630 Total energy is just the integral 1174 01:09:07,630 --> 01:09:10,300 of the power over time. 1175 01:09:10,300 --> 01:09:14,500 So power is just equal to v squared over r. 1176 01:09:14,500 --> 01:09:16,439 So I'm just going to substitute that in there. 1177 01:09:16,439 --> 01:09:18,729 So the energy of a signal is just 1 1178 01:09:18,729 --> 01:09:23,200 over r times the integral of v squared over time. 1179 01:09:28,850 --> 01:09:32,140 Now, there's an important theorem 1180 01:09:32,140 --> 01:09:34,720 in complex analysis called Parseval's theorem 1181 01:09:34,720 --> 01:09:41,560 that says that the integral over the square of the coefficients 1182 01:09:41,560 --> 01:09:46,550 in time is just equal to the integral 1183 01:09:46,550 --> 01:09:49,990 of the square magnitude coefficients in frequency. 1184 01:09:54,310 --> 01:09:56,650 So what that's saying is that it's 1185 01:09:56,650 --> 01:09:59,500 just the same as the total power in the signal 1186 01:09:59,500 --> 01:10:03,520 or the total energy in a signal if you represent it in the time 1187 01:10:03,520 --> 01:10:08,190 domain is just the same as the total energy in the signal 1188 01:10:08,190 --> 01:10:11,590 if you look at it in the frequency domain. 1189 01:10:11,590 --> 01:10:15,400 And what that's saying is that the sum of all the 1190 01:10:15,400 --> 01:10:21,650 squared temporal components is just 1191 01:10:21,650 --> 01:10:27,710 this equal to the sum of all the squared frequency components. 1192 01:10:27,710 --> 01:10:31,040 And what that means is that you can 1193 01:10:31,040 --> 01:10:35,210 see that each of these frequency components, each component 1194 01:10:35,210 --> 01:10:37,700 in frequency contributes independently 1195 01:10:37,700 --> 01:10:40,940 to the power in the signal. 1196 01:10:40,940 --> 01:10:44,210 What that means is that you can think-- 1197 01:10:44,210 --> 01:10:46,940 so you can think of the total energy 1198 01:10:46,940 --> 01:10:50,870 in the signal as just the integral over all frequencies 1199 01:10:50,870 --> 01:10:53,900 of this quantity here that we call the power spectrum. 1200 01:10:58,400 --> 01:11:00,230 And so we'll often take a signal, 1201 01:11:00,230 --> 01:11:02,240 calculate the Fourier components, 1202 01:11:02,240 --> 01:11:06,070 and plot the area of the Fourier transform, 1203 01:11:06,070 --> 01:11:08,888 the square magnitude of the Fourier transform. 1204 01:11:08,888 --> 01:11:10,430 And that's called the power spectrum. 1205 01:11:13,550 --> 01:11:17,470 And I've already said the total variance of the signal in time 1206 01:11:17,470 --> 01:11:19,940 is the same as the total variance of the signal 1207 01:11:19,940 --> 01:11:22,020 in the frequency domain. 1208 01:11:22,020 --> 01:11:26,170 So mathy people talk about the variant of a signal. 1209 01:11:26,170 --> 01:11:29,120 The more engineering people talk about the power in the signal. 1210 01:11:29,120 --> 01:11:31,120 But they're really talking about the same thing. 1211 01:11:36,830 --> 01:11:39,063 So let's take this example that we just looked at 1212 01:11:39,063 --> 01:11:40,355 and look at the power spectrum. 1213 01:11:43,830 --> 01:11:46,150 So that's a cosine function. 1214 01:11:46,150 --> 01:11:47,175 It has these two peaks. 1215 01:11:52,860 --> 01:11:56,310 Let me just point out one more important thing. 1216 01:11:56,310 --> 01:11:59,950 For real functions, so in this class, 1217 01:11:59,950 --> 01:12:03,300 we're only going to be talking about real functions of time. 1218 01:12:03,300 --> 01:12:07,260 For real functions, the square magnitude of the Fourier 1219 01:12:07,260 --> 01:12:11,840 transform is symmetric. 1220 01:12:11,840 --> 01:12:15,090 So you can see here if there is a peak 1221 01:12:15,090 --> 01:12:17,450 in the positive frequencies, there's 1222 01:12:17,450 --> 01:12:21,180 an equivalent peak in the negative frequencies. 1223 01:12:21,180 --> 01:12:25,540 So when we plot the power spectrum of a signal, 1224 01:12:25,540 --> 01:12:29,680 we always just plot the positive side. 1225 01:12:29,680 --> 01:12:31,370 And so here's what that looks like. 1226 01:12:31,370 --> 01:12:36,810 Here is the power spectrum of a cosine signal. 1227 01:12:36,810 --> 01:12:39,510 And it's just a single peak. 1228 01:12:39,510 --> 01:12:42,740 So in that case, it was a cosine at 20 hertz. 1229 01:12:42,740 --> 01:12:45,861 You get a single peak at 20 hertz. 1230 01:12:49,750 --> 01:12:54,300 What does it look like for a sine function? 1231 01:12:54,300 --> 01:12:56,330 What is the power spectrum of a sine function? 1232 01:12:56,330 --> 01:12:59,720 Remember, in that case, it was the real part was 0 1233 01:12:59,720 --> 01:13:02,180 and the imaginary part had a plus peak here 1234 01:13:02,180 --> 01:13:03,650 and a minus peak here. 1235 01:13:03,650 --> 01:13:05,990 What does the spectrum of that look like? 1236 01:13:08,670 --> 01:13:09,220 Right. 1237 01:13:09,220 --> 01:13:15,250 The square magnitude of i is just 1. 1238 01:13:15,250 --> 01:13:17,890 Magnitude squared of i is just 1. 1239 01:13:21,550 --> 01:13:24,870 So the power spectrum of a sine function 1240 01:13:24,870 --> 01:13:27,520 looks exactly like this. 1241 01:13:27,520 --> 01:13:29,200 Same as a cosine. 1242 01:13:29,200 --> 01:13:30,130 Makes a lot of sense. 1243 01:13:30,130 --> 01:13:32,650 Sine and cosine are exactly the same function. 1244 01:13:32,650 --> 01:13:38,280 One's just shifted by a quarter period. 1245 01:13:41,020 --> 01:13:43,270 So it has to have the same power spectrum. 1246 01:13:43,270 --> 01:13:46,560 It has to have the same power. 1247 01:13:46,560 --> 01:13:49,080 Let's take a look at a different function of time. 1248 01:13:49,080 --> 01:13:50,670 Here's a train of delta functions. 1249 01:13:50,670 --> 01:13:54,660 So we just have a bunch of peaks spaced regularly 1250 01:13:54,660 --> 01:13:55,710 at some period. 1251 01:13:55,710 --> 01:13:56,400 I think it was-- 1252 01:13:56,400 --> 01:13:58,140 I forget the exact number here. 1253 01:13:58,140 --> 01:14:01,620 But it's around 10-ish hertz. 1254 01:14:04,820 --> 01:14:08,080 Fourier transform of a train of delta functions 1255 01:14:08,080 --> 01:14:11,550 is another train of delta functions. 1256 01:14:11,550 --> 01:14:14,260 Pretty cool. 1257 01:14:14,260 --> 01:14:18,530 The period in the time domain is delta t. 1258 01:14:18,530 --> 01:14:23,330 The period in the Fourier domain is 1 over delta t. 1259 01:14:23,330 --> 01:14:27,250 That's another really important Fourier transform pair for you 1260 01:14:27,250 --> 01:14:27,750 to know. 1261 01:14:27,750 --> 01:14:30,830 So the first Fourier transform pair that you need to know 1262 01:14:30,830 --> 01:14:35,040 is that a constant in the time domain is a delta function 1263 01:14:35,040 --> 01:14:36,330 in the frequency domain. 1264 01:14:36,330 --> 01:14:38,900 A delta function in the time domain 1265 01:14:38,900 --> 01:14:42,670 is a constant in the frequency domain. 1266 01:14:42,670 --> 01:14:45,530 A train of delta functions in the time domain 1267 01:14:45,530 --> 01:14:48,890 is a train of functions in the frequency domain and vice 1268 01:14:48,890 --> 01:14:50,720 versa. 1269 01:14:50,720 --> 01:14:52,190 And there's a very simple relation 1270 01:14:52,190 --> 01:14:54,270 between the period in the time domain 1271 01:14:54,270 --> 01:14:56,480 and the period in the frequency domain. 1272 01:14:56,480 --> 01:15:01,020 What does the power spectrum of this train of delta functions 1273 01:15:01,020 --> 01:15:01,520 look like? 1274 01:15:09,160 --> 01:15:12,435 It's just the square magnitude of this. 1275 01:15:12,435 --> 01:15:14,060 So it just looks like a bunch of peaks. 1276 01:15:17,620 --> 01:15:20,230 So here's another function. 1277 01:15:20,230 --> 01:15:21,610 A square wave. 1278 01:15:21,610 --> 01:15:27,110 This is exactly the same function that we started with. 1279 01:15:27,110 --> 01:15:28,700 If you look at the Fourier transform 1280 01:15:28,700 --> 01:15:35,810 of the imaginary part of 0, the real part has these peaks. 1281 01:15:35,810 --> 01:15:40,180 So the Fourier transform-- so these are now the coefficients 1282 01:15:40,180 --> 01:15:43,900 that you would put in front of your different cosines 1283 01:15:43,900 --> 01:15:49,100 at different frequencies to represent the square wave. 1284 01:15:49,100 --> 01:15:53,420 But what it looks like is positive peak for the lowest 1285 01:15:53,420 --> 01:16:01,030 frequency, negative peak for the next harmonic, positive peak, 1286 01:16:01,030 --> 01:16:04,750 and gradually decreasing amplitudes. 1287 01:16:04,750 --> 01:16:07,490 The power spectrum of this-- 1288 01:16:07,490 --> 01:16:12,650 oh, and one more point is that if you look at the Fourier 1289 01:16:12,650 --> 01:16:17,570 transform of a higher frequency square wave, 1290 01:16:17,570 --> 01:16:22,150 you can see that those peaks move apart. 1291 01:16:22,150 --> 01:16:24,060 So you can transform. 1292 01:16:24,060 --> 01:16:27,840 So higher frequencies in the time domain, stuff happening 1293 01:16:27,840 --> 01:16:32,730 faster in the time domain, is associated 1294 01:16:32,730 --> 01:16:37,540 with things moving out to higher frequencies in the frequency 1295 01:16:37,540 --> 01:16:38,750 domain. 1296 01:16:38,750 --> 01:16:42,190 You can see that the same function higher frequencies 1297 01:16:42,190 --> 01:16:46,420 has the same Fourier transform but with the components spread 1298 01:16:46,420 --> 01:16:48,940 out to higher frequencies. 1299 01:16:48,940 --> 01:16:51,920 And the power spectrum looks like this. 1300 01:16:51,920 --> 01:16:56,500 And notice that one more final point here 1301 01:16:56,500 --> 01:17:00,190 is that when you look at power spectra, often signals 1302 01:17:00,190 --> 01:17:05,050 can have frequency components that 1303 01:17:05,050 --> 01:17:09,740 are very small so that it's hard to see them on a linear scale. 1304 01:17:09,740 --> 01:17:12,850 And so we actually plot them in this method. 1305 01:17:12,850 --> 01:17:15,040 You plot them in units of decibels. 1306 01:17:15,040 --> 01:17:17,370 And I'll explain what those are the next time. 1307 01:17:17,370 --> 01:17:20,200 But that's another representation of the power 1308 01:17:20,200 --> 01:17:23,200 spectrum of a signal. 1309 01:17:23,200 --> 01:17:25,550 OK, so that's what we've covered. 1310 01:17:25,550 --> 01:17:29,940 And we're going to continue with the game plan next time.