We were reading “17 Equations that Changed the World” late last night, the chapter about the wave equation. Simon got all excited about timbres (shapes of sound waves), that are essentially sine waves. He said he knew an alternative way to look for the fundamental frequency (the sin x wave):
“The smallest number that’s divisible by all the numbers in a sequence is the product of all those numbers divided by the greatest common divisor/factor of all those numbers. That’s the Chinese remainder theorem (or rather, a generalisation of it).
If you took a rational frequency and an irrational one and made them into waves, the waves would never ever ever meet, except for one point. So sometimes there’s no fundamental frequency. Because we need at least two points where the waves meet up to define a fundamental frequency.
Sadly, this happens most of the time. In fact, not even most. 100 percent of the time there’s no fundamental frequency. Technically, it’s an infinitely small chance that any number you come up with at random is rational! But fortunately for us, we can approximate the fundamental frequency here: use the two points that are closest to the waves meeting to get an approximate fundamental frequency. And it always works!
This is incredible! We’ve found a connection between a discrete problem, of what’s the smallest number that divides all of the numbers in a given sequence, to a continuous problem, of what is the fundamental frequency of a combination of sine waves. In other words, we found a discrete solution to a continuous problem!”
Simon, what does discrete mean?
“I’ll give you an example. The natural numbers, even though they are infinite, they are still discrete, because there are gaps between them. And a number in between those gaps is not a natural number anymore. A continuous thing however is for example like the real numbers. There’re no gaps. Because if there were gaps, any number in between those gaps was another real number”.
“It’s so mesmerising!” Simon explains what a standing wave is and the nodes in a wave, using a Slinky. Standing waves can be polarised in any direction (horizontally, vertically or diagonally) or they can be circularly/elliptically polarised or any combination of polarisation direction. A sea wave is normally just a regular wave, but it can become a standing wave if you introduce some kind of boundary.
Simon has created animations visualizing sound waves (Triangle, Sawtooth, Square and Sine waves) in Processing (Java), using wave functions.
These are the functions he used for the Sawtooth, Square and Sine waves:
Not to confuse “sine” with “sgn” (sgn standing for sign):
He was inspired by the logarithmic and power functions that he was studying during his math class yesterday. Simon was trying to draw both types of functions in Grapher on his laptop, but only succeeded for the power functions (because there were no subscript option for the logarithms).
Simon created his very first video game completely on his own. Everything in this game he came up with by himself – from the original idea and design to the final code. The game is about a little man (actually, Simon himself) jumping over the waves in the sea. Every time he lands on an actual wave it’s game over.
Simon used collision detection (point-rectangle instead of rectangle-circle collision detection) and array lists to duplicate the waves. He created an illusion of 3D by choosing the viewing angle “almost as if it were an orthographic camera”, he explains.
The code for this game (in Processing i.e. Java) is available on GitHub at
The making of, step by step:
Simon had trouble with the game over function. Originally, it was only triggered once the player clicked the mouse to jump again while on a wave, instead of reading to the circle-rectangle (little man-wave) collision. Simon asked about this problem in the Coding Train slack channel and got some great responses. Eventually he solved the problem is his own way (see the “Debugged” video):