Wednesday, December 23, 2015
connett circles
martin attractor
Clicking the window adjusts the viewport position; there is also an alternate version with color and animation.
Also, for a certain Rubyist friend, I wrote another lazily-evaluated, colored and animated implementation in Ruby.
Tuesday, December 22, 2015
lyapunov fractals
It took me some experimentation to figure out how to color this derivation of the logistic map; I'm still not quite sure how the hues should scale as you zoom. But the bi-tonal method shown below works well enough to produce the image at left - click it for more detail.
Tuesday, December 15, 2015
the mandelbrot set
What programmer hasn't at some point written an implementation of Benoit Mandelbrot's great discovery, the most famous fractal in the world? Here's my own minimal version, with the simplest possible coloring scheme. To interact with it, just click any two points: the window will zoom in on the rectangle they define.
Monday, November 2, 2015
a lava lamp
This 'lava lamp' is actually a simple cyclic cellular automaton; the CA rule is courtesy of Jason Rampe. In keeping with the spirit of Haskell, I chose to implement it with a hashmap of points rather than an array. Needless to say, that's not practical; but this is just a demonstration.
Wednesday, August 19, 2015
random undirected graphs
This little program generates random, undirected graphs without loops or isolated vertices (though the graph is not necessarily connected).
I have found it useful to generate random inputs for testing graph algorithms.
Wednesday, July 8, 2015
sqrt 2, visualized
The program makes for an interesting screensaver, but does it follow any pattern, or illustrate any special properties of √2 ? Though I'm no mathematician, from what I've read this seems unlikely. √2 is suspected (but not proved) to be a normal number. This would mean the digits of its expansion (respective to some number base) follow a uniform distribution; no digit would be more likely to appear than any other.
Nonetheless, I'd be curious to see the results of a really long run!
Sunday, June 28, 2015
triangle geometry
Here's a trivial post, mostly just to show off how nice mathematical code can look in Haskell. It illustrates the centroid, incircle, and circumcircle of a random triangle, with everything defined in terms of vertex triples. The viewport centers on the circumcenter, and the triangle's interior is filled using barycentric coordinates.
Monday, March 30, 2015
primitive totalistic automata
This code renders any of the 2187 possible 3-colored, 1-dimensional, totalistic cellular automata. I was charmed by these and many other beautiful demonstrations in Stephen Wolfram's notorious compendium, though I regret I can't say the same for its tendentious style.
The program input is an integer representing the intended CA rule in base 3.
Wednesday, February 18, 2015
elementary cellular automata
This code takes the rule number for an elementary cellular automaton as input, and then runs the CA from a random seed, rendering the result. The seed comprises 600 random bits taken from rule 30. Its length, when accounting for scale, is greater than the window width; this helps keep pathological edge effects outside the visible frame. The screenshot at left shows an execution of the famous rule 110.
Monday, February 16, 2015
wolfram's random generator
For my own conviction, it was enough to find that the expression sum (take 80 $ rands 5000) `div` 80 produces 2525.
Since each random bit requires computing a full cell generation, this algorithm quickly slows down. I assume more pragmatic implementations solve this by perhaps re-seeding the automaton after some number of iterations.