
Map is a visualization for the evolution of discrete dynamical systems. The idea was to explore recursive bitwise functions and observe the changes in the bit-strings themselves. The column is a partial history of the iterations of the function. Each row is a bit-string representing the result of an iteration. The top row is the most recent. The top surface represents a constantly updating frequency analysis for tracking how often each bit is on (1) or off (0). A point of interest in this project is observing stability/periodicity or lack thereof in the individual bits in a bit-string. In the above picture we can see that some bits have very short periods and others have longer and less discernable ones. It was hoped that the tool would be a good first step in analyzing these patterns.
The project itself was originally slated to be written in JS, but I decided to try writing it in Haskell. This turned out to be an interesting choice that solved some problems and caused others. For one thing it made the mathematical portions of the code almost trivially easy, and also quite powerful. Firstly Haskell is a functional language that makes writing even complex recursive mathematical functions very easy to write. Secondly there is the issue of error. Most dynamical systems are studied using numerical methods and floating point numbers. This unavoidably comes with error in each computation. Because a dynamical system is recursive, traditional simulations will accumulate error on each iteration, and it is only a matter of (a surprisingly small amount of ) time before it overwhelms the system and the sequence converges to zero or diverges. This problem isn’t easily solvable by simply increasing floating point precision due to the sensitivity to initial conditions of chaotic dynamical systems. They are so sensitive that going from, say, 32 to 64 bits isn’t enough to help significantly. Haskell presented a good solution to this in an available real numbers library that computes using continued fractions without loss of precision. An arbitrary cutoff was chosen for performance reasons, but in map, error does not accumulate from one iteration to another. This differs from the majority of work in this field, where error accumulation is often seen as a given. Possibly because much dynamical systems research is concerned with continuous spaces, whereas this project investigates discrete systems.
The tradeoff is that graphics in Haskell seem to be viewed as a novelty at best. There is very little documentation or prior art, and the libraries are hopelessly unmaintained and poorly featured. The SDL library bindings were chosen if for no other reason than it being the only viable choice. Bless the people who created the bindings, but making the visuals work was the hardest technical part of the project by far. Suffice to say that Haskell’s very strict type system did not play nicely with the C and OpenGL types used by SDL. Much experimentation and filthy hacking was required.
future work
This project turned into a bit of a proof-of-concept. Technical difficulties consumed a lot of the time, which meant we were able to show that it could visualize already well understood functions such as the Baker’s Map and the Logistic Map and confirm that they behaved as expected. It would be nice to return to the ideas behind this project and explore some of the bitwise functions it was originally intended to be used for. It also may be worth investigating patterns in the bit-strings for the functions that we did try. I also would like to see how this stuff may relate to cellular automata, themselves another type of discrete dynamical system.
Importantly, a rewrite would not be written in Haskell, at least not entirely. This project was written entirely client side, but would benefit from being client-server. This kind of separation would mean using more than one language or toolset instead of the original’s monolithic structure. Haskell could be used server-side for the computations, JavaScript for the frontend, and everyone would be much happier and healthier.
note: map was developed in collaboration with Dr. Leo Pinheiro (Rhode Island College) , who led the mathematical investigations.