Try the code and the simulations beside the lesson.
Waves just add
When two waves meet, the displacement at each point is the sum of the two displacements. This is the superposition principle, and in numpy it is the easiest rule of all: add the arrays, y = y1 + y2.
Two equal waves in step make a wave of twice the amplitude. Two equal waves half a wavelength apart cancel exactly:
It prints True: the sum is zero at every time, apart from tiny rounding.
Beats
Two notes of nearly the same pitch, f1 and f2, make a sound that swells and fades. Adding the two sines gives
where fˉ is the average of the two frequencies. The cosine is a slow envelope. The sound is loud where the envelope is large and nearly silent where it is zero. The loudness swells and fades ∣f2−f1∣ times each second. This is the beat frequency.
You can find the quiet moments in code. They are the places where the envelope is smaller than both of its neighbours:
It prints 4 quiet moments in 2 s. The beat frequency is ∣22−20∣=2 Hz, so there are 2×2=4 beats in 2 s, one for each quiet moment.
Three graphs against time from 0 to 1 second, one above the other. The top graph is a blue sine wave of 20 hertz and the middle graph an orange sine wave of 22 hertz. The bottom graph is their sum, in purple, with a dashed red envelope above and below it. The sum swells to a loud peak at 0, 0.5 and 1.0 seconds and nearly vanishes at 0.25 and 0.75 seconds, so it swells and fades 2 times a second.
Practise with new numbers
Standing waves
Now add two equal waves that run in opposite directions:
sin(kx−ωt)+sin(kx+ωt)=2sin(kx)cos(ωt)
The factor sin(kx) depends only on the place. It sets how far each point swings. The factor cos(ωt) makes every point swing together. The places where sin(kx)=0 never move. They are the nodes, at x=0,2λ,λ,23λ,…, half a wavelength apart. Halfway between them are the antinodes, where the swing is largest.
It prints [0. 2. 0. 2. 0. 2. 0. 2. 0.]. The swing is zero at 0, 0.50, 1.0, 1.5 and 2.0 m. Those nodes are half a wavelength, 0.50 m, apart.
A string fixed at both ends
Both ends of a guitar string cannot move, so both are nodes. A whole number n of half wavelengths must fit along the string:
L=n2λsofn=2Lnv
The case n=1 is the fundamental. The others, n=2,3,…, are the harmonics. They are whole-number multiples of the fundamental.
Building a sound from harmonics
A square wave jumps between +1 and −1. A sum of sines can build it, if you add only the odd harmonics, each smaller than the one before:
π4∑msin(mx)
Here m runs through the odd numbers 1,3,5,… More terms make a sharper corner. How many are enough? The program prints the height at the middle of the first flat top, which should be 1.
Try it in Python
The program lists the first four harmonics of a string, then adds odd harmonics one at a time and prints how high the sum reaches.
Common mistakes
Adding the frequencies. The beat frequency is the difference ∣f1−f2∣, not the sum.
Counting only loud moments. Count the same kind of moment each time, such as the quiet ones, and count in whole seconds.
Leaving out the 2 in fn=nv/(2L). For the fundamental, half a wavelength fits in the string, so the wavelength is 2L.
Thinking nodes move. In a standing wave the nodes never move. Only the points between them swing.
Stopping the square wave too soon. A few harmonics give a rounded wave. The corners need many.
Remember these
Waves add point by point: y = y1 + y2.
Beats: the sound swells and fades ∣f1−f2∣ times each second.
A standing wave is 2Asin(kx)cos(ωt). Its nodes are half a wavelength apart.
A string fixed at both ends has fn=nv/(2L).
A square wave is a sum of odd harmonics msin(mx) for m=1,3,5,…
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Two equal waves are added in step. What is the amplitude of the sum?
Two whistles of 500 Hz and 504 Hz sound together. How many beats do you hear in 3 s?
Why does 2Asin(kx)cos(ωt) have nodes that never move?
A string of length L is fixed at both ends. What is the longest wavelength it can hold?
Adding harmonics 1 to 9 gives a height of 1.063 at the flat top of the square wave, not 1. What can you do to get closer?
Enroll free in Waves by Computer: Adding and Fitting
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.