Mandelbrot set: Difference between revisions
Content added Content deleted
(→{{header|TeX}}: Separated solutions by language and minimalised.) |
(→Python with and without NumPy (no optimizations): Heading changed: Escape time and normalized iteration count (Basic)) |
||
Line 7,154:
plt.show()</lang>
===Basic: Escape time and normalized iteration count===
Actually the same, but without optimizations and therefore better suited for teaching. At first without NumPy, but already with complex numbers.
<lang python>import
Line 7,183 ⟶ 7,182:
z = z ** 2 + c
T[i][j] = k + 1
plt.imshow(T, cmap=plt.cm.twilight_shifted)
plt.savefig("Mandelbrot.png", dpi=250)</lang>
At second with NumPy and complex matrices. The ''normalized iteration count'' algorithm is used, which provides a smooth transition of colors between iterations (cf. Wikipedia: [https://en.wikipedia.org/wiki/Plotting_algorithms_for_the_Mandelbrot_set#Continuous_(smooth)_coloring ''Plotting algorithms for the Mandelbrot set: Continuous (smooth) coloring'']).
<lang python>import numpy as np
import matplotlib.pyplot as plt
|