Lecture 3
Phase
Sine waves have three properties, amplitude, frequency, and phase. In the last lecture, we dealt with amplitude and frequency. In this lecture, we explore the third and final property of a sine wave: Phase.
Transcript |
When thinking about sound signals, especially when used in music, we tend to think only of frequency or pitch and amplitude or how loud it is. However, there is a 3rd property of a sine wave that can be changed and that is its phase.
To demonstrate what phase is, let’s take a Sine wave. We’ve already seen how we can change its frequency and its amplitude. We can also pause a little before playing the last note. We’ve delayed the last note in the scale, shifted it in time or to put it another way: we’ve changed its phase.
Now we can obviously hear the difference when we started to play the note, but once the note is playing, it sounds exactly the same as it did when I played the same scale before without the delay. This is because our ears are much less sensitive to changes in phase than they are to changes in amplitude or frequency.
So why is phase important?
Let’s take a Sine wave with a frequency of 440Hz (that’s the note A above middle C on the piano). Now I’m going to take another Sine wave with a frequency of 660Hz (that’s roughly the note E above the A we had before) but instead of playing the A and the E together, I’m going to play the E a little after the A – shift it in time slightly.
Now I’m going to add them together.
This is the wave I get. You can hear the 2 frequencies playing. However, if I start to change the phase of the second wave, look what happens to the shape of the wave when we add them together. They still sound the same, but the shape of the signal has changed. Therefore if we are to accurately represent this signal as a series of Sine waves like a Fourier Series does, then the phase information of each wave is important too as it has an effect on the overall shape of the signal.
So how do we represent this shift in phase mathematically?
Let’s take 2 Sine waves. We’ll draw our first wave in blue and it has a phase of zero. The other we’ll draw in red, but shift it by 30°.
Now hang on a second, we’ve just been talking about changing the phase of a signal by shifting it in time, how come’s we’re suddenly talking about angles?
Well, remember what Fourier said about signals in general. He said: “any function of a variable can be expanded in a series of sines of multiples of the variable.” Our variable, or in other words, the thing that goes on the x-axis) is time as we are talking about sound signals. However, when Fourier came up with his theory, he was measuring heat flow so his variable may well have been distance. Therefore we need some common variable that can apply to all types of signals.
When talking about sine waves, angles are the common variable. This variable can then be scaled to apply to whatever signal we are dealing with. So, in our example, if we have a sound wave with a frequency of 660Hz, it means that the air around our ears is being compressed and expanded again at a rate of 660 times per second. This means that the time it takes for 1 compression / expansion cycle is 1/660th of a second.
It takes 360° to complete one cycle of a sine wave, that’s one complete rotation of the line within the circle.
Therefore we can map the time it takes for one cycle of our sound signal onto the 360° of a circle. So if we want to phase shift our signal by 30°, 30° is a 12th of 360° (one cycle of the sine wave). So for our 660Hz signal which takes 1/660th of a second to complete one cycle, a 12th of 1/660th of a second is 0.000126s.
So to convert from the angular variable of a Sine wave to the time variable of our signal, we divide the Angle by the 360° in a circle and multiply by the period of our signal, in this case 1/660th of a second.
But remember that multiplying by the period of a signal is the same as dividing by its frequency. After all what is frequency? It’s the number of signal cycles per second. 660Hz means 660 complete Sine wave cycles per second.
What if we wanted to go the other way and convert from the time variable of our signal to the angular variable of a Sine wave? In this case, we divide by the period of our signal and multiply by 360°.
Alternatively, because this time we divided by the period, we could just simply multiply by the frequency instead. So to convert from time to angle, we multiply by the frequency and then by 360°.
So, back to our question; how do we represent a phase shift of 30° mathematically? Well, the key to answering our question is to notice that the second Sine wave is lagging the first by 30°.
If at an angle of 30°, the amplitude of the blue sine wave is 0.5, the red sine wave won’t reach 0.5, for another 30° when its angle is 60°. Therefore the equation for the red wave is sine of the angle, let’s call it x, minus 30°, or to put it another way the amplitude of the red sine wave’s current angle is the same as what the amplitude of the blue sine wave’s was 30° ago.
What about if we shift the red wave the other way so that the red wave now leads the blue by 30°?
Well not surprisingly the red wave’s equation now becomes sine of x plus 30°.
Now it just so happens that if we shift a sine wave by 90° degrees we get a wave that can be described by another trigonometric function, the Cosine function.
So sine of x plus 90° is equal to the cosine of x.
The Sine and Cosine function come in very useful when dealing with right-angled triangles.
If we take the Sine of this angle and multiply it by the length of the hypotenuse we can calculate the height of the triangle.
Believe it or not, taking the Cosine of the angle and multiplying it by the length of the hypotenuse allows us to calculate the width of the triangle.
But we’ve just seen how a Cosine function is simply a Sine function shifted by 90° and that the sine of the angle allows us to calculate the height of the triangle. Look what happens if we rotate the triangle through 90°. What used to be the width of the triangle has now become its height. So Sine any angle, let’s call it x, plus 30° equals Cosine of that angle.
So now we have 2 ways of looking at a Sine and Cosine function. Either as a wave whose phase we can change, or as a triangle whose angle we can change.
But why is this important? Why bother with the Cosine function at all if all it is, is a Sine function shifted along the x-axis by 90°? To answer this question, we need a map.
I’m standing at point A on my map and I want to get to point B which is behind me over there. Now there are 2 possible routes I could take. I could take the shortest route and go straight there, or I could go the scenic route and take 2 different roads to get to the same point.
Now if we look at our map in a more schematic form, we can see the roads form a right angled triangle. I could describe the direct route by the distance I walked along the hypotenuse and the heading, or angle I set off in to get there.
Alternatively, we could get to the same point on our triangle via the scenic route by first walking along the side adjacent to the angle and then walking up the triangle on the side opposite the angle.
So even if we don’t know the heading, or angle we need to set off in, so long as we know how far across and how far up the triangle to go, we can still reach our destination.
When we looked at the rotating triangle before, we saw that this angle corresponded to the amount by which we had shifted the phase of our sine wave. It may not surprise you to learn, therefore, that just as we can describe any heading by a combination of a Cosine and a Sine function we can also describe any phase shift by adding together two different waves, a cosine wave and a sine wave at the same frequency, simply by altering their amplitudes in a certain way. Let’s see this actually happen.
I’m going to start with a Cosine wave with an amplitude of 32. You can see that this Cosine wave is just a normal Cosine wave with no phase shift.
Now I’m going to take a Sine wave with an amplitude of 29. Again, the Sine wave is not phase shifted at all.
I’m now going to add them together. Look what happens to the resultant wave. It’s a Cosine wave that has been shifted by about 42°.
But what’s its amplitude? To find out let’s go back again to looking at this idea modelled as a triangle.
Here is the amplitude of the Cosine wave 32, represented by the length of the base of the triangle and here is the amplitude of the Sine wave 29, represented by the length of the height of the triangle. What is the length of the hypotenuse?
Well Pythagoras showed us that the square on the hypotenuse is equal to the sum of the sum of the squares on the other 2 sides. Let’s look at this actually happening with a little help from a really simple demonstration I found on a visit to the Bloomfield Science museum in Jerusalem with my 4 year old son.
The base of the triangle has a length of 32, so the area of the square on the base of the triangle is 32-squared which equals 1024. The height of the triangle is 29, so the area of this square on the height of the triangle is 29-squared which equals 841. Now let’s turn the triangle round. The colored water in each of the squares on the sides of the triangle is pouring into the square on the hypotenuse.
We can see that Pythagoras was right; the square on the hypotenuse has been completely filled by the water flowing from the sum of the squares on the other 2 sides. 1024 plus 841 is equal to 1865.
Now how do we find the length of the hypotenuse from the area? Simple, we just take the square root of 1865 which gives us 43.18. This is equal to the amplitude of my phase shifted wave.
How do we work out the angle of the phase shift based on the amplitude of the Cosine and Sine waves? Well again, we look at it as a triangle.
If I increase the width of the triangle but keep the height the same, the angle decreases.
If I increase the height of the triangle but keep the width the same the angle increases.
If I increase the width of the triangle, then to keep the angle the same, I have to increase its height too. This means there must be some relationship between the angle, the height and the width of a triangle.
Ah, so there is a relationship! A relationship suggests maybe a division.
Keeping the width of the triangle the same and increasing the height makes the angle grow.
As the numerator of a division operation grows, so does the result of the division, just like the angle of my triangle, so the height must form the numerator of the division.
Keeping the height of the triangle the same and increasing the width makes the angle shrink.
As the denominator of a division operation grows, the result of the division shrinks, just like the angle of my triangle, so the width must form the denominator of the division.
So now I’m going to plot on the X-axis of a graph the result of dividing the height of my triangle by its width and I’m going to measure the angle of the triangle and plot it on the Y-axis of the graph.
When I join up the dots of the graph, we discover something. There is a relationship between the width, the height and the angle of a triangle, but it isn’t a direct or even linear relationship. That is to say that dividing the height by the width isn’t enough to give us the angle, there must be some other operation we need to do before we can recover the angle of the triangle if we know only its width and height.
How can I calculate the actual angle then from this relationship?
In order to calculate the height of the triangle we multiplied the hypotenuse by the Sine of the angle.
In order to calculate the width of the triangle we multiplied the hypotenuse by the cosine of the angle.
Therefore, maybe we could recover the angle by dividing thing these two expressions together.
The hypotenuse times the sine of the angle divided by the hypotenuse times the cosine of the angle.
Well if we do that, the first thing we notice is that it doesn’t matter what the length of the hypotenuse is, as the Hypotenuse divided itself which just equals 1 and we are left with sine of the angle divided by the cosine of the angle. But this is equal to yet another trigonometric function called the tangent function.
To recover the angle we use the inverse tangent function and that is what we have drawn on the graph.
From the previous example, if my Sine wave has an amplitude of 29 and my Cosine wave has an amplitude of 32 then to work out the angle I take the inverse tangent of:
To calculate the phase shift of the wave we made before we divide the amplitude of the sine wave, by the amplitude of the cosine wave and then take inverse tangent function and that is how I arrived at my result of 42°.
So by adding together a Sine Wave and a Cosine Wave of the same frequency, but different amplitudes, we can change the phase of the resultant wave.
At school, we all learned that there were 360° in a circle. However, there is another way of measuring angles and that is in radians.
The definition of one radian is that angle for which these three lengths are all equal. So, for example, if the radius of my circle is 1, then at an angle of 1 radian the length of this arc will also be 1.
If I now increase the angle to 2 radians, what will be the length of the arc be? Well that’s easy. The length of the arc is always equal to the radius times the radian angle. So on the unit circle, that’s a circle with a radius of 1, the length of the arc will be 2, just like the radian angle.
Now you might recall that the ratio of the circumference of a circle to its diameter is 3.14159265358979…. or, as it is otherwise known, π.
The diameter of a circle is simply twice the length of the radius. So the circumference of the circle can be calculated by multiplying pi by 2 times the radius. On the unit circle, the radius is equal to 1, so if the radian angle is equal to the length of the arc, there must be 2π radians in a circle.
But why, if we have a perfectly good way of measuring angles in degrees, do we now have to get involved in radians and complicated numbers like π. Well, the answer is to do with the way that the Cosine and Sine functions are actually calculated as we’ll find out in the next lecture.
So now we know the 3 properties of a sine wave that we can modify, we need some mathematical system that combines all the things we have learned so far. Sine Waves, Cosine Waves, amplitudes, frequencies and phases. This was the point at which I finally lost the plot back in my days at university as we are now about to enter a world where numbers are both real and imaginary and where the square root of minus one actually exists: We’re about the enter the realm of complex numbers.
Podcast
Support the course
Would you like to learn about how the Fourier Series became the Fourier Transform, how the DFT and FFT work and what Windowing is? Please help me to devote more time to filming the rest of the video course by supporting me on Patreon.
...or via PayPal
...or a coffee would be much appreciated.
Keep in touch
Receive updates on the continuing production of the course, get notified when there is a new post or video and be the first to know when the full course goes live.
Click here to subscribe