Sharedsupport / 2015-03-31-081856-roots.sagewsOpen in CoCalc
Authors: Harald Schilly, ℏal Snyder, William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
def roots(a, b, c): """ Return roots of a*x^2+b*x+c. """ s = (b*b - 4*a*c).sqrt() return (-b + s)/(2*a) B = CDF(25) %time v = [roots(a,b,c) for a in [-B..B] for b in [-B..B] for c in [-B..B] if a] %time show(points(v, pointsize=1, color='black'), svg=False, figsize=[12,12], xmin=-sqrt(B), xmax=sqrt(B))
CPU time: 1.66 s, Wall time: 1.66 s
CPU time: 7.99 s, Wall time: 10.84 s