Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2018 15:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import time #timing
import numpy as np #arrays
import numba as nb #speed
x_dim = 1000
y_dim = 1000
x_min = -1.8
x_max = 1.8
y_min = -1.8j
y_max = 1.8j
z = np.zeros((y_dim,x_dim),dtype='complex128')
for l in range(y_dim):
z[l] = np.linspace(x_min,x_max,x_dim) -np.linspace(y_min,y_max,y_dim)[l]
def julia_raw_python(c,z):
it = 0
max_iter = 100
while(it < max_iter):
#These will be expensive!
for y in range(y_dim):
for x in range(x_dim):
if abs(z[y][x]) < 10: #Runaway condition
z[y][x] = z[y][x]**2 + c #square and add c everywhere
it += 1
return z
start = time.perf_counter()
julia_raw_python(-.4+.6j,z) #arbitrary choice of c
end = time.perf_counter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment