Hacker News new | past | comments | ask | show | jobs | submit login

Here's Weierstrass in Python: https://scipython.com/blog/the-weierstrass-function

I wonder what they sound like as audio.

Edit: apparently it sounds like this https://youtu.be/vWmZnlPQK14




My attempt at nice looking TS version:

    function sum(f: (x: number) => number, upper = 500) {
      let sum = 0;
      for (let n = 0; n < upper; n++) sum += f(n);
      return sum;
    }

    const weierstrass = (x: number, a = 0.5, b = 3) =>
      sum(n => a ** n * Math.cos(b ** n * x));


honestly less terrible than I was expecting


Audio spectrum is bounded, so we are only hearing the first few terms of the series that make up the function (the coefficient under sine grows exponentially with n).

You could even replace the audible part with Chopin (or anything else, even f(x)=0) to get a Weierstrass-like function which sounds like Chopin (or silence) but is still not differentiable anywhere.


What piqued my interest is that the illustration in the article looks a lot like a typical organic audio waveform. That's unusual.

At a lower pitch, with some variation in pitch and amplitude, it probably sounds nicer.


At some frequencies sounds like a more (or less) chip-crushed church organ.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: