#!/usr/bin/python # elliptic.py # (c) William Stein, 2000 import cgi # cgi-bin import Documents, HTML import misc import constants # import mfd # modular forms database import magma import os print "Content-Type: text/html" # HTML is following print # blank line, end of headers form = cgi.FieldStorage() def is_numeric(c): return (c >= '0' and c <='9') or c=='-' or c=='+' or c=='/' def nextnum(s): if len(s) == 0: return 0, 0, 0 i=0 while not is_numeric(s[i]): i = i+1 if i >= len(s): return 0, 0, 0 j=i+1 while j < len(s) and is_numeric(s[j]): j = j+1 return 1, s[i:j], s[j:] def parse(form): ERROR_MESSAGE = "Please enter either 2, 3 or 5 rational numbers in the a-invariants field."; if not form.has_key("ainvariants"): print "

Error

" print ERROR_MESSAGE return 0, 0 s = form["ainvariants"].value e, n1, s = nextnum(s) if not e: print "

Error

" print ERROR_MESSAGE return 0,0 e, n2, s = nextnum(s) if not e: print "

Error

" print ERROR_MESSAGE return 0,0 e, n3, s = nextnum(s) if not e: return 1, ('0','0','0',n1,n2) e, n4, s = nextnum(s) if not e: return 1, ('0',n1,'0',n2,n3) e, n5, s = nextnum(s) if not e: print "

Error

" print ERROR_MESSAGE return 0,0 return 1, (n1,n2,n3,n4,n5) def html_curvedata(ainvs,hostname): doc = Documents.Document() doc.append(HTML.TITLE('Modular Forms Database: Curve data')) doc.append(HTML.LINK(rel="stylesheet", type="text/css", \ HREF="http://%s/mfd/mfd.css"%hostname, TITLE="was")) body = HTML.BODY(klass="top") doc.append(body) body.append(HTML.CENTER( HTML.H1("The elliptic curve defined by [%s,%s,%s,%s,%s].    "%ainvs))) body.append(HTML.CENTER(HTML.A("
BACK

", \ href="http://%s/mfd/elliptic/index.html"%hostname))) cmd = "function factor(x) return Factorization(Numerator(x)) cat " +\ " [ : a in Factorization(Denominator(x))]; end function;\n "+\ "ainvs := [%s,%s,%s,%s,%s]; if not IsEllipticCurve(ainvs) then "%ainvs +\ "ans := \"The Weierstrass equation is singular.\"; " + \ " else E:=EllipticCurve(ainvs); G,f:=TorsionSubgroup(E); " + \ "eig := qEigenform(E,100); periods := Periods(E); "+ \ "ans:=Sprintf(\"
The %o.