Help using clisk for exploring fractals


My 9-yo son thinks fractals are very exciting. We have been watching Youtube videos and reading stuff on the web together. And now we decided that we should play a bit with fractals ourselves and I found the clisk library and specifically this blog post, by the clisk author, on how to use it for rendering the Mandelbrot set. The most basic example given in the blog post:

(show (viewport [-2 -1.5] [1 1.5]
    :while (v- 2 (length [x y]))
    :update (v+ c [(v- (v* x x) (v* y y)) (v* 2 x y)])
    :result (vplasma (v* 0.1 'i))
    :bailout-result black
    :max-iterations 1000)) 1024 1024)

That’s cool. The classic Mandelbrot is very mysterious and fun to investigate. But we would like to explore some other fractals, including some other powers of z for the Mandelbrot. The fractal function in clisk is versitile enough to allow that, but my experience with math stops me from figuring out how. The function being iterated over is in the :update key:

:update (v+ c [(v- (v* x x) (v* y y)) (v* 2 x y)])

I can sort of see c + z² there, if I squint, but fail to make the necessary connection. Any mathy people here that could help my son and my figuring this out? A first question is how to make it render c + z³. But really, I’d like some help to understanding what the connection is so that we can start rendering fractals at will here.

Thanks in advance! :sunny:


Wait, that does look a bit like (x + y)² => x² + y² + 2xy.

(Still failing to grok it, though…)


I might be totally wrong (not a mathy person), but going by the first answer to, it looks like Mandelbrot’s c + z^2, z being complex for x + yi, is written as c + (x^2 - y^2 + 2xy) (without the imaginary part).

Edit: Just noticed the vector addition with c is saying + [(x^2-y^2) 2xy], not the (x^2 - y^2 + 2xy) form. I suppose it’s got something to do with vector addition and complex numbers which I’m not qualified to comment on


You are mathier than I! Or at least smarter. Wonderful!

Asking Wolfram Alpha to expand (x + yi)^3 yields: x^3 + 3 i x^2 y - 3 x y^2 - i y^3.

I then assumed that the vector syntax was [non-complex complex] and used this update function:

:update (v+ c [(v- (v* x x x) (v* 3 x y y)) (v- (v* 3 y x x) (v* y y y))])

Lo and behold:

I can’t thank you enough! It was too long ago I dabbled with complex math and I have allowed myself to forget too much about it. But that must change now, for my son’s sake.