I'm new to Mathematica and will need some help in coding the Mandelbrot set.
I don't want to use MandelbrotSetPlot
since I want to understand the interior mechanisms of the set. I'm also not interested in speed but just want to keep it simple.
Where do I start? z=z^2+c is relatively simple but:
- How do I make clear that the function should be iterated? I tried NestList, NestGraph and NestWhile but nothing seems to work. Is there a way to include n and n+1 instead?
- How do I make clear that c is a complex number? Can I define
c=r+i
, for example?
I found this Julia set here(Why is this Mandelbrot set's implementation infeasible: takes a massive amount of time to do?) which makes sense to me:
ArrayPlot[Table[
NestWhile[#^2 - (0. - 1 I) & , r + i I, Abs[#] < 2.0 &, 1, 10],
{r, -2, 2, 0.005},
{i, -2, 2, 0.005}]]
But a Mandelbrot should have a variable c instead, that's right?
Thanks in advance and sorry for the stupid questions.
0. - 1 I
to(r + i I)
. Mandelbrot is $z_{n+1}\leftarrow z_n^2 + c$ where $c$ is the intial $z_0$ - also switch your {r,...} and {i,...} ranges in the table over to rotate it by 90*. And consider usingParallelTable
for better performance. $\endgroup$ – flinty Jun 21 '20 at 14:05NestWhile
and this is the most efficient and expressive approach to this problem. There is no need to refer ton
andn+1
and you should continue to experiment with constructs likeNest
,FixedPoint
,Map
, as you learn Mathematica. Also if you have any syntax trouble, these answers are a good place to start mathematica.stackexchange.com/questions/18393/… $\endgroup$ – flinty Jun 21 '20 at 14:41