Please provide this solution in PYTHON. Thanks in advance.
Plot the Julia set for C=0.285+0.01i
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
# Image width and height; parameters for the plot
im_width, im_height = 500, 500
c = complex(0.285, 0.01)
zabs_max = 10
nit_max = 1000
xmin, xmax = -1.5, 1.5
xwidth = xmax - xmin
ymin, ymax = -1.5, 1.5
yheight = ymax - ymin
julia = np.zeros((im_width, im_height))
for ix in range(im_width):
for iy in range(im_height):
nit = 0
# Map pixel position to a point in the complex plane
z = complex(ix / im_width * xwidth + xmin,
iy / im_height * yheight + ymin)
# Do the iterations
while abs(z) <= zabs_max and nit < nit_max:
z = z**2 + c
nit += 1
shade = 1-np.sqrt(nit / nit_max)
ratio = nit / nit_max
julia[ix,iy] = ratio
fig, ax = plt.subplots()
ax.imshow(julia, interpolation='nearest', cmap=cm.hot)
plt.show()
Get Answers For Free
Most questions answered within 1 hours.