import random
rndpoly1 = C(1)
polyOrd = random.sample(range(100), 1)
for i in range(40):
randRoot = C(U.get_random_element()) + C(U.get_random_element())*C(I)
rndpoly1 = rndpoly1*(z - randRoot)
rootarray = []
for root in rndpoly1.roots():
j = root[1]
for i in range(j):
rootarray.append(root[0])
Gout = Graphics()
Gout += points(rootarray,color='white', markeredgecolor = 'red', pointsize=20,zorder = 1, marker = "o")
#show(Gout,aspect_ratio=1)
for m in range(20):
derpoly = rndpoly1.derivative(z)
cparray = []
for root in derpoly.roots():
j = root[1]
for i in range(j):
cparray.append(root[0])
if m == 19:
Gout += points(root[0],color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*")
else:
Gout += points(root[0],color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*",alpha=.3)
#Gout += points(cparray,color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*")
rndpoly1 = derpoly
Gout += points(sum(cparray)/len(cparray),color='white', markeredgecolor = 'magenta', pointsize=40,zorder = 1, marker = "p")
Gout += points(sum(rootarray)/len(rootarray),color='white', markeredgecolor = 'orange', pointsize=40,zorder = 1, marker = "d")
show(Gout,aspect_ratio=1)