I just read that earlier today, Benoît Mandelbrot passed away. Mandelbrot’s most famous discovery, the Mandelbrot fractal, played an important early role in my interest in both programming and mathematics, and I’ve revisited Mandelbrot fractals many times as programming samples for new languages or frameworks I’ve looked at. I was lucky to have an opportunity to hear Mandelbrot speak in person a few years ago when he stopped by the Microsoft campus on a book tour for his book The Misbehaviour of Markets: A Fractal View of Financial Turbulence.

In honor of Mandelbrot, here are two very simple takes on the Mandelbrot fractal that I’ve written in the last couple years.

## Mandelbrot in the F# Interactive

One of the first pieces of F# code I wrote is below. I blogged about this here.

## Mandelbrot in 175 characters of Javascript

Inspired by the js1k.com competition earlier this year, I adapted Ken Perlin’s very cool C program to Javascript as a 175 character program for rendering a Mandelbrot fractal in any browser. Couldn’t quite get it to fit in a single tweet though (rule #6 of the js1k challenge).

y=-16;s="<pre>";while(s+='\n',y++<15)for(x=0;x++<84;s+=(" .:-;!/>)|&IH%*#"[k&15]))for(i=k=r=0;j=r*r-i*i-2+x/25,i=2*r *i+y/10,j*j+i*i<11&&k++<111;r=j);document.body.innerHTML=s

Check it out here for the full page source.

[UPDATE: And here's a slightly more fully featured implementation, using Javascript and HTML5 canvas. ]

Let the record show that if you want F# to generate the prettier picture like the Javascript one, you can just change the end of the F# code thusly:

<pre>

let chars=" .:-;!/>)|&IH%*#"

for y in [-1.2..0.1..1.2] do

for x in [-2.0..0.05..1.0] do

match mandelbrot (Complex(x, y)) with

| DidNotEscape -> Console.Write " "

| Escaped i -> Console.Write chars.[i&&&15]

Console.WriteLine ()

</pre>

Cool I have never seen a text mode fractal!

e1saman.wordpress.com/…/the-father-of-fractals-benoit-mandelbrot-is-dead

This brought recollection of the, infinitely sillier…

thedailywtf.com/…/Stupid-Coding-Tricks-The-TSQL-Madlebrot.aspx