Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Undergrad research examples with cocalc

Views: 534
# Algorithm to plot Thue equation, solutions and roots given a thue equation def thue_graph_finder(thue_input, c): R.<x,y> = QQbar[] ts = [] thue_eq = thue_input(y=1) thue_eq2 = thue_eq.univariate_polynomial() print thue_eq2 thue_eq_roots = thue_eq2.roots() eq_roots = [] for p in thue_eq_roots: eq_roots.append(CC(p[0])) th_init = gp.thueinit(thue_eq2,1) sols = gp.thue(th_init,c) for p in sols: print p if p[1] != 0 and p[2] != 0: t = p[1] / p[2] ts.append(CC(t)) approx_plot = plot([0,0], xmin = -100, ymin = -100, xmax = 100, ymax = 100) if len(ts) > 0: approx_plot = point(ts, pointsize=100, color = "red") root_plot = point(eq_roots, pointsize=100) show(root_plot + approx_plot) from sage.misc.html import HtmlFragment R.<x,y> = QQbar[] F.<x> = ZZ[] p = F.random_element(3).homogenize(y) @interact def _(thue_input = input_box(p, label = '$f$'), c = input_box(ZZ.random_element(1, 50))): print(thue_graph_finder(thue_input, c))
Interact: please open in CoCalc
def plane_curve_finder(thue_input,c): ts = [] thue_eq = thue_input(y=1) thue_eq2 = thue_eq.univariate_polynomial() th_init = gp.thueinit(thue_eq2,1) # what gp returns is "gp integers", which are not sage integers. # This line will convert "gp integers" to the usual sage ZZ elements. sols = [map(ZZ,a) for a in gp.thue(th_init,c)] for p in sols: ts.append(p) approx_plot = point([0,0], color = "white") if len(ts) > 0: approx_plot += point(ts, pointsize=100, color = "red") curve_plot = implicit_plot(thue_input - c, (x,-10,10), (y,-10,10)) show(curve_plot + approx_plot) from sage.misc.html import HtmlFragment R.<x,y> = QQbar[] F.<x,y> = ZZ[] p = F.random_element(3) @interact def _(thue_input = input_box(p, label = '$f$'), c = input_box(17)): print(plane_curve_finder(thue_input, c))
Interact: please open in CoCalc