This blog is about Simon, a young gifted mathematician and programmer, who had to move from Amsterdam to Antwerp to be able to study at the level that fits his talent, i.e. homeschool. Visit https://simontiger.com
Simon created a string simulation or a simulation of a traveling wave, something he used to experiment with using a slinky. Pressing the F key flattens the wave, the T key makes it a triangular wave, the Q key makes it a square wave, the S key makes it a sine wave, and the H key makes it a half-sine wave. Simon’s code of the string simulation is available at: https://editor.p5js.org/simontiger/sketches/Q-0iYdEPS
While working on the project live on Discord, Simon received a suggestion from one of the viewers to tie the wave to the microphone (to the sound wave), which he did. “It turned into a more creative project than I thought!” Check this version of the project out at: https://editor.p5js.org/simontiger/sketches/dQypxomRm
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
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):