 So, you want to know more about your signal. Putting it through an FFT will tell you exactly what you want to know, but the output is not quite what you expected. What does this strange list of numbers mean? Where have the magnitude and phase graphs gone? They're right here in this list. But to properly understand what the FFT is telling us, we need a little help from my friend here and a right-angled triangle. Are you coming Pythagoras? I'm Mark Newman, and this channel is all about helping you understand the fascinating world of signals and systems. When I was at university, everything was about manipulating equations. Lecturers would skip stages in their derivations and diagrams of what the maths was actually doing were very few and far between. So in these videos, I prefer to explain things in a more systematic, visual and intuitive way. You've probably heard of my friend here, the Greek philosopher Pythagoras. He lived some 2,000 years before Fourier was even born. However ancient though Pythagoras ideas were, his way of looking at right-angled triangles was very useful to Fourier. The fast Fourier transform splits your signal into sinusoids and records the properties of each sinusoid as a complex number. That's what this list is. We found out in the last video that the position of each item in the list tells you its frequency. But what about the item itself? Each item is a complex number and it is this number that tells you the amplitudes and phases of the cosine and sine components making up each sinusoid. The real part of the complex number represents the cosine component and the imaginary part of the complex number represents the sine component. But what have triangles got to do with all this? Think of a triangle rotating within a circle. As the angle of the triangle increases, its height increases. Once the angle passes 90 degrees, the height starts to decrease again. As the angle passes 180 degrees, the height starts increasing but in the opposite direction. And once the angle passes 270 degrees, the height starts to decrease again and everything starts over. Now if we plot this on a graph with the angle of the triangle on the x-axis and the height of the triangle on the y-axis, just look at which function it describes. It's a sine wave. Something similar happens with the width of the triangle too. Only this time, the wave it describes is a cosine wave. So cosine waves are linked to the width of a triangle and sine waves are linked to the height of a triangle. Now that we know how sines and cosines are linked to triangles, let's randomly choose one of the items in the FFT output list and use it as an example of how to calculate the magnitude and phase of the sinusoid it represents. Oh, before we go on, we need to clear up some terminology. The real and imaginary parts of this complex number describe the amplitudes of the cosine and sine waves. However, we are looking to find the magnitude of the sinusoid that this complex number represents. What's the difference between magnitude and amplitude? Magnitude is a scalar quantity, meaning it only has a numerical value. It's always positive. Amplitude, on the other hand, can be positive or negative. The magnitude tells us how large the sinusoid is, whereas the amplitude tells us something about its phase too. Look at these two waves. They're both sinusoids and they both have the same magnitudes. But the amplitude of the first wave is positive and the amplitude of the second wave is negative. There's a phase difference of 180 degrees between the two waves. Let's make the width of the triangle equal to the real part of the complex number, representing the amplitude of the cosine wave. And let's make the height of the triangle equal to the imaginary part of the complex number, representing the amplitude of the sine wave. Notice the direction of the line. The amplitude of this particular sine wave is negative. What happens if we add the cosine wave and the sine wave together? They form a sinusoid with a new magnitude and phase. How do we calculate the magnitude and phase of this new sinusoid? To answer this question, we need to think of our triangle not as a triangle, but as a root in the forest. These three trees roughly form a right-angled triangle. This tree here represents the new sinusoid that I'm trying to get to. And this tree here represents my starting point. These two trees form the base of the triangle, representing the amplitude of the cosine wave. And these two trees form the height of the triangle, representing the amplitude of the sine wave. But how can I get from my starting point here to my destination over there? Well, for two possibilities. I could take the scenic route and walk first along the cosine path and then along the sine path. Or alternatively, I could take a shortcut and head straight there. The heading or angle I fit off in represents the phase of the sinusoid. And the distance I walked along the hypotenuse represents the magnitude of the sinusoid. But how can we calculate the distance from the hypotenuse of a triangle when all we know are the lengths of its base and its height? Pythagoras taught us that if we draw squares on the three sides of the triangle, then the area of the square on the hypotenuse is equal to the sum of the areas of the squares on the other two sides. And if we know the area of the square on the hypotenuse, we can work out its length by taking the square root. So the length of the hypotenuse of this triangle is the square root of 43.0 squared plus minus 28.3 squared, which equals 51.5, which is the magnitude of this sinusoid in the list. But how do we calculate the phase of the sinusoid? This is equivalent to the heading or angle I need to set off in. The angle of a triangle is related to its width and its height. Increase the height and the angle increases and vice versa. Increase the width and the angle decreases and vice versa. But the relationship between the angle, the height and the width of a triangle is not linear. The function it describes is an inverse tangent function. So to calculate the angle of the triangle, or the phase of the sinusoid, we need to divide the height by the width and take the inverse tangent function of the result. But you may notice that the inverse tangent function only covers phases between minus 90 degrees and plus 90 degrees. What happens if the triangle is in this quadrant of the circle when both the amplitudes of the cosine and sine components are negative? Or maybe this quadrant, when the amplitude of the cosine component is negative, but the amplitude of the sine component is positive? If we want to be able to cover all quadrants of the circle, we have to remember the sines of the two amplitudes. In most modern programming languages, this is taken care of for us by using the extended inverse tangent function, or as it is usually referred to, the ATAN2 function. Therefore, the phase of the sinusoid we've been looking at can be calculated by dividing the height of the triangle, minus 28.3, by the width, 43.0, and then taking the inverse tangent of the result, giving us an angle of minus 33 degrees. So if we use Pythagoras and the inverse tangent function on the real and imaginary parts of each item in the FFT output list, we can plot graphs of the magnitudes and phases for every frequency in our signal, just like the ones we saw at the beginning of the video. If you would like assistance with any of the principles I teach in my videos, or help in applying them to your specific application, you can schedule a one-on-one consultation session with me. See the link at the end of the video. Notice the symmetry in the magnitude graph. It's as if someone has put a mirror at this frequency here. A similar symmetry exists in the phase graph as well. It's just that the phase graph is flipped as well as reflected. So here's your challenge for this video. Why does this symmetry happen? What does it mean? Is there something unique to the signal I chose? Or is it due to something the FFT has done? You'll find the answer in the next video.