Question: Help me check if my code is correct based off the following criteria in the image: here's my code It has a error in regaurds
Help me check if my code is correct based off the following criteria in the image:
here's my code It has a error in regaurds to how it saves but it seems to meet criterias and "import numpy as np
import matplotlib.pyplot as plt
def nfractalK pixel, tol, n:
r # ratio of number points along imaginary axis to number of points along real axis
a j
xleft
xright
ybottom
ytop
x nplinspacexleft, xright, pixel # x real coordinates
y nplinspaceybottom, ytop, roundpixel r # y imaginary coordinates
Re Im npmeshgridx y # meshgrid
Z Re Im j # matrix holding x and y coordinates or points on complex plane
B npzerosroundr pixel pixel float # this matrix keeps track of speed of convergence to a root if Bij is large, iteration converges...
Id nponesBshape # matrix of ones
# roots of polynomial to apply Newton's iteration to in this case pz zn
roots npexpj nppi nparangen n
Zn Z # initial guess for Newt
on's iteration
# iterate the initial guess Zn K times, the iteration is applied to the
# whole matrix using array elementbyelement operations
for k in range K:
Zn a Znn n Znn
for i in rangen:
B npabsZn rootsi toli
# plot commands
pltfigurefigsize
pltsubplot
pltpcolormeshx y B cmap'rainbow', shading'auto'
pltcolorbar
outfile "plotsnfractalsummerpng
pltsavefigoutfile
pltshow
# Example usage:
nfractalK pixel tol n Last thing to note is it outputs a graph successfully along with some errors but I am not sure if it meets criteria
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
