1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
import os import numba import numpy as np import matplotlib.pyplot as plt os.chdir(r'D:\projects\wordpress\ex40') os.getcwd() def py_julia_fractal(z_re, z_im, j): for m in range(len(z_re)): for n in range(len(z_im)): z = z_re[m] + 1j * z_im[n] for t in range(256): z = z ** 2 - 0.05 + 0.68j if np.abs(z) > 2.0: #if (z.real * z.real + z.imag * z.imag) > 4.0: # a bit faster j[m, n] = t break jit_julia_fractal = numba.jit(nopython=True)(py_julia_fractal) N = 1024 j = np.zeros((N, N), np.int64) z_real = np.linspace(-1.5, 1.5, N) z_imag = np.linspace(-1.5, 1.5, N) jit_julia_fractal(z_real, z_imag, j) fig, ax = plt.subplots(figsize=(14, 14)) ax.imshow(j, cmap=plt.cm.RdBu_r,extent=[-1.5, 1.5, -1.5, 1.5]) ax.set_xlabel("$\mathrm{Re}(z)$", fontsize=18) ax.set_ylabel("$\mathrm{Im}(z)$", fontsize=18) fig.tight_layout() plt.savefig("example40.png", dpi=100) plt.show() plt.close() <img class=" wp-image-198 aligncenter" src="https://gantovnik.com/bio-tips/wp-content/uploads/2019/01/example40.png" alt="example40" width="628" height="628" /> |
Recent Comments