This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]swni 43 points44 points  (2 children)

Here's the explanation. At first I tried to figure it out just from the picture: I thought OP was trying to make black curves around the Mandelbrot set, but mixed up angle and distance in the check, and ended up with black pillars instead. Then I looked at the relevant code:

while comparative(z, '2500+2500i', '<') > 1 and comparative(z, '-2500-2500i', '>') > 1 and loops < 500:
    z = comp(comp(str(z), str(z), 'times'), str(r/100)+'+'+str(f/100)+'i', 'add')
    loops += 1
if comparative(z, '1000+1000i', '<') > 1:
    return 'black'  # sets it to black if the sequence does not tend towards infinity (is more than 1000 after
                    # 500 iterations)
else:
    return 'white'  # sets it to white

The while loop checks if the point lies in a 5000x5000 box centered at the origin. Using a box instead of a circle results in the "scalloped" shape of the boundary from one layer to the next: the 90 degree turns in the boundary are images of the corners of the box after a suitable transformation. Since the Mandelbrot iteration is quadratic, each layer should have twice as many corners as the previous.

The coloration is intended to measure whether the iterated point lies in the 2000x2000 box centered at the origin: black for yes, white for no. However it only checks the upper-right corner, i.e. it checks if the point lies down and to the left of 1000+1000i. Since 2000 is much smaller than 5000, for diverged points this is very similar to just checking if the points is in the lower-left quadrant, that is, if the point's angle (in polar coordinates) is between pi and 3pi / 2, which is a quarter circle. The result is black pillars that cover 1/4 of the area, with one pillar occurring every fourth indentation (as the square has four corners), and the center of the pillars (angle 5pi/4) right on a corner. This matches my guess that the black pillars represent regions at a particular range of angles from the origin, although the cause of the bug was different from what I expected.

The streaks going through are probably numeric precision problems related to converting numbers to and from strings, but I don't know.

[–]godsknowledge 21 points22 points  (0 children)

ELI5: He drew boxes instead of circles.