What is the best approach for plotting the Mandelbrot set using a computer?

cdotter
Messages
305
Reaction score
0

Homework Statement


Note: This is not for homework. I'm trying to teach myself programming and this looks like a fun project. I want to plot the Mandelbrot set using a computer.


Homework Equations


Z_{n+1}=Z_n^2+c for some constant c

The Attempt at a Solution


Given: Z_0=0, maximum of 100 iterations, step value of 0.01.

Conceptually, I think I want to plot the points on Cartesian coordinate system centered at (0,0). Then x=Re(c) and y=Im(c).
Code:
Loop across the x plane in increments of 0.01
    Loop across the y plane from in increments of 0.01
        Iterate Z_{n+1}=Z_n^2+c 100 times, where is (x,y)=x+iy, breaking if abs(Z)>=2
            If it breaks record the iteration it broke on.
From there I would plot all the points using the corresponding iteration number to give a color. Points that are part of the set would be one color, points that are not part of the set would be another colored that is reflective of the number of iterations before abs(Z)>=2.

Conceptually, is this correct?

I read another example where the author calculates step values dx and dy instead of explicitly defining them: http://kemenaran.winosx.com/?2008/05/16/126-petit-ensemble-de-mandelbrot-en-python I'm not really sure why they do this. Is it something to do with using values of \pm 2 for x & y and then scaling them to a much larger 300 pixel canvas, rather than just using a \pm 2 canvas and plotting many smaller points in explicit increments of 0.01, like I do?
 
Last edited by a moderator:
Physics news on Phys.org
Bump. :smile:
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top