Mazzy_Code

224 days ago by edhe2226

U = RealDistribution('uniform',[0,1]) U.get_random_element() C = ComplexField(500) C(U.get_random_element()) + C(U.get_random_element()) * C(I) R.<z> = C['z'] import random random.sample(range(10), 1) 
       
[0]
[0]
import random rndpoly1 = C(1) polyOrd = random.sample(range(100), 1) for i in range(polyOrd[0]): 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) 
       
derpoly = rndpoly1.derivative(z) cparray = [] for root in derpoly.roots(): j = root[1] for i in range(j): cparray.append(root[0]) Gout = Graphics() Gout += points(rootarray,color='white', markeredgecolor = 'red', pointsize=20,zorder = 1, marker = "o") Gout += points(cparray,color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*") show(Gout,aspect_ratio=1) 
       
Gout = Graphics() Gout += points(rootarray,color='white', markeredgecolor = 'red', pointsize=20,zorder = 1, marker = "o") for i 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]) Gout += points(cparray,color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*") rndpoly1 = derpoly show(Gout,aspect_ratio=1) 
       
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) 
       
sigma = 1 G = RealDistribution('gaussian', sigma) import random rndpoly1 = C(1) polyOrd = random.sample(range(100), 1) for i in range(polyOrd[0]): randRoot = C(G.get_random_element()) + C(G.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") for i 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]) Gout += points(cparray,color='white', markeredgecolor = 'blue', pointsize=20,zorder = 1, marker = "*") rndpoly1 = derpoly show(Gout,aspect_ratio=1) 
       
results=[] for n in range(1,100): randpoly = C(1) rootarray= [] cparray=[] for j in range(2*n): randpoly *= (z-(C(U.get_random_element()) + C(U.get_random_element())*C(I))) derpoly=randpoly for j in range(n): derpoly=sage.calculus.functional.derivative(derpoly,z) for root in randpoly.roots(): j = root[1] for i in range(j): rootarray.append(C(root[0]**2)) for root in derpoly.roots(): j = root[1] for i in range(j): cparray.append(C(root[0]**2)) results.append(C(sum(rootarray))/C(len(rootarray))-C(sum(cparray))/C(len(cparray))) 
       
print(rootarray) 
       
[]
[]
Gout1 = list_plot([(2*(i + 1), abs(results[i])) for i in range(len(results))], color="green") show(Gout1) 
       
results[1] 
       
0.0000000000000000000000000000000000000000000000000000000000000000000000\
000000000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000
0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000