Elliptic Curves in Sage: Part 1

Creating elliptic curves in Sage:

{{{id=1| EllipticCurve? /// }}} {{{id=2| E = EllipticCurve([3,5]); E /// Elliptic Curve defined by y^2 = x^3 + 3*x + 5 over Rational Field }}} {{{id=96| type(E) /// }}} {{{id=97| S = E.sha(); S /// Shafarevich-Tate group for the Elliptic Curve defined by y^2 = x^3 + 3*x + 5 over Rational Field }}} {{{id=4| EllipticCurve([1,2,3,4,5]) /// Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field }}} {{{id=5| R. = QQ[] E = EllipticCurve([a1,a2,a3,a4,a6]) E /// Elliptic Curve defined by y^2 + a1*x*y + a3*y = x^3 + a2*x^2 + a4*x + a6 over Multivariate Polynomial Ring in a1, a2, a3, a4, a6 over Rational Field }}} {{{id=6| show(E) ///
\newcommand{\Bold}[1]{\mathbf{#1}}y^2 + a_{1}xy + a_{3}y = x^3 + a_{2}x^2 + a_{4}x + a_{6}
}}} {{{id=13| E = EllipticCurve_from_j(1728); E /// Elliptic Curve defined by y^2 = x^3 - x over Rational Field }}} {{{id=12| E.j_invariant() /// 1728 }}} {{{id=8| E = EllipticCurve_from_j(389); E /// Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 10852*x + 811751 over Rational Field }}} {{{id=16| E.j_invariant() /// 389 }}} {{{id=69| E = EllipticCurve_from_c4c6(8,19); E /// Elliptic Curve defined by y^2 = x^3 - 1/6*x - 19/864 over Rational Field }}} {{{id=71| E.c_invariants() /// (8, 19) }}} {{{id=72| E = EllipticCurve_from_cubic('x^3 + y^3 + z^3', [1,-1,0]) /// Traceback (most recent call last): File "", line 1, in File "_sage_input_176.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("RSA9IEVsbGlwdGljQ3VydmVfZnJvbV9jdWJpYygneF4zICsgeV4zICsgel4zJywgWzEsLTEsMF0p"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/private/var/folders/7y/7y-O1iZOGTmMUMnLq7otq++++TI/-Tmp-/tmpJUxIXS/___code___.py", line 3, in exec compile(u"E = EllipticCurve_from_cubic('x^3 + y^3 + z^3', [_sage_const_1 ,-_sage_const_1 ,_sage_const_0 ])" + '\n', '', 'single') File "", line 1, in File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/constructor.py", line 461, in EllipticCurve_from_cubic magma.eval(cmd) File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/interfaces/magma.py", line 521, in eval ans = Expect.eval(self, x, **kwds).replace('\\\n','') File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 983, in eval return '\n'.join([self._eval_line(L, **kwds) for L in code.split('\n') if L != '']) File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 637, in _eval_line self._start() File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/interfaces/magma.py", line 558, in _start Expect._start(self) File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 472, in _start raise RuntimeError, "Unable to start %s"%self.__name RuntimeError: Unable to start magma }}} {{{id=68| /// }}} {{{id=67| /// }}}

The Group Law

Example over QQ

{{{id=34| E = EllipticCurve([0,0,1,-1,0]); E /// Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field }}} {{{id=99| E.integral_points() /// [(-1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1), (2 : 2 : 1), (6 : 14 : 1)] }}} {{{id=100| 14*(14+1) == 6*(6-1)*(6+1) /// True }}} {{{id=101| 14*15 == 5*6*7 /// True }}} {{{id=102| P = E([6,14]); P /// (6 : 14 : 1) }}} {{{id=103| -P /// (6 : -15 : 1) }}} {{{id=43| show(plot(E, thickness=1), gridlines=True) /// }}} {{{id=30| P = E([0,0]); P /// (0 : 0 : 1) }}} {{{id=35| P.curve() /// Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field }}} {{{id=40| R = P + P; R /// (1 : 0 : 1) }}} {{{id=39| R + P /// (-1 : -1 : 1) }}} {{{id=38| 30*P /// (79799551268268089761/62586636021357187216 : -754388827236735824355996347601/495133617181351428873673516736 : 1) }}} {{{id=37| @interact def f(n=(1..200)): print n*P show(plot(E) + plot(n*P,pointsize=100,color='red') ) ///
}}} {{{id=45| /// }}}

Example over Complex Field CC

{{{id=104| ComplexField(200) /// Complex Field with 200 bits of precision }}} {{{id=105| CC /// Complex Field with 53 bits of precision }}} {{{id=44| E = EllipticCurve(CC, [pi, e+I]); E /// Elliptic Curve defined by y^2 = x^3 + 3.14159265358979*x + (2.71828182845905+1.00000000000000*I) over Complex Field with 53 bits of precision }}} {{{id=42| P = E.lift_x(2010); P /// (2010.00000000000 : 90114.4123729358 + 5.54850203018320e-6*I : 1.00000000000000) }}} {{{id=41| P+P /// (502.498826251294 - 5.56916330211630e-7*I : 11264.3278918597 + 0.0000256617911193528*I : 1.00000000000000) }}} {{{id=36| 10*P /// (20.0677989357789 - 0.000353445046938822*I : 90.2629379753835 + 0.00316782900257474*I : 1.00000000000000) }}} {{{id=49| /// }}}

Example over Finite Field

{{{id=51| E = EllipticCurve(GF(7), [2,3]); E /// Elliptic Curve defined by y^2 = x^3 + 2*x + 3 over Finite Field of size 7 }}} {{{id=58| E.plot(pointsize=100) /// }}} {{{id=48| P = E.lift_x(2); P /// (2 : 1 : 1) }}} {{{id=52| P + P /// (3 : 6 : 1) }}} {{{id=21| 3*P /// (6 : 0 : 1) }}} {{{id=53| 4*P /// (3 : 1 : 1) }}} {{{id=55| 5*P /// (2 : 6 : 1) }}} {{{id=56| P.additive_order() /// 6 }}} {{{id=54| 6*P /// (0 : 1 : 0) }}} {{{id=63| /// }}} {{{id=62| /// }}}

Example over "Generic Base"

(this is too much of a pain in Sage still. :-( )

{{{id=77| /// }}} {{{id=19| /// }}}

Visualizing Elliptic Curves

{{{id=107| var('foobar') /// foobar }}} {{{id=106| E = EllipticCurve([1.4, foobar^2]); E /// Elliptic Curve defined by y^2 = x^3 + 1.40000000000000*x + foobar^2 over Symbolic Ring }}} {{{id=60| E = EllipticCurve([1,2,3,4,5]) E.plot(color=hue(.8), thickness=5, xmax=5) /// }}} {{{id=59| E = EllipticCurve(RR, [pi, e]) plot(E) /// }}}

The above looks crappy on the left -- somebody could fix that by increasing the default plot_points parameter.  See below:

{{{id=79| E = EllipticCurve(RR, [pi, e]) plot(E, plot_points=500) /// }}} {{{id=81| E.plot?? /// }}}

We can also plot over prime finite fields:

{{{id=78| EllipticCurve(GF(101), [1,7]).plot() /// }}}

Nontrivial prime power order finite fields aren't yet supported...

{{{id=22| EllipticCurve(GF(27,'a'), [1,7]).plot() /// Traceback (most recent call last): File "", line 1, in File "_sage_input_142.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("RWxsaXB0aWNDdXJ2ZShHRigyNywnYScpLCBbMSw3XSkucGxvdCgp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/private/var/folders/7y/7y-O1iZOGTmMUMnLq7otq++++TI/-Tmp-/tmp8TSQlz/___code___.py", line 3, in exec compile(u"EllipticCurve(GF(_sage_const_27 ,'a'), [_sage_const_1 ,_sage_const_7 ]).plot()" + '\n', '', 'single') File "", line 1, in File "/Users/wstein/sage/install/sage-4.5.3/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_finite_field.py", line 164, in plot raise NotImplementedError NotImplementedError }}}

It's fun to start with a curve over the rational numbers, and vary the finite field:

{{{id=84| @interact def _(p=primes(1000)): E = EllipticCurve(GF(p),[0,0,1,-1,0]) show(E.plot()) ///
}}} {{{id=86| /// }}}

Elliptic Curves define curves over the complex numbers, which we can (try to) plot in various ways, e.g., consider the plot of $\sqrt{x^3+ax+b}$ associated to $y^2=x^3+ax+b$.

 

{{{id=89| var('x') complex_plot(sqrt(x^3+2*x+3), (-2,1), (-1,1)) /// }}} {{{id=91| E = EllipticCurve([2,3]) E.plot(xmin=-2,xmax=1).show(xmin=-2,xmax=1) /// }}} {{{id=92| def f(x1,x2): z = CDF(x1,x2) return abs((z^3+2*z+3).sqrt()) plot3d(f, [-2,1], [-2,2]) /// }}} {{{id=88| /// }}} {{{id=87| /// }}} {{{id=24| /// }}} {{{id=25| /// }}}

Some of What is Missing or Slow

  1. Cubic to curve (see above)
  2. Other coordinates
  3. 3d visualization could be improved
  4. speed of arithmetic (too technical for class?)
{{{id=95| /// }}} {{{id=94| /// }}} {{{id=93| /// }}} {{{id=26| /// }}} {{{id=7| /// }}}