
The Mandelwat Set - rbanffy
https://medium.com/dailyjs/the-mandelwat-set-c3037204bf83
======
krylon
A little more than eight years ago, I came across a nice documentary:
"Fractals - The Colors of Inifnity", narrated by Arthur C. Clarke (yes, THE
Arthur C. Clarke!), with music provided by Dave Gilmour of Pink Floyd; to top
it off, I was tripping on LSD for the first time when I saw it, and I had to
rewind at least once to check if something I had seen was actually on the
screen or just in my head (to my disappointment at the time, it was actually
on the screen).

It's a nice documentary, though. Highly recommend it. They even have an
interview with Benoit Mandelbrot himself, may he rest in peace.

Two years after that, I wrote my first Mandelbrot-renderer. First in Python,
but that was waaaay too slow, then in C, which was a lot faster (duh!), and
then I made it even faster by telling the compiler to use SSE. (To some, that
sounds trivial, but it was something I had never done before.)

I have always suspected that it is like a rite of passage, building at least
one simple-minded Mandelbrot renderer. I rewrote mine after two more years to
take advantage of multiple threads and wrote another one to render the
Buddhabrot[1]. Then I remembered an article I had read years before, about the
Parallel Virtual Machine, PVM. So, the next weekend, I turned my Mandelbrot
renderer into a distributed application.

So Kudos to the author. Tackling the Mandelbrot set has the dual advantage of
being interesting _and_ you can make pretty pictures along the way. It is
great fun, and I learned a few things along the way. What more could I ask
for?

[1]
[https://en.wikipedia.org/wiki/Buddhabrot](https://en.wikipedia.org/wiki/Buddhabrot)

~~~
psyc
I wrote my first Mandelbrot renderer around 1990. I've been a graphics
programmer for almost 30 years, and it still absolutely blows my mind. I
understand the math, but I still watch ultra-mega-zooms on YouTube and marvel
that such an object exists.

~~~
Baeocystin
My high school science fair project in 1989 was the Mandelbrot set, and I was
using my Amiga to generate them, then some funky dot-matrix printer voodoo to
get even grayscaling for the prints. I barely made the cutoff time, even
though I'd spent weeks working on the project, because each possible render
took at least a day, and my code had a lot of hiccups. (IIRC, everything was
written in Modula-2. I need to see if I can find those old disks somewhere.)

It's funny that of all the things I'm 'jealous' of in modern tech, the thing
that still blows me away is just how fast I can generate/zoom around fractal
sets, just for the hell of it, on my phone. This much computing power in the
palm of one's hand was inconceivable to me at the time!

~~~
kirrent
One of my most enjoyable projects was writing a Mandelbrot generator for the
Gameboy. It was so slow that if you wanted to fill the very low res screen
you'd be the better part through your battery life. Great fun though.

------
cr0sh
This brings back memories of my being in high school; I'd get there in the
morning, run over to our Computer Programming classroom, and load a floppy
into the one Apple IIe that was connected to a color TV.

I load and run a Applesoft BASIC program that plotted the Mandelbrot set -
oh...so...slowly. It's one saving grace was that it used a special ML program
(something I found in Byte magazine or somewhere) which - on a machine
equipped with an 80 column card (and the extra memory it afforded) would
enable a high-resolution mode with access to all 16 colors.

So I'd run it - and let it plot...

By the time lunchtime came around, it would be finished, and it saved the
image to the floppy. I'd then manually pick some new coordinates, and run it
again to "zoom" in to an interesting area.

My last period was in that class (it was an elective, and one year I took it
twice per day just to pass the time and gain an easy "A") - and by that time
the new plot would be done and saved.

The next day I'd repeat it again. After about four iterations, though, it
would be running too slow to finish a plot in time. So - I'd start again, and
zoom in somewhere else. The teacher enjoyed it, and the other students liked
seeing the pretty pictures.

Nobody really understood the math, though.

~~~
zem
what does ML stand for here?

~~~
Almaviva
Presumably "Machine Language" which is what we called Assembly, back when the
translation between what you wrote and what the CPU actually did was pretty
transparent.

~~~
zem
huh, i've always seen it as "machine code" or "assembly language"; "machine
language" is new to me.

------
aisofteng
This style of writing that has a flavor of "omg I'm so random xD" and "I'm not
sure why this works but it does lol" is always irritating.

~~~
FridgeSeal
100% agree: "Sets wtf is a set

    
    
        I’m not really going to get into set theory because I don’t know anything about it tbqh, but maybe it’s worth a mention? Wonder what would be a really good succinct but not wrong explanation of set theory…"
    

"Sets wtf is a set", I don't know Bob, what is grammar, and why doesn't your
article have any? "lol, sets? one of the fundamental sections of mathematics?
Wut r those lel? who cares I do js, fuck learning about what's going on when
you're here to write a trite, subpar blog post on the subject".

"...but maybe it's worth a mention?" I don't know, is literally one of the
fundamental parts of the underlying mathematics important? "...Wonder what
would be a really good succinct but not wrong explanation of set theory…"
Here's an idea, take literally 3 seconds, or the minimal amount of effort you
have and search 'introduction to set theory'. I can almost guarantee that
there is a plethora of fantastic resources out there. Hell, Wikipedia is often
more than adequate for mathematics topics. Also, unless you're a James Joyce
tier writer, this stream of consciousness style writing is exceedingly poor
form and should be avoided. It adds nothing and really only serves to tell the
reader how little you know.

~~~
19eightyfour
Maybe this is how kids talk these days. There is going to be some Millenial
who is a math genius an order of magnitude beyond Terry Tao, and what if they
talk like this? Such things are going to happen. I find it amusing.

~~~
Sunset
This is not how kids talk these days. Source: I have a kid.

~~~
Scarblac
It seems to be how 20something frontend developers talk though (source: work
with a few of them and saw their talk slides).

------
j2kun
A while back I wrote a similar post that focuses more on the math, and how one
might discover this organically (well, maybe)

[https://jeremykun.com/2014/05/26/learning-to-love-complex-
nu...](https://jeremykun.com/2014/05/26/learning-to-love-complex-numbers/)

~~~
chias
This is beautiful. Thank you for sharing the link.

~~~
j2kun
Oh that's so kind of you! I'm interested to hear what aspect or sections you
particularly liked?

------
mwfunk
One of the first programs I ever wrote was a Mandelbrot renderer in GW-BASIC,
on an 8086 PC with a CGA card running DOS 3.3. This wasn't in the '80s when
this would have made sense, rather this was circa 1994 because this was
literally the only computer that was available to me. Nonetheless it was mind-
blowing to me.

CGA had a 320x200 4-color mode. My program had a hardcoded bounding box that
it would evaluate, and generate a 320x200 rendering of. I had to leave it
running overnight for it to run to completion. I would set up the bounding box
in the source file, start running the program, then wait until the next day
for it to complete. It was awesome. Modern hardware could probably do the same
thing in a few milliseconds. I'm sure it being written in GW-BASIC didn't
help. :) Still, good times. That was the first thing I ever did that sort of
resembled graphics programming.

~~~
bartread
Actually I don't think this is as ridiculous as you might think.

I spent quite a bit of time with a mate of mine over the summer of 1992
writing compression algorithms in GW-BASIC on his dad's 8086 powered PC,
equipped with CGA graphics. Another friend had a computer with EGA (gasp!)
graphics. Almost no-one had a "decent" (i.e., even remotely current) spec PC
back then, and I was on an Amiga 500.

When, just after we'd finished our A-level exams in 1994, first friend's dad
upgraded to a 486SX33 with some sort of SVGA card that was capable of running
DOOM - and doing so smoothly - minds were duly blown. And that's where that
summer went.

------
Dru89
A bit unrelated, but it's weird that Medium doesn't seem to support embedded
code, and instead only seems to work with gists.

It made the mobile experience pretty bad (all I get are links to the gists)
and it would definitely "pollute" my gist history with a lot of little code
snippets.

On the note of the topic itself, though, this was a fun read for building
fractals in JavaScript!

~~~
petercooper
It can, but it wouldn't be syntax highlighted: [https://help.medium.com/hc/en-
us/articles/224550008-Code-blo...](https://help.medium.com/hc/en-
us/articles/224550008-Code-blocks-inline-code)

------
blauditore
> Hey, I’m a Web Developer™! I should use JavaScript for this because
> JavaScript is the best lol!

I understand this is meant as a joke, but I also think that's part of the
reason why Node became so big.

~~~
NTripleOne
As a web developer, node feels like a joke that's gotten out of hand and by
this point people are just rolling with it.

------
FridgeSeal
"I thought, “Hey, I’m a Web Developer™! I should use JavaScript for this
because JavaScript is the best lol!” "

While that's clearly meant to be somewhat of a joke (from a medium account
called dailyjs as well), it's this kind of annoying attitude that has lead to
js being forced into lots of other avenues.

Also, is js really even the best tool for this? I feel like you're going to
get far better pictures and faster results from language closer to the metal
like C/Rust/Java(???).

~~~
vidarh
Sure, you'll be able to render faster. But how much time will you spend
building a UI? And you still won't have anything to inline in the web page.
Part of the appeal of doing this kind of stuff in JS is to be able to share it
without requiring people download and install something.

Realistically speaking, any toy fractal renderer like this will be an order of
magnitude or two away from a heavily tuned one employing every trick in the
book anyway, regardless of language.

~~~
OJFord
> _you still won 't have anything to inline in the web page._

How about a good old-fashioned image that doesn't require the viewer have JS
enabled?

------
Nursie
Some very pretty pictures there!

I often write fractal renderers when I'm bored, usually batch rather than
interactive ones. My most recent was able to parallel draw using several
hundred servers, it was great fun.

Next steps for me after mandelbrot, on my most recent run, were the burning
ship fractal, then fractals using floating point (Glynn Trees) and imaginary
exponents, then Pickover Biomorphs (which I love to look at) Never quite got
my phoenixes working....

And then I got some real work to do !

------
kpil
I really enjoyed this video with Dr Holly Krieger of Numberphile.
[https://youtu.be/NGMRB4O922I](https://youtu.be/NGMRB4O922I)

There are a few more videos related to PI and The Mandelbrot set, Julia, etc.
All nice to watch.
[https://youtu.be/d0vY0CKYhPY](https://youtu.be/d0vY0CKYhPY)

------
sylentmode
Does it bother nobody else that the title says mandelwat and not Mandelbrot?

~~~
bartread
It's sort of a JavaScript in-joke. The originaly "Wat?" talk was somewhat
entertaining but it's now become ubiquitous enough that I'd probably throttle
its progenitor given half a chance.

------
nice_byte
In case anyone's interested in the webgl implementation (with explanation),
here's my post on the same topic from a while back:
[http://gpfault.net/posts/mandelbrot-
webgl.txt.html](http://gpfault.net/posts/mandelbrot-webgl.txt.html)

------
ttoinou
If you want others coloring algorithm check out this one :
[https://www.shadertoy.com/view/MttXz8](https://www.shadertoy.com/view/MttXz8)
(Mandelbrot Filaments & Lightning on ShaderToy)

------
bschwindHN
I remember reading an article from Shawn Hargreaves from the days of XNA
(gamedev framework):

[https://blogs.msdn.microsoft.com/shawnhar/2006/12/11/sixty-f...](https://blogs.msdn.microsoft.com/shawnhar/2006/12/11/sixty-
fractals-per-second/)

I took the code from that article and combined it with the normalized
iteration count algorithm:

[https://en.wikipedia.org/wiki/Mandelbrot_set#Continuous_.28s...](https://en.wikipedia.org/wiki/Mandelbrot_set#Continuous_.28smooth.29_coloring)

Running the result at 60FPS on a huge 1080p TV was a lot of fun!

------
BooglyWoo
This site has an excellent series of in-depth interviews with Mandelbrot;
profiling his early life, his capacity to think mathematically "in pictures",
and goal to link seemingly disparate fields such as "social" and "natural"
sciences through fractal mathematics.

EDIT: forgot the link godammit
[https://www.webofstories.com/play/benoit.mandelbrot/6](https://www.webofstories.com/play/benoit.mandelbrot/6)

------
chestervonwinch
Some time ago, I made a toy web app that creates fractals like the Julia set
via functional iteration:

[http://notmatthancock.github.io/software/func-
iter/](http://notmatthancock.github.io/software/func-iter/)

There's more on how it works and so forth if you go to the explanation link.

Edit: it's computationally intensive to create the fractals, so it's not very
suitable for mobile (although, there's a progress indicator).

------
ghusbands
Many don't seem to realise that the black circles in the middle of spirals and
other smooth curves are due to the iteration count being too low. The spirals
don't stop and the only filled shapes in the mandelbrot set look very much
like the zoomed out view.

------
scrame
This is great! I more or less majored in fractals from being really interested
as a kid, so I love seeing people find it and break it down.

As mentioned elsewhere, the Colors of Infinity doc is pretty good, if you've
never gone beyond the T-shirts and trippy colors.

------
nightcracker
Am I the only one that was a bit disappointed to find it's a beginner
introduction to the Mandelbrot set? The title led me to believe there was some
modification or something new =/

------
fibo
MandelBrot WebGL2 shader here! [https://github.com/fibo/mandelbrot-
webgl2](https://github.com/fibo/mandelbrot-webgl2)

you need Canary.

------
jfo
Original author here.

It's a real, real joy to read all these memories about the set, thank you all!

> Although I'm a huge fan of tech writing for beginners, in this case I could
> have done with 0.6 as much whimsy.

Can I meet you in the middle somewhere?

No, but seriously, there are what I consider very good reasons to adopt this
tone. It's easier to write in a loose conversational style, first of all, and
it's much more approachable for a wider variety of readers. But most
importantly, to me anyway, is that I want to avoid even the semblance of an
authoritative voice derived solely from the tone of the writing. Case in
point:

> It's just a way of saying: "Outside the scope of this textbook".

That's exactly right. I'm not going to explain such a huge branch of
mathematics with any justice in a short blog post, so I'm not even going to
try. The cursory definition of "what you probably think it is" is more than
adequate to get to the point, and I want to be clear about what I do and do
not actually understand. To me though, "Outside the scope of this post"
bespeaks of an author's deep and abiding understanding of the subject, as if
he or she doesn't feel it necessary to deign to share that understanding just
yet. For me, for this subject, This is not accurate, and I don't want readers
to feel like it is.

> only serves to tell the reader how little you know.

This is also exactly right. I don't know much about sets, at all. I could read
about them! I'd love to read about them, and I probably will sometime. But I
don't know much about them right now. I think it's _more_ important, not less,
that I am clear about that. This post is written for someone who doesn't have
a strong math background and is only just learning about the Mandelbrot set,
in effect, me from a few months ago.

The authoritativeness of the post should come from the provable validity of
the contents, not the airs of the author. I had this post vetted by JavaScript
~ninjas~ and a Math phd to avoid putting out bad information, that's much more
important to me than proving that I know everything, because I don't.

That said, I want it to be an enjoyable read for anyone, so I'll keep the
tonal crits in mind.

> A bit unrelated, but it's weird that Medium doesn't seem to support embedded
> code, and instead only seems to work with gists. It made the mobile
> experience pretty bad (all I get are links to the gists) and it would
> definitely "pollute" my gist history with a lot of little code snippets

I agree.

> Am I the only one that was a bit disappointed to find it's a beginner
> introduction to the Mandelbrot set? The title led me to believe there was
> some modification or something new =/

I'm sorry; but if I had truly discovered a new fractal set, I probably
wouldn't be publishing it on Medium first. :) Mandelwat was just too good a
pun.

> Somebody introduce this guy to the Mandlebulb.

The Mandlebulb blows my mind.

> I understand this is meant as a joke, but I also think that's part of the
> reason why Node became so big.

I agree.

> I feel like you're going to get far better pictures and faster results from
> language closer to the metal like C/Rust/Java(???).

Yes, this is self evidently correct. Did you even open the post? One of the
first hyperlinks goes to the widget that I finished the project with, which
uses WebGL to render ~60fps interactive zooms up to the limits of 32 bit
floats: [http://mandelbrot.jfo.click](http://mandelbrot.jfo.click)

Thank you all for reading, it is really awesome to be able to share something
I just learned and am excited about with so many people!!

------
NoGravitas
Scrolling down, I was kind of afraid each time a new image scrolled into view
that it would be The Parrot.

~~~
jfo
What is "The Parrot"? Like party parrot?

~~~
NoGravitas
Langford's Basilisk:
[http://www.infinityplus.co.uk/stories/blit.htm](http://www.infinityplus.co.uk/stories/blit.htm)

~~~
jfo
Wow cool, thanks!

------
kobeya
Somebody introduce this guy to the Mandlebulb.

