I've previously seen simple equations that produce beautiful, complex shapes:

equation that looks like 4 onion domes

Is there an equivalent for music? I.e. a simple equation $A(t)$ that, when played as a sound, will produce a melody?

Or failing that, something in the Fourier domain that produces a surprisingly complex or beautiful melody with a simple equation?

I am trying to find a beautiful default for a little open-source utility I wrote that plays an equation as audio.

How functions can be interpreted as music

You can represent music by modeling it as a function, amplitude, with respect to time. More often it is modeled as two functions, one for each ear, i.e. stereo. These functions can be graphed just as any other function can:

audio graph

Now this is discrete (sampled around 48,000Hz), but can be approximated by a continuous function. So we can perform operations on it. For example, you can use the FFT to approximate a Fourier transform.

Unfortunately, because this function is a discrete function comprising millions of datapoints, it can not be written compactly. Just in the same way that the beautiful image at the top of the page is not compact if you represent it as pixel data, yet is compact if you look at the mathematical function that generates that data.


This is a proof of concept that you can make melodies with fairly simple equations:

\begin{align*} &\sin(440 \cdot 2 \pi t) \exp(-(t-1.1)^2 e^{(t-1.1)^2}) \\ + &\sin(554.365 \cdot 2 \pi t) \exp(-(t-3.0)^2 e^{(t-3.0)^2}) \\ + &\sin(659.225 \cdot 2 \pi t) \exp(-(t-4.9)^2 e^{(t-4.9)^2}) \end{align*}

It is somewhat ugly as it just combines the bump function with sinusoids to create an A-major arpeggio: A, C♯, E. The principle is that the function is varying in frequency and amplitude, and it's amplitude peaks when it hits pleasant frequencies.

I'm looking for a more natural version of this. Something similar to the equation at the top of this page that produces the surprisingly complex and beautiful image.

Hear it played as audio.

Making your own

Here's a Desmos graph of the first couple of bump functions I used if you want to play around with this. You then just multiply the bump function by the periodic function you want. You can change the delay of each one by changing $2.9$ to the delay you want. Each bump function lasts about 2 seconds, but you can change the width and shape by playing around with bump the function.

  • $\begingroup$ How do you play an equation as a sound? What does $t^2$ sound like? $\endgroup$ Commented May 20, 2023 at 1:36
  • $\begingroup$ @GerryMyerson It has to have some periodic component to be audible. Check out equation audio to see what I mean. $\endgroup$
    – Zaz
    Commented May 20, 2023 at 1:41
  • 1
    $\begingroup$ OK, so, a function of the form $y=A\sin(Bt+C)$ gets interpreted as a single note of a particular pitch and loudness. Any periodic function can be written as a sum of sines and cosines (a Fourier series) so interpreted as a chord, a bunch of simultaneous notes. Not clear to me how you get a tune out of that. It would be helpful if you would explain in the body of your question how a function gets interpreted as music. $\endgroup$ Commented May 20, 2023 at 1:58
  • 1
    $\begingroup$ I'll try to make a prototype of what I'm describing. But the proof that it's possible is that uncompressed audio files are time series of amplitude values. $\endgroup$
    – Zaz
    Commented May 20, 2023 at 2:43
  • 1
    $\begingroup$ @James I added details on the bump functions I used. Does that answer your question? $\endgroup$
    – Zaz
    Commented May 20, 2023 at 4:04

1 Answer 1


Cool utility! If you haven't already, I suggest learning about the relationships between a sound's waveform and its audible qualities, and manually experimenting.

You can get some fun results using methods from FM synthesis by modulating a signal (like a sine wave) by changing its parameters (amplitude, phase, frequency) over time using other functions, which themselves can be modulated further, resulting in nested function expressions.

Modulations at rates above around 20Hz affect the instantaneous audible pitch and timbre of the sound, whereas slower modulations result in audible changes to the sound over time.

Here's a neat example: .2 sin((2000 pi + 10 sin(100 pi t)) t). I expected this to be a steady FM tone (a 1000 Hz wave, frequency-modulated by a 50 Hz wave), but I made a mistake: varying the frequency term also changes the instantaneous phase, and this phase error is proportional to the amount of time that has passed. It's clearer to view this as phase modulation: .2 sin(2000 pi t + 10 t sin(100 pi t)); if you remove the $t$ factor from the modulation amplitude, you get the expected steady tone.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .