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 right angled triangle.

Are you coming, Pythagoras? Hi, 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 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 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°, the height starts to decrease again. As the angle passes 180°, the height starts increasing, but in the opposite direction and once the angle passes 270°, 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 the triangle and sine waves are linked to the height of the triangle. Now that we know how sines and cosines are linked to triangles, let’s randomly choose one of the items from the FFT output list to use 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 is the difference between magnitude and amplitude? Magnitude is a scalar quantity meaning it has only 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 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 is a phase difference of 180° between the two waves. Let’s make the width of the triangle equal 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 the triangle, not as a triangle, but as a route in a forest.

These three trees roughly form a right-angled triangle. This tree here represents the new sinusoid and is the tree 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 the starting point here to my destination over there? Well, there are 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 angle or heading I set 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 along the hypotenuse of a triangle if 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 of 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 triangle 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 -28.3 squared which equals 51.5 which is 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 -90° and +90°. What happens if the triangle is in this quadrant of the circle when both the amplitudes of 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 signs 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, -28.3, by the width, 43.0 and then taking the inverse tangent of the result giving us an angle of -33°. 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 the 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 this 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..