# Homework Help: Plotting the Mandelbrot set

1. Mar 1, 2012

### cdotter

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
$Z_{n+1}=Z_n^2+c$ for some constant c

3. 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 (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 $\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: May 5, 2017
2. Mar 2, 2012

Bump.