 After delving into a bit of pure mathematics in the last few lectures, I want to look at what all this has to do with the Fourier transform. So what tools do we have in our arsenal? We have sine waves and cosine waves. We've learned about how we can shift a signal space by adding sine and cosine waves together. And we've found a new shorthand way of doing mathematical operations with sines and cosines by using the three forms of a complex number. We're now going to use all of these tools as we look at the secret of how the Fourier transform actually works. This secret is called convolution. But before we start to talk about convolution, let's first remind ourselves of what Fourier said about signals, or as he called them, functions. Any function of a variable, whether continuous or discontinuous, can be expanded in a series of sines of multiples of the variable. So in other words, Fourier saw any signal as a lot of sine waves, each with its own frequency, phase and amplitude, all added together. This is what a transform is, a way of building up a signal out of simpler building blocks. In Fourier's case, he built his signals out of sine waves, but Fourier was by no means the only person to invent a transform. There are many other types of transforms. The Laplace transform, for example, overcomes a big disadvantage of the Fourier transform. One problem with the Fourier transform, which we'll look at later on, is that it assumes that signals repeat themselves forever, which clearly many of them don't. This is where a Laplace transform has a distinct advantage. Whereas Fourier assumes that signals are made up of a collection of sine waves with a constant amplitude, Laplace constructs his signals from a collection of decaying sine waves, which decay to nothing, or near enough, long before forever is reached. Another type of transform is the wavelet transform. A wavelet is a little burst of sine wave, which starts at zero amplitude, grows to some value, then decays back to zero again. By adding lots of wavelets together, changing the point in time at which each wavelet starts, the shape of its envelope and its frequency, you can make up any signal you like, just as you can with Fourier's sine waves. So Fourier, building his signals as he did out of sine waves, claims that he could take any signal, break it down into its constituent waves, and tell us what the properties of each wave were. We discovered back at the beginning of the course that a sine wave has three properties, frequency, amplitude, and phase. So at the end of Fourier's transform, we expect to end up with a list of waves containing three columns for each wave, one for frequency, one for amplitude, and one for phase. So what is convolution? Convolution is the mathematical equivalent of looking for your slippers. I have no idea where I put my slippers, so I have to search in every room. I know what they look like, so I'll recognise them when I see them. What happens if I find my wife's slippers first? Well, I know they're not mine because my wife's slippers are grey and mine are purple. Here are my slippers! I wonder how they got there. Applying this analogy to the world of signals, my slippers are like the sine wave that we're looking for within our signal. I'll know when I find it, as I know what frequency I'm looking for, but I don't know where or other when it occurs in the signal. In other words, I have no idea what its phase is, so just as I have to search every room in my house for my slippers, I have to search every phase in my signal for the sine wave that I'm looking for. To demonstrate how convolution works, let's look at a more visual example. By this point in the course, you probably know what I look like. Here I am. Now, imagine that I was in the middle of a crowd of people. How would you find me? Well, one way you could do it would be to compare each person in the crowd with the image of me that you have in your memory. Let's call this the test image. If we slide the test image over all the people in the crowd, the moment the test image and the real me converge, you'll know that you have found me. To find the phase of the sine wave with the frequency we are looking for in our signal, we do exactly the same thing. We slide or convolve a cosine wave of the same frequency over the signal. Let's call this cosine wave the test wave. Now, why am I using a cosine wave and not a sine wave? Well, it's simply a matter of convention. As far as the maths is concerned, I could use either. After all, sine waves and cosine waves are the same wave, just with a 90 degree phase difference between them. However, very soon you're going to understand the Fourier transform formula. And that formula is written in the language of complex numbers. Therefore, I want to keep things consistent. When writing a complex number, we always start with the real part, which corresponds to the cosine component. So just as complex numbers begin with the cosine component, so will I. So here's our test wave, a cosine wave, and I'm slowly going to slide it over my signal by increasing its phase. The moment the test wave converges with the sine wave we are looking for, we know that we have found the phase of the sine wave within our signal. Now, involving the two waves in this manner is all very well for us humans. We can easily identify by sight when the two waves converge. But how could we detect the point of convergence mathematically? How would a computer do it? What we need is to somehow generate a number, a score that indicates how well the two signals match. When they don't match at all, the score needs to be low. When they match completely, the score needs to be high. Well, one way we could do this would be as follows. Let's reset our signal to its initial position. Now, I'm going to multiply each point on our test wave with each point on the signal and plot the multiplied signal on a new graph. At an angle of 0 degrees, our test wave has a value of 1 and our signal has a value of 0.17. So we multiply these two points together which gives us 0.17 and we plot that new point here. At an angle of 2 degrees, our test wave has a value of 0.98 and our signal has a value of 0.34. So we multiply those two points together which gives us 0.34 and we plot that point here. At an angle of 4 degrees, our test wave has a value of 0.94 and our signal has a value of 0.5. So we multiply those two points together giving us 0.47 and we plot that point here. We do this for all the points which gives us a new multiplied signal shown here in green. We then measure the area enclosed by the multiplied graph. This gives us a single value which is the score of how well matched the test wave and the sine wave which I'm looking for within my signal are. The score for this initial position of the test wave is 31. Now let's increase the phase a little and do the whole operation again. Each point on the test wave is multiplied by each point on the signal and the resulting area enclosed by the graph gives us the score of how well matched the signal and test wave are. If I animate the process, look at what happens to the score. As the waves move closer and closer to being in phase with each other the area enclosed by the multiplied graph increases meaning that the score increases too. When the two waves are in phase, the score reaches its highest value 180 in the case of these two waves then begins to fall off again as the two waves slip out of phase. When the two waves are at their most out of phase the score is at its lowest value minus 180 in the case of these two waves. So when my test wave reaches a phase of 80 degrees the two signals match perfectly and the score is at its highest value. I have found the phase of the sine wave in my signal. That's all very well for a simple signal like this but what about a more complicated signal? What about a signal made up of more than one sine wave? Which sine waves are present in this signal? What are their frequencies? What are their phases? And what are their amplitudes? Well just like the slippers, we have to look for them. Let's start by convolving a test wave with a frequency of one and an amplitude of one over our signal. When we multiply all the points on our test wave by all the points on our signal and plot them on the multiplied graph it doesn't matter what the phase is there is always as much of the green line above the x-axis as there is below it. This means that when we calculate the total area enclosed by the graph we'll always get a score of zero. This indicates that our signal does not contain a sine wave with a frequency of one. Let's try convolving a test wave with a frequency of two over our signal. This time as we increase the phase we can see how the multiplied signal shifts up and down over the x-axis. When we measure the area enclosed by the multiplied graph we see that the score is not zero. So our signal does contain a sine wave with a frequency of two in it. Finding the point at which the score is at its greatest tells us that the phase of this sine wave is 30 degrees. Let's try convolving a test wave with a frequency of three over our signal. Again the multiplied signal shifts up and down over the x-axis. So our signal does contain a sine wave with a frequency of three in it. The score is at its highest point at 60 degrees. So the phase of this sine wave within our signal is 60 degrees and so on. If I were to try a test frequency of four on this wave I would get zero again as this signal does not contain a sine wave with a frequency of four. So whenever we try a frequency that does not exist in the signal we get a value of zero in the score no matter what the phase. And when a frequency does exist in the signal we get a score that is non-zero. The moment we find the point at which the score is at its maximum we have found the phase of the sine wave we are looking for. While we've been searching our signal for sine waves we've found their frequencies and their phases and we haven't said anything about their amplitudes. Well that's just what the score is. The maximum score we found for each frequency is proportional to the amplitude of the sine wave we are looking for. It doesn't actually tell us what the original amplitude was but it does tell us what its relative contribution is to the overall signal. Just for curiosity's sake what will we have to do to make the score equal to the actual contribution of this particular sine wave in the original signal? Well we'd have to divide the score by a half of the period of the signal. The period of this signal is 360 degrees so a half of the period will be 180 degrees. For this test wave with a frequency of three the maximum score was 72. So if we divide 72 by 180 we get 0.4 which is the actual amplitude of this frequency within the signal. However as we're only concerned with splitting the signal apart into its constituent sine waves the relative contribution or as I called it the score is good enough for now. So our signal is made up of two waves the first has a frequency of two at a phase of 30 degrees and a relative amplitude of 90 the second has a frequency of three at a phase of 60 degrees and a relative amplitude of 72. When these two waves are added together we get a result which looks like our signal. So using convolution we've managed to deconstruct our signal into its constituent sine waves we have just found our first Fourier series. Now Fourier was a wildly old mathematician although we knew he could get his answer using convolution he could see how hard it had to work to get there Fourier noticed there was a slightly quicker way of doing it What I'm about to show you is not the fast Fourier transform we'll take a look at that in a later lecture What I want to demonstrate here is how we don't actually need to do the whole convolution operation i.e. slide our test wave all the way over our signal to get our result We just saw how the score increases to a maximum the nearer the test wave and the sine wave we're looking for in our signal are to being in phase with each other If I trace the line which the score value describes as we convolve the two waves just look at which function that line makes It's a phase shifted sine wave with the same phase as the sine wave we are looking for within our signal But we know that any phase shifted sine wave can be described by adding a non phase shifted cosine wave and a non phase shifted sine wave at the same frequency but different amplitudes So instead of having to perform the entire convolution all we need to do is multiply our signal firstly by a cosine wave and then by a sine wave then use Pythagoras and the inverse tangent mode to calculate the amplitude and phase shift from the two scores for each wave So let's do just that for our signal The first frequency that was present in our signal was 2 So let's start with that frequency If I calculate the score using a non phase shifted cosine wave as my test wave I get 78 If I calculate the score using a non phase shifted sine wave as my test frequency I get 45 Using Pythagoras the square root of 78 squared plus 45 squared equals 90 Using the inverse tangent rule inverse tan of 45 divided by 78 equals 30 degrees the same answer as before The second frequency present in my signal was 3 So let's calculate for that frequency If I calculate the score using a non phase shifted cosine wave as my test wave I get 36 If I calculate the score using a non phase shifted sine wave as my test wave I get 62 The square root of 36 squared plus 62 squared equals 72 Using the inverse tangent rule inverse tan of 62 divided by 36 equals 60 degrees again the same answer as before So let's review what we just did Firstly we multiplied every point of our signal by every point on a cosine wave at a known frequency take as a multiplied cosine signal which we plotted on a new graph We then found the area enclosed by that graph which we used as a score or a relative amplitude for the cosine component at that frequency We then multiplied every point of our signal by every point on a sine wave at the same frequency as the cosine wave to get a multiplied sine signal which we plotted on a new graph We then found the area under that graph which we used as a score or relative amplitude for the sine components of that frequency We then repeated the whole process again and again at many different frequencies until we had found all the frequencies within our signal So how can we express what we've just done in a mathematical language? Well, we start with a signal I said at the beginning of the course that I would demonstrate how Fourier worked by using sound signals Sound is a signal whose amplitude changes over time So let's call our signal x of t The t denoting that the variable in our signal is time First of all, in stage one we multiply the signal by a cosine wave But the x axis of a cosine wave is usually an angle Back in the lecture on phase we saw how we could scale our x axis to fit the 360 degrees of a circle by multiplying our time value by the frequency we are looking for and then multiplying the result by 360 degrees Well, that's all very well if we were working in degrees like we have been until now However, remember that when your calculator calculates the cosine or sine of a value using the infinite series we saw in the lecture on Euler's identity it is actually working in radians So we have to convert the time value not into degrees but into radians Instead of there being 360 degrees in a circle we say there are 2 pi radians in a circle So we multiply our time value t by the frequency f we are looking for and then by 2 pi radians So in stage one we multiply our signal x of t by the cosine of 2 pi f t Here is what I get when I multiply the sound signal coming from the violin we passed on the way to the cosine wave Now we need to find the area under the graph of our multiplied signal to obtain the score which represents the amplitude of the contribution of this cosine wave to the overall signal But how do we do that? If we wanted to calculate the area of a rectangle we would take the height of the rectangle and multiply it by its width But our signal is not a rectangle Is there any way to make it into one? Well we could make it into lots of rectangles or rather we could break it down into lots of slices and treat each slice as if it were a rectangle and then add the areas of all the rectangles together You can see how the blocky rectangles do approximate the shape of the multiplied signal If we reduce the width of each rectangle and increase the number of rectangles then we get a better approximation The thinner the rectangles and the more of them there are the closer we get to the actual value of the area under the graph If we were to make each rectangle infinitely thin and increase the number of rectangles to infinity we could calculate the area exactly This is known as integration which we represent mathematically by an integration sign So to find the area under the multiplied cosine graph we take the integral of our multiplied signal x of t times cosine 2 pi f of t with respect to t i.e. each slice is t seconds thick where the difference between one t and the next t is infinitely small We write this mathematically as the integral of x of t times cosine 2 pi f of t dt But an integral has to have limits t has to start somewhere and end somewhere Well, in a repeating signal such as the one we have here it's enough to look at one cycle of the signal as after that cycle is complete the signal will just repeat itself In our signal here you can see that everything repeats itself every 3.5 milliseconds So we say that the period of the signal is 3.5 milliseconds and we integrate it between time equals 0 and time equals 3.5 milliseconds Now as this is a repeating signal it doesn't actually matter where we set our limits so long as we integrate over exactly one cycle Imagine this signal went on forever Imagine it didn't have a beginning or an end just as the signal will repeat itself again and again and again into the future so it has already repeated itself again and again since the ancient past So just as our graph here looks from now when time is 0 into the future we could also look back into the past when time was less than 0 and the signal would still look the same Instead of integrating from 0 to 3.5 milliseconds we could integrate from minus 1.75 milliseconds to 1.75 milliseconds and the result of the integral will still come out the same so long as the period over which we integrated remained exactly 3.5 milliseconds which is the period of this particular signal Now, not all signals have a period of 3.5 milliseconds How do we write the limits of the integration for an arbitrary signal with a period of p seconds? Well, if we always ensure that our time equals 0 point is exactly at the centre of the graph then we need to integrate from a point in time that is minus 1.5 of the period until a point in time which is plus 1.5 of the period so our integration limits become minus p over 2 and plus p over 2 But why is that important? Why not just integrate from 0 to the period p like we did before? What's all this dividing the period by 2 business? We'll answer that question towards the end of the lecture So now we have the score for how much the cosine wave at this first frequency contributes to our overall signal The next stage is to repeat all the steps we just took only this time using a sine wave at the same frequency We take our signal multiply it by a sine wave and then integrate to find the area under the graph giving us the score which represents the amplitude of the contribution of the sine wave to the overall signal So now we have two separate integrals which I'm going to call and the sine integral But having to deal with two separate equations is rather messy Is there any way we could combine them into one integral? Could we, for example, add the two integrals together? Well, unfortunately, no That will give us a result that is simply the sum of the areas under both graphs which would give us the wrong answer Remember, in order to work out the phase of the particular sine wave we are looking for or, in other words, when exactly it occurs in our signal we have to keep the scores for the cosine and sine components separate But how can we do that and still combine our two integrals into one equation? Well, in the last few lectures we've been talking about a special number that does just that The imaginary number i If we multiply one of the integrals by i we could have our cake and eat it, so to speak But which integral? Well, the integral with the sine in it of course, just like Euler's formula multiplies the sine term by i So now, if we multiply the sine integral by i we could add the two integrals together or even take one away from the other, and it wouldn't make any difference to the result as the i would keep them separate So, what should we do? Add or take away? Well, the answer is actually more political and mathematical political in the sense that whereas mathematically it doesn't really matter which sine we use everyone has to agree to do the same thing to avoid confusion In this course we're learning about the Fourier transform which is a method of breaking down signals into their constituent sine waves It sounds to reason therefore that if Fourier knows how to break signals down he can also take those sine waves and put them back together again to recover the signal, and indeed he can, using the inverse Fourier transform We don't have time in this course to look in any detail at the inverse Fourier transform, but I will just say that the equations for the Fourier and inverse Fourier transforms look quite similar So, to differentiate between them the convention has grown up we denote the Fourier transform with a minus sign and the inverse Fourier transform with a plus sign between the integrals So, not wanting to flat convention let's combine these two integrals together by putting a minus sign between them Mathematicians like to be tidy If they can they like to reduce their equations to be as short as possible For example do we really need the two integration signs? After all as we saw integration is simply adding an infinite number of rectangular areas together Each of these integrals simply gives us a number So, for the sake of the following example let's do away with all the signs and cosines a second and deal with some simple numbers Imagine I wanted to do the following calculation 9 plus 11 minus 2 plus 3 9 plus 11 is 20 and 2 plus 3 is 5 So, 20 minus 5 equals 15 However we could remove the brackets making sure of course we can change the sign in the second set of brackets as this is a minus operation and do the whole calculation at once without having to calculate each bracket separately 9 plus 11 equals 20 minus 2 equals 18 minus 3 equals 15 This would appear to indicate that just as I can combine the calculation of two brackets into one calculation so I can combine the two integrations into one and we would get the same answer If this is true of two integrals which we actually do want to add together how much more so is it true of two integrals that we're not really adding together at all because the I will keep the sign term separate anyway So we can combine the cosine and sign integrations into one big operation but we can go further Our signal x of t is multiplied by the sign term and by the cosine term So, we could take x of t out as a common factor and put everything else in brackets But hey, look at this inside the brackets it's Euler's formula with a few minor differences The theta in our case is 2 pi f t and instead of adding the cosine and sign terms together we are subtracting them instead So, we can replace the entire brackets with E to the minus I 2 pi f t The minus sign is there because we have the cosine term minus the sign term So, this gives us a little equation which describes how we calculate the contribution of the cosine and sign terms at our first test frequency Now, we need to run this equation again and again at many different frequencies or in other words, we need to keep changing the value of f We write this like this n is an index When n equals 1 we are testing our signal with our first test frequency f1 and this gives us a result c1 c1 is a complex number whose real part tells us the score of the contribution of the cosine wave at frequency 1 and whose imaginary part tells us the score of the contribution of the sine wave of frequency 1 When n equals 2 we are testing our signal with our second test frequency f2 This gives us a result c2 c2 is also a complex number whose real part tells us the contribution of the cosine wave at frequency 2 and whose imaginary part tells us the contribution of the sine wave at frequency 2 and so it is for c2, c3, c4 and so on We generalize this by calling the terms by the collective name cn So that's it There you have it That's how the Fourier transform works and what the equation means Job done End of course Well Not quite What we just calculated is not the Fourier transform It's a Fourier series What's the difference? Remember Fourier's claim that any function could be expanded in a series of signs and multiples of the variable? Well this claim was a hotly debated subject at the time As we learned in the introduction to the course eminent mathematicians like Lagrange and Laplace both challenged Fourier's paper on the subject and it seems with good reason It took the further work of Peter Gustave Lejeune de Richelais to give a satisfactory demonstration of Fourier's claim However, there were certain restrictive conditions that had to exist for Fourier's idea as he'd proposed it in his paper to work The problem with Fourier's claim is indicated by the limits of the integral Remember that we found the area under the graph of the multiplied signal over one cycle of the signal from time equals zero to the period of the signal or as we wrote it before from minus a half of the period to plus a half of the period Only repeating signals have a cycle The whole meaning of the word cycle is something that goes around and around again and again in other words, a signal that keeps repeating itself The problem is, repeating signals are not the only signals out there In fact, most of the useful signals we encounter from day to day don't repeat themselves The words that I'm saying to you now are a kind of signal a sound signal If I was to repeat the same sentence to you over and over and over again in this lecture, you'd very quickly get bored and most likely switch off as no new information can be imparted in a repeating signal Hence, Fourier's claim that any signal can be expanded in a series of signs cannot be true Only repeating signals can be expanded in a series of signs But here we are spending all this time learning about a mathematical idea that is so revolutionary it underpins most of the electronic communication we have nowadays not to mention many other applications that Fourier couldn't even have dreamed of If the Fourier series only allows us to model a small proportion of signals how comes it so useful? Well that was thanks to the Richling who made some small but significant changes to Fourier's equation What happens, he asked if the signal doesn't repeat itself If a signal doesn't repeat itself then it cannot have a period or can it The word never suggests infinity Maybe we could say that the signal actually does repeat itself but it will only repeat itself after an infinite amount of time Therefore the limits of the integral must expand to encompass the whole of time from minus infinity to plus infinity or to put it another way the signal has never repeated itself and the signal will never repeat itself again This is why I changed the limits of the Fourier series equation before from looking at the signal from time equals zero to the period to looking at the signal from minus half of the period to plus a half of the period I wanted to give the integral consistent with the way we write the Fourier transform equation looking in both directions into the past and into the future of the signal But now we have a problem and that problem is called infinity How can we calculate the infinite? As we'll see it's not only the period but the non-repeating seal that is going to become infinite but also the length of the list of sine waves that we need to describe it Come with me as we journey into the infinite and we discover how Delichlet turned the Fourier series into the Fourier transform For more on how the Fourier transform works online course head over to works.com slash full dash course