I need to make a function that tests if a complex number, c is in the Mandelbrot set which is defined as zn+1 = zn2 + c. The values of n are in subscript if that was confusing. The function accepts variables c (some complex number of the form 0 + 0j) and n (number of iterations). To see if c is in the set, I need to test z = z**2 + c > 2. If > 2 I need to return false. Now I know that with c = 0 + 0j and n = 25 I should get True. But I can only get true with very small values of n. What do I need to do differently.
def inMSet(c,n):
for x in range(0, n):
z = n**2 + c
if abs(z) > 2:
return False
else:
return True
forloop doesn't seem to be doing anything. Should you havez = x**2 + cinstead? - Geoff Montee