NUMBAT OER - Open Educational Resources

4. Making (sine) waves

The relationship between the sine of an angle and the value of the angle describes a cycle or wave that looks like:

Sine plotted against angle

The sine wave starts with a value of zero, increases to 1 at 0.5π radians, is zero again at 1π radians, is -1 at 1.5π radians and returns to zero at 2π radians. As you will appreciate from section 3, the cosine wave is a similar shape, but starts with a value of 1 (ie the value of sine at 0.5π radians).

The sine wave doesn't have to stop at 2π radians. Although it is hard to conceive of an angle of, say, 4π radians (720°), it is perfectly feasible to have the sine of 4π radians. You shouldn't be surprised to find that the sine of 4π radians is also zero, because the sine wave carries on repeating itself. In fact, you can calculate the sine of any real number (positive or negative) - a sine wave calculated for values between zero and 100 looks like this:

Sine wave

Notice that the wave still has a range from 1 to -1 – its amplitude is 2. By adding extra variables to the sine wave, it can be changed to make it have whatever values you want. You can change the amplitude by adding a multiplier to the sine wave, for instance:

fx = 2 sinx

which has an amplitude of 4:

Sine wave

This transformed sine wave still has an average value of zero. If we add a constant to it, we leave the amplitude unchanged but change the maximum and minimum values, for instance:

fx = 2 sinx + 2

will range from zero to +4 instead of -2 to +2:

Sine Wave

The frequency of the sine wave is unchanged from the original plot – it goes through a complete cycle in 2π (about 6.3). We can transform the sine wave further to change the frequency, for example:

fx = 2 sin(0.5x) + 2

will have a frequency that is half of that of our original wave – the distance between adjacent peaks has been doubled:

Sine wave

Finally, we can shift our wave sideways so that it doesn't start with a value of half of the overall amplitude. By adding an offset to the argument for the sine (the bit in brackets), we can shift the curve sideways by a predictable amount:

fx = 2 sin(0.5x + π) + 2

Because a complete cycle of the sine wave occupies 2π, adding an offset of 1π shifts the curve by half a cycle, which will reverse the phase (turn peaks into troughs), as:

Sine wave

If you are going to use this technique to produce a regular cycle, you need to be very clear what each of the bits of the expression does, and be careful where you place your brackets. It is very easy to implement this using a spreadsheet, which is where this series of diagrams originated.