我试图在 python 中制作一个 julia 集,但我的输出在一些早期过程中是 Nan。我不知道是什么原因造成的。只是为了坦白:我的编程课不好,我真的不知道我在做什么,这主要是我从谷歌那里学到的。
这是代码:
import matplotlib.pyplot as plt
c = complex(1.5,-0.6)
xli = []
yli = []
while True:
z = c
for i in range(1,101):
if abs(z) > 2.0:
break
z = z*z + c
if i>0 and i <100:
break
xi = -1.24
xf = 1.4
yi = -2.9
yf = 2.1
#the loop for the julia set
for k in range(1,51):
x = xi + k*(xf-xi)/50
for n in range(51):
y = yi + n*(yf-yi)/50
z = z+ x + y* 1j
print z
for i in range(51):
z = z*z + c #the error is coming from somewhere around here
if abs(z) > 2: #not sure if this is correct
xli.append(x)
yli.append(y)
plt.plot(xli,yli,'bo')
plt.show()
print xli
print yli
先感谢您 :)