Real_Case

233 days ago by edhe2226

U=RealDistribution('uniform',[0,1]) R=RealField(5000) S=RealField(300) #T=RealDistribution('uniform',[0,2*pi]) P.<z>=R['z'] 
       
plot(0, (0, 1), color="black", axes=False) + point((0,0), color="black", size=100, marker="|") + point((1,0), color="black", size=100, marker="|") def gen_poly(ord): poly = R(1) for i in range(ord): poly *= (z-R(U.get_random_element())) return poly def get_roots(poly): rootarray = [] for root in poly.roots(): multiplicity=root[1] for mult in range (multiplicity): rootarray.append(S(root[0])) return rootarray poly = gen_poly(100) deriv = sage.calculus.functional.derivative(poly, z) Graph1 = plot(0, (0, 1), color="black", axes=False) + point((0,0), color="black", size=100, marker="|") + point((1,0), color="black", size=100, marker="|") + points([(root, 0) for root in get_roots(poly)], color="red", size=50, marker="|") Graph1 += plot(-.1, (0, 1), color="black", axes=False) + point((0,0-.1), color="black", size=100, marker="|") + point((1,-.1), color="black", size=100, marker="|") + points([(root, -.1) for root in get_roots(deriv)], color="green", size=50, marker="|") show(Graph1, aspect_ratio=0.5) 
       
from sage.plot.histogram import Histogram max_roots = [] max_crit_points = [] for i in range(100): poly = gen_poly(100) deriv = sage.calculus.functional.derivative(poly, z) #polyroots = get_roots(poly) #polyroots.remove(S(1)) max_roots.append(S(max(get_roots(poly)))) max_crit_points.append(S(max(get_roots(deriv)))) show(histogram([100*(1-max_roots[i]) for i in range(len(maxroots))], bins=50)) show(histogram([100*(1-max_crit_points[i]) for i in range(len(maxroots))], bins=50)) show(histogram([100*(max_crit_points[i]-maxroots[i]) for i in range(len(maxroots))], bins=50)) 
       

rootarray=get_roots(gen_poly(100)) rootarray.remove(S(1)) print(max(rootarray)) 
       
0.9840200922917574644088745117187500000000000000000000000000000000000000\
00000000000000000000
0.984020092291757464408874511718750000000000000000000000000000000000000000000000000000000000