• Take two moderately interesting functions that map the unit square to itself; for example, \[(x,y) \rightarrow \left(1-y^2, \sqrt{x}\right)\] and \[(x,y) \rightarrow \left(\frac{x+y}{2}, x\right)\].
  • Take a random point in the unit square.
  • Apply a random one of your two functions.
  • Apply a random one of your two functions.
  • Apply a random one of your two functions.
  • Plot out all of the points you iterated through.

You might expect that you get a kinda random smear of points. And you’d be right that it’s kinda random, but…

(^ notice the fractal self-similarity in that one!)

(^ notice the faint macroscopic grid pattern in that one; that seems to be very sensitive to initial conditions. Sometimes it’s imperceptible, other times it’s really in-your-face.)

It takes a bit of care to find an interesting pair of functions: most simple pairs of functions tend to produce very uninteresting attractor-patterns, because there’s a point, or a small set of discrete points, that are invariant under both functions, and so you very quickly end up trapped in that set. Like…

I forget where I learned about this feature of our universe. It was one of my first programming projects outside of Warcraft III’s map-making engine.


source code