Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -3,11 +3,10 @@ import math
|
|||
def mandelbrot(z , c , n=40):
|
||||
if abs(z) > 1000:
|
||||
return float("nan")
|
||||
elif n > 0:
|
||||
return mandelbrot(z ** 2 + c, c, n - 1)
|
||||
else:
|
||||
if n > 0:
|
||||
return mandelbrot(z ** 2 + c, c, n - 1)
|
||||
else:
|
||||
return z ** 2 + c
|
||||
return z ** 2 + c
|
||||
|
||||
print("\n".join(["".join(["#" if not math.isnan(mandelbrot(0, x + 1j * y).real) else " "
|
||||
for x in [a * 0.02 for a in range(-80, 30)]])
|
||||
|
|
|
|||
25
Task/Mandelbrot-set/Python/mandelbrot-set-3.py
Normal file
25
Task/Mandelbrot-set/Python/mandelbrot-set-3.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from pylab import *
|
||||
from numpy import NaN
|
||||
|
||||
def m(a):
|
||||
z = 0
|
||||
for n in range(1, 100):
|
||||
z = z**2 + a
|
||||
if abs(z) > 2:
|
||||
return n
|
||||
return NaN
|
||||
|
||||
X = arange(-2, .5, .002)
|
||||
Y = arange(-1, 1, .002)
|
||||
Z = zeros((len(Y), len(X)))
|
||||
|
||||
for iy, y in enumerate(Y):
|
||||
print (iy, "of", len(Y))
|
||||
for ix, x in enumerate(X):
|
||||
Z[iy,ix] = m(x + 1j * y)
|
||||
|
||||
imshow(Z, cmap = plt.cm.prism, interpolation = 'none', extent = (X.min(), X.max(), Y.min(), Y.max()))
|
||||
xlabel("Re(c)")
|
||||
ylabel("Im(c)")
|
||||
savefig("mandelbrot_python.svg")
|
||||
show()
|
||||
Loading…
Add table
Add a link
Reference in a new issue