-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add complex * fix pylint * add julia * add lowres * add highres
- Loading branch information
1 parent
ca8ecf5
commit bff9056
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
np.warnings.filterwarnings("ignore") | ||
|
||
|
||
def is_stable(candidate, num_iterations): | ||
z = 0 | ||
for _ in range(num_iterations): | ||
z = z ** 2 + candidate | ||
return abs(z) <= 2 | ||
|
||
|
||
def complex_matrix(xmin, xmax, ymin, ymax, pixel_density): | ||
re = np.linspace(xmin, xmax, int((xmax - xmin) * pixel_density)) | ||
im = np.linspace(ymin, ymax, int((ymax - ymin) * pixel_density)) | ||
return re[np.newaxis, :] + im[:, np.newaxis] * 1j | ||
|
||
|
||
def get_members(candidate, num_iterations): | ||
mask = is_stable(candidate, num_iterations) | ||
return candidate[mask] | ||
|
||
|
||
c = complex_matrix(-2, 0.5, -1.5, 1.5, pixel_density=21) | ||
members = get_members(c, num_iterations=20) | ||
|
||
plt.scatter(members.real, members.imag, color="black", marker=",", s=1) | ||
plt.gca().set_aspect("equal") | ||
plt.axis("off") | ||
plt.tight_layout() | ||
plt.show() | ||
|
||
c = complex_matrix(-2, 0.5, -1.5, 1.5, pixel_density=512) | ||
plt.imshow(is_stable(c, num_iterations=20), cmap="binary") | ||
plt.gca().set_aspect("equal") | ||
plt.axis("off") | ||
plt.tight_layout() | ||
plt.show() |