Sage Days 26

Introduction to Sage via Number Theory

Basic Algebraic Number Theory

Defining Number Fields

{{{id=16| x = polygen(QQ,'x') #or can use x = var('x') #or can create polynomial rings in one of two ways R. = PolynomialRing(QQ) R. = QQ[] K. = NumberField(x^4 - 2*x^2 - 1) K /// Number Field in a with defining polynomial x^4 - 2*x^2 - 1 }}} {{{id=24| a^4 - 2*a^2 - 1 /// 0 }}} {{{id=23| K = NumberField(x^4 - 2*x^2 - 1, 'alpha'); K /// Number Field in alpha with defining polynomial x^4 - 2*x^2 - 1 }}} {{{id=22| alpha /// Traceback (most recent call last): File "", line 1, in File "_sage_input_11.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("YWxwaGE="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/private/var/folders/l5/l55HHC6uExG+F0kEqsPAgU+++TM/-Tmp-/tmpKodarT/___code___.py", line 2, in exec compile(u'alpha' + '\n', '', 'single') File "", line 1, in NameError: name 'alpha' is not defined }}} {{{id=18| K.gen() /// alpha }}} {{{id=50| K.0 /// alpha }}} {{{id=54| C. = CyclotomicField(17); C /// Cyclotomic Field of order 17 and degree 16 }}} {{{id=53| z^17-1 /// 0 }}} {{{id=52| F. = QuadraticField(5); a^2 /// 5 }}} {{{id=51| K = F.extension(x^3 - 2, 'b') /// }}} {{{id=56| L = K.galois_closure('c') /// }}} {{{id=57| L.degree() /// 12 }}} {{{id=58| L.defining_polynomial() /// x^12 - 270*x^10 + 80*x^9 + 30375*x^8 - 1818156*x^6 - 972000*x^5 + 63145575*x^4 + 58429760*x^3 - 1014099750*x^2 - 969332400*x + 8409895009 }}} {{{id=66| G = L.galois_group(); G /// Galois group of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 }}}

Elements of Number Fields

{{{id=48| K = NumberField(x^4 - 2*x^2 - 1, 'alpha'); K /// Number Field in alpha with defining polynomial x^4 - 2*x^2 - 1 }}} {{{id=25| alpha = K.0 s = (1+1/alpha)^10; s /// -120*alpha^3 + 164*alpha^2 + 336*alpha - 324 }}} {{{id=29| s.norm() /// 1024 }}} {{{id=28| s.trace() /// -640 }}} {{{id=27| s.minpoly() /// x^4 + 640*x^3 + 102464*x^2 - 30963712*x + 1024 }}} {{{id=26| alpha.minpoly() /// x^4 - 2*x^2 - 1 }}} {{{id=60| phi = K.embeddings(K); phi /// [ Ring endomorphism of Number Field in alpha with defining polynomial x^4 - 2*x^2 - 1 Defn: alpha |--> alpha, Ring endomorphism of Number Field in alpha with defining polynomial x^4 - 2*x^2 - 1 Defn: alpha |--> -alpha ] }}} {{{id=62| phi[0](s) /// -120*alpha^3 + 164*alpha^2 + 336*alpha - 324 }}} {{{id=63| phi[1](s) /// 120*alpha^3 + 164*alpha^2 - 336*alpha - 324 }}} {{{id=65| L = K.galois_closure('beta'); L /// Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 }}} {{{id=64| Phi = L.embeddings(L); Phi /// [ Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> -beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> -35/33456*beta^7 - 325/33456*beta^5 + 10265/33456*beta^3 - 15639/11152*beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> -7/8364*beta^7 - 65/8364*beta^5 + 2053/8364*beta^3 - 1455/2788*beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> -7/11152*beta^7 - 65/11152*beta^5 + 2053/11152*beta^3 - 18305/11152*beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> 7/11152*beta^7 + 65/11152*beta^5 - 2053/11152*beta^3 + 18305/11152*beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> 7/8364*beta^7 + 65/8364*beta^5 - 2053/8364*beta^3 + 1455/2788*beta, Ring endomorphism of Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 Defn: beta |--> 35/33456*beta^7 + 325/33456*beta^5 - 10265/33456*beta^3 + 15639/11152*beta ] }}} {{{id=68| Phi[0](s) /// Traceback (most recent call last): File "", line 1, in File "_sage_input_126.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("UGhpWzBdKHMp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in File "/private/var/folders/l5/l55HHC6uExG+F0kEqsPAgU+++TM/-Tmp-/tmpLhAtgb/___code___.py", line 3, in exec compile(u'Phi[_sage_const_0 ](s)' + '\n', '', 'single') File "", line 1, in File "map.pyx", line 439, in sage.categories.map.Map.__call__ (sage/categories/map.c:3301) TypeError: -120*alpha^3 + 164*alpha^2 + 336*alpha - 324 must be coercible into Number Field in beta with defining polynomial x^8 - 20*x^6 + 146*x^4 - 460*x^2 + 1681 }}} {{{id=69| em = K.embeddings(L) /// }}} {{{id=70| t = Phi[3](em[0](s)); t /// -83/697*beta^7 + 41/51*beta^6 + 225/697*beta^5 - 205/17*beta^4 + 2437/697*beta^3 + 1517/51*beta^2 - 20491/697*beta - 5495/51 }}}

Nice formating and Latex:

{{{id=74| show(t) ///
\newcommand{\Bold}[1]{\mathbf{#1}}-\frac{83}{697} \beta^{7} + \frac{41}{51} \beta^{6} + \frac{225}{697} \beta^{5} - \frac{205}{17} \beta^{4} + \frac{2437}{697} \beta^{3} + \frac{1517}{51} \beta^{2} - \frac{20491}{697} \beta - \frac{5495}{51}
}}} {{{id=34| show(s) ///
\newcommand{\Bold}[1]{\mathbf{#1}}-120 \alpha^{3} + 164 \alpha^{2} + 336 \alpha - 324
}}} {{{id=73| show(t.matrix()) ///
\newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrrrrrr} -\frac{5495}{51} & -\frac{20491}{697} & \frac{1517}{51} & \frac{2437}{697} & -\frac{205}{17} & \frac{225}{697} & \frac{41}{51} & -\frac{83}{697} \\ \frac{3403}{17} & -\frac{5495}{51} & -\frac{1431}{17} & \frac{1517}{51} & \frac{355}{17} & -\frac{205}{17} & -\frac{35}{17} & \frac{41}{51} \\ -\frac{68921}{51} & \frac{3403}{17} & \frac{4455}{17} & -\frac{1431}{17} & -\frac{4469}{51} & \frac{355}{17} & \frac{205}{51} & -\frac{35}{17} \\ \frac{58835}{17} & -\frac{68921}{51} & -\frac{12697}{17} & \frac{4455}{17} & \frac{3679}{17} & -\frac{4469}{51} & -\frac{345}{17} & \frac{205}{51} \\ -\frac{344605}{51} & \frac{58835}{17} & \frac{25379}{51} & -\frac{12697}{17} & -\frac{16565}{51} & \frac{3679}{17} & -\frac{123}{17} & -\frac{345}{17} \\ \frac{579945}{17} & -\frac{344605}{51} & -\frac{99865}{17} & \frac{25379}{51} & \frac{37673}{17} & -\frac{16565}{51} & -\frac{3221}{17} & -\frac{123}{17} \\ \frac{206763}{17} & \frac{579945}{17} & -\frac{514345}{51} & -\frac{99865}{17} & \frac{79253}{51} & \frac{37673}{17} & -\frac{23945}{51} & -\frac{3221}{17} \\ \frac{5414501}{17} & \frac{206763}{17} & -\frac{901715}{17} & -\frac{514345}{51} & \frac{370401}{17} & \frac{79253}{51} & -\frac{26747}{17} & -\frac{23945}{51} \end{array}\right)
}}}

Fractional Ideals and Residue fields

{{{id=75| K.class_group() /// Class group of order 1 with structure of Number Field in alpha with defining polynomial x^4 - 2*x^2 - 1 }}} {{{id=76| F.
= QuadraticField(-23); F /// Number Field in a with defining polynomial x^2 + 23 }}} {{{id=77| F.class_group() /// Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23 }}} {{{id=80| OF = F.ring_of_integers(); OF /// Maximal Order in Number Field in a with defining polynomial x^2 + 23 }}} {{{id=88| OF.basis() /// [1/2*a + 1/2, a] }}} {{{id=81| OF.discriminant() /// -23 }}} {{{id=32| P = F.prime_above(23); P /// Fractional ideal (-a) }}} {{{id=31| I = F.ideal(2); I.factor() /// (Fractional ideal (2, 1/2*a - 1/2)) * (Fractional ideal (2, 1/2*a + 1/2)) }}} {{{id=42| P2 = I.factor()[0][0] /// }}} {{{id=82| I*P /// Fractional ideal (-2*a) }}} {{{id=83| I/P /// Fractional ideal (-2/23*a) }}} {{{id=84| P.is_principal() /// True }}} {{{id=85| P2.is_principal() /// False }}} {{{id=39| k = P.residue_field() /// }}} {{{id=38| k.order() /// 23 }}} {{{id=41| k(2+a) /// 2 }}} {{{id=45| /// }}} {{{id=86| /// }}}

Elliptic Curves:

Over $\mathbb{Q}$

{{{id=89| E = EllipticCurve([1,2,3,4,5]); E /// Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field }}} {{{id=90| E.minimal_model() /// Elliptic Curve defined by y^2 + x*y = x^3 - x^2 + 4*x + 3 over Rational Field }}} {{{id=1| E1 = EllipticCurve([3,7]); E1 /// Elliptic Curve defined by y^2 = x^3 + 3*x + 7 over Rational Field }}} {{{id=5| E2 = EllipticCurve('389a'); E2 /// Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field }}} {{{id=7| E3 = EllipticCurve([0,1,1,-2,0]); E3 /// Elliptic Curve defined by y^2 + y = x^3 + x^2 - 2*x over Rational Field }}} {{{id=10| E.ap(97) /// -12 }}} {{{id=11| E.rank() /// 1 }}}

Invariants

{{{id=12| E.conductor() /// 10351 }}} {{{id=14| E.discriminant().factor() /// -1 * 11 * 941 }}} {{{id=92| E.tamagawa_numbers() /// [1, 1] }}} {{{id=93| for p in prime_range(20): print E.ap(p) /// 1 0 -3 -1 -1 1 5 4 }}} {{{id=94| E.aplist(20) /// [1, 0, -3, -1, -1, 1, 5, 4] }}}

Rank

{{{id=95| E.rank() /// 1 }}} {{{id=97| E.analytic_rank() /// 1 }}} {{{id=98| E.gens() /// [(1 : 2 : 1)] }}} {{{id=99| F = EllipticCurve('5077a'); F /// Elliptic Curve defined by y^2 + y = x^3 - 7*x + 6 over Rational Field }}} {{{id=100| F.rank() /// 3 }}} {{{id=101| F.analytic_rank() /// 3 }}} {{{id=102| F.gens() /// [(-2 : 3 : 1), (-7/4 : 25/8 : 1), (1 : -1 : 1)] }}} {{{id=103| F.regulator() /// 0.417143558758384 }}} {{{id=104| F.simon_two_descent() /// (3, 3, [(1 : 0 : 1), (0 : 2 : 1), (2 : -1 : 1)]) }}} {{{id=105| print F.mwrank() /// Curve [0,0,1,-7,6] : Basic pair: I=336, J=-10800 disc=35092224 2-adic index bound = 2 By Lemma 5.1(a), 2-adic index = 1 2-adic index = 1 One (I,J) pair Looking for quartics with I = 336, J = -10800 Looking for Type 2 quartics: Trying positive a from 1 up to 5 (square a first...) (1,0,-24,52,-20) --nontrivial...(x:y:z) = (1 : 1 : 0) Point = [4:6:1] height = 1.46677848399307 Rank of B=im(eps) increases to 1 (1,0,-12,4,16) --nontrivial...(x:y:z) = (1 : 1 : 0) Point = [2:0:1] height = 0.767043355331546 Rank of B=im(eps) increases to 2 Trying positive a from 1 up to 5 (...then non-square a) Trying negative a from -1 down to -1 Finished looking for Type 2 quartics. Looking for Type 1 quartics: Trying positive a from 1 up to 6 (square a first...) (1,0,6,28,25) --nontrivial...(x:y:z) = (1 : 1 : 0) Point = [-1:3:1] height = 1.20508110418585 Rank of B=im(eps) increases to 3 (The previous point is on the egg) Exiting search for Type 1 quartics after finding one which is globally soluble. Mordell rank contribution from B=im(eps) = 3 Selmer rank contribution from B=im(eps) = 3 Sha rank contribution from B=im(eps) = 0 Mordell rank contribution from A=ker(eps) = 0 Selmer rank contribution from A=ker(eps) = 0 Sha rank contribution from A=ker(eps) = 0 Used full 2-descent via multiplication-by-2 map Rank = 3 Rank of S^2(E) = 3 Searching for points (bound = 8)...done: found points of rank 3 and regulator 0.417143558758385 Processing points found during 2-descent...done: now regulator = 0.417143558758385 Saturating (bound = 100)...done: points were already saturated. Transferring points from minimal curve [0,0,1,-7,6] back to original curve [0,0,1,-7,6] Generator 1 is [1:-1:1]; height 0.668205165651928 Generator 2 is [-2:3:1]; height 1.36857250535393 Generator 3 is [-14:25:8]; height 2.71735939281229 Regulator = 0.417143558758385 The rank and full Mordell-Weil basis have been determined unconditionally. (0.264629 seconds) }}}

Plotting Elliptic Curves

{{{id=106| plot(E, plot_points=300, thickness=2, color=hue(.75), xmax=2) /// }}}

Elliptic Curves over Finite Fields

{{{id=108| k.
= GF(7^6); k /// Finite Field in a of size 7^6 }}} {{{id=110| E = EllipticCurve(k, [a,a^2]) E.cardinality() /// 117837 }}} {{{id=111| time E.abelian_group() /// Additive abelian group isomorphic to Z/117837 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + a*x + a^2 over Finite Field in a of size 7^6 Time: CPU 0.12 s, Wall: 0.12 s }}} {{{id=116| E = EllipticCurve([1..5]) time ap = E.aplist(10^6) /// Time: CPU 3.80 s, Wall: 3.82 s }}} {{{id=113| @interact def f(p=(389,primes(3,1000))): show(EllipticCurve(GF(p), [1..5]).plot(), frame=True) /// }}}

Elliptic Curves over Number Fields

{{{id=114| K. = QuadraticField(2); K /// Number Field in w with defining polynomial x^2 - 2 }}} {{{id=118| E = EllipticCurve([ 0, -1, 1, -3*w -4, 3*w + 4 ]); show(E) ///
\newcommand{\Bold}[1]{\mathbf{#1}}y^2 + y = x^3 + \left(-1\right)x^2 + \left(-3 \sqrt{2} - 4\right)x + \left(3 \sqrt{2} + 4\right)
}}} {{{id=119| show(E.j_invariant()) ///
\newcommand{\Bold}[1]{\mathbf{#1}}\frac{1732608}{1031} \sqrt{2} + \frac{266240}{1031}
}}} {{{id=120| N = E.conductor(); N /// Fractional ideal (-24*w + 11) }}} {{{id=121| N.norm().factor() /// 1031 }}} {{{id=122| E.tamagawa_numbers() /// [1] }}} {{{id=123| time T = E.simon_two_descent(); T /// Time: CPU 0.11 s, Wall: 0.42 s (2, 2, [(w + 3/2 : -1/4*w - 1 : 1), (-w - 1 : -w - 2 : 1)]) }}} {{{id=124| P, Q = T[2] /// }}} {{{id=125| P.height() /// 0.933266708161421 }}} {{{id=126| Q.height() /// 0.183656956219703 }}} {{{id=127| E.height_pairing_matrix([P,Q]).det() /// 0.0235582958658636 }}} {{{id=128| embs = K.embeddings(CC) Lambda = E.period_lattice(embs[0]); Lambda /// Period lattice associated to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-3*w-4)*x + (3*w+4) over Number Field in w with defining polynomial x^2 - 2 with respect to the embedding Ring morphism: From: Number Field in w with defining polynomial x^2 - 2 To: Algebraic Field Defn: w |--> -1.414213562373095? }}} {{{id=129| Lambda.basis() /// (10.7444017502464, 5.37220087512321 + 2.12681775202610*I) }}}

Over a number field we do not have quite as much functionality.  

For example, L-series and $a_p$ are not yet implemented.

{{{id=130| /// }}}