Skip to content

Instantly share code, notes, and snippets.

@adiamaan92
Created September 26, 2021 15:04
Show Gist options
  • Save adiamaan92/326ae6c50f9b526283275053b7f7eb74 to your computer and use it in GitHub Desktop.
Save adiamaan92/326ae6c50f9b526283275053b7f7eb74 to your computer and use it in GitHub Desktop.
Iterate - Diverge logic for Mandelbrot set
import numpy as np
x_dim, y_dim = 500, 500
x = np.linspace(-2, 1, x_dim)
y = np.linspace(-1.5, 1.5, y_dim)
max_iterations = 100
array = np.zeroes((x_dim, y_dim))
for i in range(x):
for j in range(y):
n, z = 0, 0
c = np.complex(x[i], y[j])
n = 0
while np.abs(z) < 2 and n <= max_iterations:
z = brot_equation(z, c)
n += 1
array[j, i] = n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment