Hello,
I am playing around with the Mendelbrot set and am running into math problems.
The equation is this: Z(n+1) = Z(n)^2 + C
I am putting this on a graph and drawing circles up to 15 iterations for each Z point.
def update(xy, zs, limit):
z1 = pow(zs,2) + xy #THE EQUATION
print(limit, z1)
xplot = (round(z1.real, 10) + half_dash) * x_space
yplot = (round(z1.imag,10) + half_dash) * y_space
if z1.real > 2 or z1.imag > 2 or z1.real < -2 or z1.imag < -2:
pygame.draw.circle(test_surface, "black", (xplot,yplot), 4)
else:
pygame.draw.circle(test_surface, "blue", (xplot,yplot), 4)
if limit > 0:
update(xy, z1, limit-1)
xy is my x and y coordinate of my mouse on the graph.
zs is the starting point of 0.
xplot and yplot are getting the actual x and y values on the surface.
So the problem is that z1 iterates incorrect numbers and I can’t figure out why. Any ideas?
xy is a complex number.