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)