Building a tool in Haskell for dynamical systems research.
FractalStream is a program that I developed while I was a graduate student with John Hubbard. It was developed to replace a pre-OS X Mac program called FractalAsm which was written by Karl Papadantonakis while he was an undergraduate at Cornell. FractalAsm was cool because the scripts you wrote were translated directly to PowerPC machine code, so they were quite fast; in fact, I think they were compiled down to code that would execute without touching memory. Since the PowerPC has 32 double-precision floating point registers there was a good amount of state that you could work with.
The biggest drawback, of course, was that FractalAsm scripts were translated directly to PowerPC machine code. For a while, FractalAsm could still be run using the Classic Environment; but once Apple dropped the PowerPC, keeping FractalAsm running got a bit gruesome.
Bill Thurston ended up funding me for a semester to develop a replacement for FractalAsm that would run on (then-)modern Apple hardware. In retrospect we should have used that opportunity to develop a cross-platform solution right away, but things were getting desparate enough that just running natively on Intel OS X was considered a big improvement. In any case, Bill’s funding along with Hubbard and Sarah Koch’s extensive experience using FractalAsm in their research gave me the opportunity to develop the initial (and essentially only) version of FractalStream.
FractalStream is a program for experimentally investigating dynamical systems. In practice, that means that it can make pretty pictures, but those pretty pictures have to help real mathematicians get real work done.
It was decided early on to use a new scripting language rather than maintaining compatibility with the FractalAsm language; for one thing, I didn’t personally have a running version of FractalAsm and couldn’t quite reverse-engineer the semantics of the language from the documentation.
Since many of the FractalStream users study complex dynamics, Sarah and I felt that it would be useful to allow the user to write scripts that directly manipulate complex variables. For example, the full FractalStream (1.0) script for rendering a Mandelbrot set with click-through to the corresponding Julia set is simply
iterate z^2 + C until z escapes.
Since the original FractalStream was developed during Apple’s PowerPC-to-Intel transition, it was important that it would run on both platforms. The solution was to translate the scripts to LLVM IR, which could then be compiled and executed as native code (a script compiler to C also existed at one point).
I had a notion early on that the scripts could compile to GPU programs since the FractalStream drawing operations fall squarely in the set of “embarassingly parallel” tasks. The idea was to get a massive speed boost by using the GPU as a streaming coprocessor. The big drawback is precision: even now, 64-bit floating point precision is not a given on GPUs. This is especially true for mobile GPUs, and most FractalStream users seem to primarily use it on a laptop.
Since 32-bit floating point results in major precision loss after just a few zooms into the Mandelbrot set, it seems clear that 64-bit support is a hard requirement. This effectively killed the “stream” part of FractalStream, but the name stuck.
That’s all for now. To see what FractalStream is capable of, have a look at the PDFs in the zombified Google code archive.