1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Plotting the Mandelbrot set

  1. Mar 1, 2012 #1
    1. The problem statement, all variables and given/known data
    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.


    2. Relevant equations
    [itex]Z_{n+1}=Z_n^2+c[/itex] for some constant c

    3. The attempt at a solution
    Given: [itex]Z_0=0[/itex], 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 (Text):

    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 [Broken] I'm not really sure why they do this. Is it something to do with using values of [itex]\pm 2[/itex] for x & y and then scaling them to a much larger 300 pixel canvas, rather than just using a [itex]\pm 2[/itex] canvas and plotting many smaller points in explicit increments of 0.01, like I do?
     
    Last edited by a moderator: May 5, 2017
  2. jcsd
  3. Mar 2, 2012 #2
    Bump. :smile:
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook