Sage Days 16: ECHIDNA
system:sage

<p>
<center>
<font size="+2">
<b>Elliptic Curves and Higher Dimensional Analogues</b><br>
<i>Open source Magma extensions in Sage</i><br>
</font>
<font size="+1">
<a href="http://echidna.maths.usyd.edu.au/kohel/alg/">http://echidna.maths.usyd.edu.au/kohel/alg/</a>
</font>
</center>
<br>
<p>

This is a repository of of open source GPL code which represents many years of research with many 
collaborators. Once you have installed the echidna package, to attach ECHIDNA to your Magma shell 
in Sage you just do:

{{{id=0|
magma.attach_echidna()
///
}}}

In addition there are various databases which may be of interest for your research in arithmetic geometry, 
complex multiplication, cryptography, modular forms, and other areas of number theory.
<p>

<h3>First, a few sensible definitions...</h3>

{{{id=10|
%magma
ZZ := IntegerRing();
F<x> := FunctionField(ZZ);
Factorization((x^7-x)/(x^8-1));
///



























[
<x, 1>,
<x^2 - x + 1, 1>,
<x^2 + x + 1, 1>,
<x^2 + 1, -1>,
<x^4 + 1, -1>
]
}}}

{{{id=39|
%sage
F.<x> = FunctionField(ZZ)
((x^7-x)/(x^8-1)).factor()
///

























x * (x^2 + 1)^-1 * (x^2 - x + 1) * (x^2 + x + 1) * (x^4 + 1)^-1
}}}

{{{id=13|
%magma
Factorization((2^7-2)/(2^8-1))
///

























[ <2, 1>, <3, 1>, <7, 1>, <5, -1>, <17, -1> ]
}}}

{{{id=40|
%sage
((2^7-2)/(2^8-1)).factor()
///

























2 * 3 * 5^-1 * 7 * 17^-1
}}}

{{{id=15|
%magma
F<x,y> := FunctionField(ZZ,2);
f := x*(x^6-y^6)/(x^8-y^8);
f([2,1])
///



























42/85
}}}

{{{id=44|
%magma
Factorization(f([2,1]));
///

























[ <2, 1>, <3, 1>, <7, 1>, <5, -1>, <17, -1> ]
}}}

{{{id=17|
%sage
F.<x,y> = FunctionField(ZZ,2)
f = x*(x^6-y^6)/(x^8-y^8)
f([2,1])
///

























42/85
}}}

{{{id=20|
%sage
f([2,1]).factor()
///

























2 * 3 * 5^-1 * 7 * 17^-1
}}}

<h2 style="text-align: center;">Brandt modules</h2>

{{{id=1|
%sage
M = BrandtModule(71)
M.decomposition(bound=7)
///

























[
Subspace of dimension 1 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field
]
}}}

{{{id=26|
%sage
for N in M.decomposition(bound=7):
    print N
    print N.basis_matrix()
///

























Subspace of dimension 1 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field
[  1   2   2   2   2   2 2/3]
Subspace of dimension 3 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field
[ 1  0 -1  0  0  1 -1]
[ 0  1 -1  0  1 -1  0]
[ 0  0  0  1  0 -1  0]
Subspace of dimension 3 of Brandt module of dimension 7 of level 71 of weight 2 over Rational Field
[   1    0    0 -1/2 -1/2 -1/2  1/2]
[   0    1    0    0   -1    0    0]
[   0    0    1 -1/2  1/2 -1/2 -1/2]
}}}

{{{id=2|
%magma
M := BrandtModule(71);
Decomposition(M,7);
///


























[
Brandt module of level (71,1), dimension 1, and degree 7 over Integer Ring,
Brandt module of level (71,1), dimension 3, and degree 7 over Integer Ring,
Brandt module of level (71,1), dimension 3, and degree 7 over Integer Ring
]
}}}

{{{id=27|
%magma
for N in Decomposition(M,7) do
    print N;
    print BasisMatrix(N);
end for;
///




























Brandt module of level (71,1), dimension 1, and degree 7 over Integer Ring
[3 2 6 6 6 6 6]
Brandt module of level (71,1), dimension 3, and degree 7 over Integer Ring
[ 1 -1  0  0 -1  2 -1]
[ 0  0  1  0  0 -1  0]
[ 0  0  0  1 -1  1 -1]
Brandt module of level (71,1), dimension 3, and degree 7 over Integer Ring
[ 1  0 -1  1  0 -1  0]
[ 0  1  1 -2  0  1 -1]
[ 0  0  0  0  1  0 -1]
}}}

{{{id=3|
%sage
M = BrandtModule(71,2)
M.decomposition(bound=7,anemic=False)
///

























[
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 1 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field,
Subspace of dimension 3 of Brandt module of dimension 18 of level 71*2 of weight 2 over Rational Field
]
}}}

{{{id=4|
%magma
M := BrandtModule(71,2);
Decomposition(M,7);
///


























[
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 1, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 3, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 3, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 3, and degree 18 over Integer Ring,
Brandt module of level (71,2), dimension 3, and degree 18 over Integer Ring
]
}}}

<h2 style="text-align: center;">Quaternion algebras, lattice genera, and Hecke operators</h2>

We can enumerate all representative lattices in a genus.

{{{id=22|
%magma
p := 389;
O := QuaternionOrder(p);
L := NormModule(O);
G := Genus(L);
print G;
// time Representatives(G); // 4 minutes to enumerate 319 representatives...
///




















Genus of Standard Lattice of rank 4 and degree 4
Determinant: 151321
Factored Determinant: 389^2
Inner Product Matrix:
[  2   0   1   1]
[  0   4  -1   2]
[  1  -1  98   0]
[  1   2   0 196]
}}}

Even without enumeration, we can verify equality of two genera locally:

{{{id=24|
%magma
A = Matrix([ [2, -1, 0, 1], [-1, 2, 1, -1], [0, 1, 260, -130], [1, -1, -130, 260] ]);
M = RSpace(ZZ,4,A);
F = Genus(M);
F eq G;
///























true
}}}

<p>
Following the idea of Birch, we can create a ternary lattice which captures half of the Hecke eigenspace 
of weight 2 modular forms.
</p>

{{{id=28|
%magma
A = GramMatrix(L);                                                
D = Matrix(3,[ A[1,1]*A[i,j] - A[1,i]*A[1,j] : i, j in [2..4] ]);                                  
N = LatticeWithGram(D);                                                                            
N = LatticeWithGram(2*p*GramMatrix(Dual(N)));
N;
///























Standard Lattice of rank 3 and degree 3
Determinant: 778
Factored Determinant: 2 * 389
Minimum: 2
Kissing Number: 2 
Inner Product Matrix:
[ 2  0 -1]
[ 0  4  1]
[-1  1 98]
}}}

The number of representatives is determined by naive enumeration;

{{{id=30|
%magma                                                                           
H := Genus(N);
time #H;
///























22
Time: 1.610
}}}

which should be improved using the mass formula (which we can also compute naively):

{{{id=34|
%magma
auts = [ #AutomorphismGroup(X) : X in Representatives(H) ];
print auts;
print "Mass:", &+[ 1/m : m in auts ];
///





















[ 4, 4, 4, 4, 2, 2, 4, 2, 4, 2, 4, 2, 2, 2, 2, 4, 2, 4, 2, 2, 12, 4 ]
Mass: 97/12
}}}

Now we can follow Birch's idea for computing Hecke operators 
as the adjacency matrices of Kneser's neighboring method:

{{{id=43|
%magma
for p in [2,3,5,7] do
    time Tp := AdjacencyMatrix(H,p);
    Factorization(CharacteristicPolynomial(Tp));
end for;
///






















Time: 1.080
[
<x - 3, 1>,
<x + 2, 1>,
<x^20 - 3*x^19 - 29*x^18 + 91*x^17 + 338*x^16 - 1130*x^15 - 2023*x^14 + 7432*x^13 + 6558*x^12 - 28021*x^11 - 10909*x^10 + 61267*x^9 + 6954*x^8 - 74752*x^7 + 1407*x^6 + 46330*x^5 - 1087*x^4 - 12558*x^3 - 942*x^2 + 960*x + 148, 1>
]
Time: 1.520
[
<x - 4, 1>,
<x + 2, 1>,
<x^20 - 11*x^19 + 19*x^18 + 204*x^17 - 845*x^16 - 781*x^15 + 8883*x^14 - 6177*x^13 - 40916*x^12 + 63058*x^11 + 85034*x^10 - 215618*x^9 - 46920*x^8 + 342529*x^7 - 84612*x^6 - 241030*x^5 + 112365*x^4 + 51018*x^3 - 28526*x^2 + 3560*x - 100, 1>
]
Time: 2.150
[
<x - 6, 1>,
<x + 3, 1>,
<x^20 - x^19 - 58*x^18 + 69*x^17 + 1338*x^16 - 1962*x^15 - 15578*x^14 + 28633*x^13 + 93460*x^12 - 224324*x^11 - 236982*x^10 + 902782*x^9 - 92649*x^8 - 1549758*x^7 + 1240027*x^6 + 457997*x^5 - 897661*x^4 + 293181*x^3 + 17361*x^2 - 16713*x + 757, 1>
]
Time: 2.510
[
<x - 8, 1>,
<x + 5, 1>,
<x^20 - 12*x^19 - 8*x^18 + 602*x^17 - 1355*x^16 - 11751*x^15 + 44797*x^14 + 105012*x^13 - 632038*x^12 - 274991*x^11 + 4756743*x^10 - 2413492*x^9 - 19377380*x^8 + 21737168*x^7 + 37613472*x^6 - 64826048*x^5 - 17117376*x^4 + 68169472*x^3 - 23637760*x^2 - 4162560*x + 1715200, 1>
]
}}}

Now let's check that this gives reasonable Hecke eigenvalues:

{{{id=56|
%magma                                                                                         
E := EllipticCurve(DBEC,389,1,1);                                                                  
[ TraceOfFrobenius(E,GF(p)) : p in [2,3,5,7] ];
///




















[ -2, -2, -3, -5 ]
}}}

<h2 style="text-align: center;">Heights on elliptic curves</h2>

{{{id=72|
%magma
K<i> := QuadraticField(-1);
EK := E(K);
P1 := EK![0,0,1];
P2 := EK![1,0,1];
Q1 := EK![ -13/4, 1/8*(33*i - 4), 1 ];
IsLinearlyIndependent([P1,P2,Q1]);
///
























true
}}}

{{{id=73|
%sage
show(magma("HeightPairingMatrix([P1,P2,Q1]);").sage())
///



















<html><div class="math">\left(\begin{array}{rrr}
0.32700077365160495184435215238 & 0.058522674844878951747663984109 & -6.7762635780344027125465800054 \times 10^{-21} \\
0.058522674844878951747663984109 & 0.47671165934373953738278266792 & 1.0164395367051604068819870008 \times 10^{-20} \\
-6.7762635780344027125465800054 \times 10^{-21} & 1.0164395367051604068819870008 \times 10^{-20} & 2.7069217577806433779801040945
\end{array}\right)</div></html>
}}}

<h2 style="text-align: center;">Elliptic curves and canonical lifting algorithms</h2>

{{{id=11|
%magma
FF<s> := FiniteField(3,71);
E := EllipticCurveWithjInvariant(Random(FF));
q := #FF;
time t := AGMTrace(E);
print "Trace:", t;
print "Order:", q + 1 - t;;
///




























Time: 0.230
Trace: -145710267643441352
Order: 7509466514979724949656983601698900
}}}

<p>For several years this was the fastest algorithm available, but Mike Harrison has now implemented canonical lifting algorithms in Magma...</p>

{{{id=35|
%magma
time "Order:", #E;
///



























Order: 7509466514979724937503719689210631
Time: 0.140
}}}

{{{id=36|
%magma
FF := FiniteField(13,117);
E := EllipticCurveWithjInvariant(Random(FF));
time t := TraceOfFrobenius(E);
///



























Time: 1.680
}}}

{{{id=12|
%magma
time t eq AGMTrace(E);
///

























true
Time: 6.510
}}}

<p><span style="color: #000080;"><strong>Exercise:</strong></span> Port this code to Sage, then improve and extend it.</p>

<p><h2 style="text-align: center;">... using Magma in Sage ...</h2></p>

<p><span style="text-decoration: underline;"><span style="color: #993300;"><strong>Caution:</strong></span></span> FF = FiniteField(3,71) doesn't do what you might think.</p>

{{{id=14|
%sage
FF.<s> = FiniteField(3^71)
E = EllipticCurve_from_j(FF.random_element())
# Don't try this: E.trace_of_frobenius()
q = FF.cardinality()
t = ZZ(magma(E).AGMTrace())
E._order = q + 1 - t
print "Trace:", E.trace_of_frobenius()
print "Order:", E.order()
///

























Trace: -158953772870405074
Order: 7509466514979724962900488828662622
}}}

<h2 style="text-align: center;">Quartic CM fields,&nbsp; genus 2 curves, and CM Igusa invariants</h2>

{{{id=5|
%magma
DBCM := QuarticCMFieldDatabase();
DBG2 := Genus2CurvesDatabase();
DBIX := IgusaLIXDatabase();
///
}}}

{{{id=6|
%magma
DABInvs := QuarticCMFieldInvariantsWithClassNumber(DBCM,8,2);
#DABInvs;
///


























2108
}}}

{{{id=7|
%magma
DAB := DABInvs[1];
print "DAB:", DAB; 
print "Igusa:", DAB in DBIX;
///


























DAB: [ 5, 27, 151 ]
Igusa: true
}}}

{{{id=16|
%magma
K<t> := QuarticCMField(DAB);
K;
///


























Number Field with defining polynomial x^4 + 27*x^2 + 151 over the Rational Field
}}}

<p><span style="color: #333399;"><strong>Exercise:</strong></span> Create a class for quartic CM fields in Sage.</p>

{{{id=18|
%magma
DABInvs[[1..16]];
///

























[
[ 5, 27, 151 ],
[ 5, 27, 171 ],
[ 5, 28, 191 ],
[ 5, 30, 205 ],
[ 5, 30, 220 ],
[ 5, 34, 284 ],
[ 5, 35, 305 ],
[ 5, 36, 279 ],
[ 5, 36, 319 ],
[ 5, 37, 311 ],
[ 5, 38, 341 ],
[ 5, 38, 356 ],
[ 5, 39, 319 ],
[ 5, 39, 369 ],
[ 5, 40, 380 ],
[ 5, 40, 395 ]
]
}}}

{{{id=37|
%magma
#[ DAB : DAB in DABInvs | DAB in DBIX ];
///

























835
}}}

<p>The Igusa class polynomials (or ideal) is, for CM genus 2 curves, the analogue of the Hilbert class polynomial for CM elliptic curves.</p>

{{{id=19|
%magma
IgLIX := IgusaLIXInvariants(DBIX,DAB)[1];
IgLIX;
///


























[
<511231418660002024917034394418895780105198481601*x^16 - 3945729417661390367738634862588716060505296443923606990507022208*x^15 + 7146133915704585755312190766883571188405947862812833171140599377618706876002304*x^14 - 48072115920190158388437800182452027404922827543319672549289284452517119416054936649728*x^13 - 403218799811169962557724651679320400989714209952213754811178116920124518722374330818984509440*x^12 - 910821492897669156687144658212385737867090650319852325149210333307185426587482227768002081004191744*x^11 - 821123087899184871707917071217960347513138710566699358090589483527914434017654278327495736817812504576000*x^10 - 258626570998023333542358627769655028492672528791934497901974520271369807354439554222744939743165418658781462528*x^9 - 74359539768750418868679259080877842686534314506482226155644892867752386864684893776758154807537242485145716073168896*x^8 - 5559018977985786766645284095767397156234669279490549262220755618016255869238068179784710630765086252965476608268828672000*x^7 - 190333306310765888836512766921756298961680712023912176019744967226496408640401662509122562871392932842571735553076625408000000*x^6 - 3580871906354256462944065200534302942917475186995717661957184496228199024632151995347433775575252723712301885599214731264000000000*x^5 - 41424953876285416645893055579797601321864176617226605341284796887126568493914455078879717622520169458235492644908506808320000000000000*x^4 - 298728446043799385693969265747029591716189110924690437207329053200094883960083540100214771626254858225464892456447690932224000000000000000*x^3 - 1223097407855247932874131126150045578728122332602007225522752391747767910205601234628736474693826208193409198617766236520448000000000000000000*x^2 + 831580969190747761079569841968066176011487148098794417779667030400821203682153177506261200410877102768241268224713176383488000000000000000000000*x - 252756652251178609806279149376365836679273686302568260052575753214625925236617811146539871664121274358496321372574246240256000000000000000000000000, 1>,
<2014503653351538957269899893322261704657253554477445737761577973062027954783460040033356416*x^15 - 7176696260603885000909072512461940877985183725485279714668829986089376027703769000081813624734365229073408*x^14 + 180994279434160406820444169021572756873214998582552668218904922197967072895123597489199917425052404462670967078912*x^13 + 1158531980393857231281627675825602469432745938568648600143358493099034086841854986022867855776133189745062250401955184640*x^12 + 2072997504895754507880182256331572755269840559045611253769798791074260233589482589198986215649610230980400679455123281741348864*x^11 + 1169054907891237162941134463795208873812554924825531094701970728802310247245506220201857933877827869598465810209874933382062339522560*x^10 + 224431573887055157805252672718695077222642473423521676050367050301663152582414499866887868089163612168055110327460820382630670536598880256*x^9 + 39265223177776684314136518948077424841090621672449702191522565676595731101103686218381319655519229438709144398006113319033160206465897385164800*x^8 - 10383739376133822708983218218233021864447630658960991127801691652158254333206436479897356067210021719356874546207654529219649468274178309226496000000*x^7 - 1277318253958571663549407036388346118460686579467065039140786674680037550268369966533906857913193487328564845805570501055945535184872799398684262400000000*x^6 - 50469723688383975866497120073694151323713897346195877942277415309898432576761049030113233811883481781887182154478411596869663560417644407480018534400000000000*x^5 - 792523870044329673917061984584142921768904490954259541640827181352715821601699791136853384653187020346254280472428101664676941395106821686977101824000000000000000*x^4 - 4723073838208399968607335181704674396413049435838117529864092995661580495885481020801826945201337944195000179013619984435249175325485547937673825484800000000000000000*x^3 + 6959140277347787884897638471304475401021242499671882071553736746683240357861267023069952151052054539048980067520808612049137349317010525625216139264000000000000000000000*x^2 - 3328500264247690258490727991300707989762460330165590727811783982907151587360366455471642371836011534510039077421764050203549169907753080355513014681600000000000000000000000*x + 681177754790413250922102743815175613955416677043078265545410296218730251454450806810489259004842831931705717515601989453529091643526909437220906598400000000000000000000000000, 6559905699203585086733949>,
<1566064994552365029952798956297969171523835965163906115941334167474464321849080105692332032*x^15 - 5563586843596147869679858819843852918018026132827005609002865943926805900268567105969197628768478492669952*x^14 + 157426376636039476188592947477737474543273972705169571336355191799534351523940355143311559030985051188793850527744*x^13 + 939275026072738455465899674794177200234027220034160842002726588419224148025827535734565881415859507021945943674585088000*x^12 + 1520562125607415384997679722224372668419198028537812269138700856634140766324796551307325875610338683932557777488587297686290432*x^11 + 666594662254826531119265380041213162963387292263658887143951468994260651468820281677106258146857180798014831105969309151978210721792*x^10 + 80184055539408582403712153781134711864132483312919195932903496675807075315248844318623733920697493136709899174246339766041522578252627968*x^9 - 6025391782078485979037816667794094406332640645136184987898508322560287000632131051125986353729891496183749546041968300287070403648684292046848*x^8 - 12534507315944104318732237986778222333933458071343871211687543115001057452320353395657670518439099721512928827322880647019954224845752395492229120000*x^7 - 1262948781972375988171877383992707884250669140487501630867336470034810610659699806457211160709421245006208264674703014591950876279776175798360211456000000*x^6 - 46563715618610053881539330920910446744005359468730463000516012431248223540898364298530107711795338866502788530606604283473377871610248834493087481856000000000*x^5 - 681372681481966827148360997985606690571036278973128323628823297090139309165407774902688406743577261667096200728841851997123699020869553522500509368320000000000000*x^4 - 3398228922692413558162084299505512293327061301434281615407941985389581586113812232385104200893299278353376806342314258190336893133351423783762606948352000000000000000*x^3 + 12582968286960437115033328465709560217063252864525789564463088064592139695145352963214751497406061524769318541374380100127000027272486631794941771120640000000000000000000*x^2 - 7142994003092183832656477833678407251313251459181754952110769019410621867170632174538674231589933691663073619069503441946270733125022179150708346978304000000000000000000000*x + 1836562324056624492542935824755612265588989395148477898008033357654525273946497767841410969454174134771819155393134821731739627931900000495068424175616000000000000000000000000, 19679717097610755260201847>
]
}}}

<h2 style="text-align: center;">Invariants of genus 2 curves</h2>

{{{id=38|
%magma
frob_seq := QuarticCMFieldOrdinaryWeilNumbers(K,3); frob_seq;
///

























[
1/5*(10*t^3 - 23*t^2 + 215*t - 48)
]
}}}

{{{id=45|
%magma
chi := MinimalPolynomial(frob_seq[1]); chi;
///

























x^4 - 210*x^3 + 21502*x^2 - 1377810*x + 43046721
}}}

{{{id=46|
%magma
FF<t> := FiniteField(3,8);
IgusaInvariantsSequences(DBG2,chi);
///


























[
[
[ 1, t^4527, t^3539, t^6402, t^4026 ],
[ 1, t^461, t^4057, t^6086, t^5518 ],
[ 1, t^1383, t^5611, t^5138, t^3434 ],
[ 1, t^4149, t^3713, t^2294, t^3742 ],
[ 1, t^5887, t^4579, t^322, t^4666 ],
[ 1, t^4541, t^617, t^966, t^878 ],
[ 1, t^503, t^1851, t^2898, t^2634 ],
[ 1, t^1509, t^5553, t^2134, t^1342 ]
]
]
[
Maximal Order of Equation Order with defining polynomial x^4 - 210*x^3 + 21502*x^2 - 1377810*x + 43046721 over ZZ
]
[
[]
]
[
[]
]
[ 5, 27, 151 ]
[ 8 ]
[ 1 ]
}}}

{{{id=61|
%magma
IgLIX := IgusaLIXInvariants(DBIX,DAB)[1];
JJ_seq := IgusaLIXToIgusaInvariants(IgLIX,FF : LiftingPrecision := 512);
JJ_seq;
///



























[
[ 1, t^4527, t^3539, t^6402, t^4026 ],
[ 1, t^461, t^4057, t^6086, t^5518 ],
[ 1, t^1383, t^5611, t^5138, t^3434 ],
[ 1, t^5887, t^4579, t^322, t^4666 ],
[ 1, t^1509, t^5553, t^2134, t^1342 ],
[ 1, t^4149, t^3713, t^2294, t^3742 ],
[ 1, t^503, t^1851, t^2898, t^2634 ],
[ 1, t^4541, t^617, t^966, t^878 ]
]
}}}

<h2 style="text-align: center;">Mestre's algorithm</h2>

<p>
Mestre's algorithm (reconstruction of a genus 2 curve from Igusa invariants) has been extended 
to finite fields of characteristic 2 and 3.

{{{id=62|
%magma
JJ := JJ_seq[1];
C := HyperellipticCurveFromIgusaInvariants(JJ);
J2 := IgusaInvariants(C);
IgusaToNormalizedIgusaInvariants(J2);
///




























[ 1, t^4527, t^3539, t^6402, t^4026 ]
}}}

<p>Conversely, the Igusa class invariants were constructed using canonical lifting of the invariants of an ordinary curve over a finite field.</p>

{{{id=54|
%magma
CanonicalLiftAbsoluteIgusaInvariants(C,256);
///

























[ -9637117550979931276585099097828620705244730913080411493420172661876174650783387388424494536744609656913505923310162044918*$.1^7 - 10650794707408917155898592713515786325622109919934295658413476864943655021098431877292767320580555702601957704691931089620*$.1^6 - 63135006716367772731979862386034388424000662853155563136953241873973496927675015097245310727555698071848996443127765227322*$.1^5 + 43727836848541426366045048637082593144338125501378754912564355635469408672190862790405339036446970129376169749879917997209*$.1^4 + 24329346054209682075016622914892076337133704068934033522380294273462837680250132255023193296835085504288675325830461796442*$.1^3 - 2697237568491709411643312932691231251950674707295142997999000616931512431249236720358730247088418500235032455884779379753*$.1^2 + 43436634050596213896912009288769172649766288146042239788297571330162423863072701024965177466418820391334409487556605925125*$.1 - 43561291733105919005443873810387073345402467955574449770377423833713090998244824231530653096742126880242910403474929491819, 7073425172988472034815810017206392815582696083251843667770063108606800645473967772034782597370365027070833432268173887048*$.1^7 + 24754628566541876815156239657638681154034567509703598932374395451206370049515819588196574849410291461871646326480174948464*$.1^6 + 66484956130767123507481252385892148684180977454401744191751124906597558164693753975776172289145242759141576317190027724321*$.1^5 - 28186801677208323511505117735374585421258414649248752154181636164007321799710469705080149207441918808372901120753183867567*$.1^4 + 47114994129303865372033662695872032015798631662188171271062045288236293423411893254781859870709923764456550717956645264247*$.1^3 + 34731607100368582449232653739863882962754693955808264863419042491695331483842085102761185003029077547542737860872151986022*$.1^2 + 56570889279001728622507347915557607989790903884104989015039220064688066456446304454433608974851331002487834050572736517470*$.1 - 31086101225949229345802390481941662307326343093157367258865762017115593848009010908371285147994906900021730087794375036960, 59738286440549335361973913585162020172384138998729595588864330048599621534892065766541547618481952857285688947263577916729*$.1^7 - 1769982582836837288202857121964600578137554387756823340519820271386033000798166967463056675438399370387392786880688488905*$.1^6 - 47237515924102001058120147339773378894220563641690159540245820475101679163132413204338437448016416021898582060098005842511*$.1^5 - 18822745664641238572273093101698926699823108053919609302975895858636672135437197586345540686851784995422451881771163362813*$.1^4 + 2949748090170846181045158320193010845850441606133104132557677764139024694734830403621896672188092260250597223443965724936*$.1^3 + 48955491187731992918770701499684320783312126823039502356145167132192239145109695795451742333849256534183124219630425802095*$.1^2 - 46118548767691989375736222237615893543170539012322630519435480350010177172887960093099709322213345076197066802155592310141*$.1 - 23585586788646071174001060071145410804533652102104593814178854205161501020359753447352842409190410398686753651048145031755 ]
}}}

<h2 style="text-align: center;">Isogeny graphs in genus 2</h2>

{{{id=49|
%sage
magma.eval("jj := IgusaToAbsoluteIgusaInvariants(JJ);")
magma.eval("A, X := AbsoluteIgusaInvariantIsogenyAdjacencyMatrix(jj,2);")
G = Graph(magma("A;").sage())
G.plot(scaling_term=0.005)
///

























<html><font color='black'><img src='cell://sage0.png'></font></html>
}}}

{{{id=50|
%magma
P<x> := PolynomialRing(ZZ);
chi := x^4 - 12*x^3 - 170*x^2 - 8748*x + 531441;
JJ := IgusaInvariantsSequences(DBG2,chi)[1][1];
jj := IgusaToAbsoluteIgusaInvariants(JJ);
///
}}}

{{{id=51|
%sage
magma.eval("A, X := AbsoluteIgusaInvariantIsogenyAdjacencyMatrix(jj,2);")
G = Graph(magma("A;").sage())
G.num_verts()
///

























366
}}}

{{{id=52|
G.plot(scaling_term=0.001, vertex_size=10, vertex_labels=False)
///

























<html><font color='black'><img src='cell://sage0.png'></font></html>
}}}

{{{id=33|
leaves = []
for v in G.vertices():
    if len(G.neighbors(v)) == 1:
        leaves.append(v)
G.delete_vertices(leaves)
G.plot(scaling_term=0.001, vertex_size=10, vertex_labels=False)
///

























<html><font color='black'><img src='cell://sage0.png'></font></html>
}}}

<h2 style="text-align: center;">Endomorphism rings<br /></h2>

{{{id=23|
%magma
C := HyperellipticCurveFromIgusaInvariants(JJ);
J := Jacobian(C);
EndomorphismRing(J);
///



























Transformation of Order over 
Equation Order with defining polynomial x^4 + 12*x^3 - 170*x^2 + 8748*x + 531441 over ZZ
Transformation Matrix:
[  1   0   0   0]
[  0   2   0   0]
[  0   0   8   0]
[  0   0   0 352]
[ 2, 8, 352 ]
}}}

<h2 style="text-align: center;">Invariants of genus 3 curves</h2>
<p>The invariants of Shioda for genus 3 hyperelliptic curves, and of Dixmier, extended by Ohno, are implemented for generic genus 3 curves (plane quartics).</p>

{{{id=25|
%magma
P<x> := PolynomialRing(QQ);
C := HyperellipticCurve(x^7 + 3*x + 1);
SS, ii := ShiodaInvariants(C); 
print C;
print SS;
print ii;
///





Hyperelliptic Curve defined by y^2 = x^7 + 3*x + 1 over Rational Field
[ -3/4, 0, 3/512, 0, 3/16384, 1/512, 81/4587520, 1/8192, 81/146800640 ]
[ 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
}}}

{{{id=31|
%magma
PP<X,Y,Z> := ProjectiveSpace(QQ,2);
C1 := Curve(PP,X^3*Y + Y^3*Z + Z^3*X);
D1, ii := DixmierOhnoInvariants(C1);
d1 := [ D1[i]/D1[1]^ii[i] : i in [1..#D1] ];
C2 := Curve(PP,X^4+Y^4+Z^4);
D2, ii := DixmierOhnoInvariants(C2);
d2 := [ D2[i]/D2[1]^ii[i] : i in [1..#D2] ];
print C1;
print "D1:", D1;
print "d1:", d1;
print C2;
print "D2:", D2;
print "d2:", d2;
///
































Curve over Rational Field defined by
X^3*Y + Y^3*Z + X*Z^3
D1: [ 9, -729, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -823543 ]
d1: [ 1, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -823543/387420489 ]
Curve over Rational Field defined by
X^4 + Y^4 + Z^4
D2: [ 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1099511627776 ]
d2: [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16/387420489 ]
}}}

{{{id=42|
%magma
C3 := Curve(PP,X^4 + 2*X^3*Y + 3*X^2*Y^2 + 2*X*Y^3 + 18*X*Y*Z^2 + 9*Y^2*Z^2 - 9*Z^4);
D3, ii := DixmierOhnoInvariants(C3);
d3 := [ D3[i]/D3[1]^ii[i] : i in [1..#D3] ];
print C3;
print "D3:", D3;
print "d3:", d3;
///




























Curve over Rational Field defined by
X^4 + 2*X^3*Y + 3*X^2*Y^2 + 2*X*Y^3 + 18*X*Y*Z^2 + 9*Y^2*Z^2 - 9*Z^4
D3: [ 1296, -15116544, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -21925459760140076420431872 ]
d3: [ 1, -9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -823543/387420489 ]
}}}

<h2 style="text-align: center;">Pic<sup>0</sup>(C) for general curves</h2>
<p style="text-align: justify;">This is a generic wrapper for Florian Hess' Riemann-Roch spaces in Magma.
These examples are genus one, but the construction is for arbitrary genus!</p>

{{{id=58|
%magma
PP<X,Y,Z> := ProjectiveSpace(QQ,2);                                                                 
C := Curve(PP,X^3+Y^3+Z^3);                                                                         
P := C![-1,1,0];                                                                                    
J := PicardGroup(C,P);                                                                              
Q := J!C![0,-1,1];  
[ i*Q : i in [1..3] ];
///























[
(X, Y + Z),
(X + Z, Y),
0
]
}}}

<p>
Here we work with a twist of rank 2.
</p>

{{{id=74|
%magma
C := Curve(PP,X^3+Y^3+19*Z^3); 
P := C![-1,1,0];                                                                     
J := PicardGroup(C,P);                                                                              
Q := J!C![-3,2,1];  
[ i*Q : i in [1..3] ];
///






















[
(X + 3*Z, Y - 2*Z),
(X + 92/35*Z, Y + 33/35*Z),
(X + 9613/10386*Z, Y + 27323/10386*Z)
]
}}}

{{{id=75|
%magma
R := J!C![-3/2,-5/2,1];                                                                             
[ i*Q + j*R : i, j in [-2..2] ];
///




















[
(X + 1502783/670397*Z, Y + 1325880/670397*Z),
(X + 2395/201*Z, Y - 2386/201*Z),
(X + 33/35*Z, Y + 92/35*Z),
(X + 109/31*Z, Y - 90/31*Z),
(X - 1025/1533*Z, Y + 4112/1533*Z),
(X - 1322/4983*Z, Y + 13301/4983*Z),
(X + 36/13*Z, Y - 17/13*Z),
(X - 2*Z, Y + 3*Z),
(X + 8/3*Z, Y + 1/3*Z),
(X - 594/103*Z, Y + 613/103*Z),
(X - 831/196*Z, Y + 895/196*Z),
(X + 5/2*Z, Y + 3/2*Z),
0,
(X + 3/2*Z, Y + 5/2*Z),
(X + 895/196*Z, Y - 831/196*Z),
(X + 613/103*Z, Y - 594/103*Z),
(X + 1/3*Z, Y + 8/3*Z),
(X + 3*Z, Y - 2*Z),
(X - 17/13*Z, Y + 36/13*Z),
(X + 13301/4983*Z, Y - 1322/4983*Z),
(X + 4112/1533*Z, Y - 1025/1533*Z),
(X - 90/31*Z, Y + 109/31*Z),
(X + 92/35*Z, Y + 33/35*Z),
(X - 2386/201*Z, Y + 2395/201*Z),
(X + 1325880/670397*Z, Y + 1502783/670397*Z)
]
}}}

<h2 style="text-align: center;">Alternative models for elliptic curves in Sage</h2>

These examples are twist of Hessian curves, which can be easily implemented in Sage
directly:

{{{id=82|
%sage
k = FiniteField(101)
E = HessianCurve(k(0))
E
///









Hessian curve over Finite Field of size 101 defined by x^3 + y^3 + z^3 = 0
}}}

{{{id=83|
%sage
P = E.random_point()
[ n*P for n in range(32) ]
///









[(0 : 100 : 1), (96 : 45 : 1), (4 : 84 : 1), (46 : 3 : 1), (13 : 5 : 1), (32 : 16 : 1), (48 : 26 : 1), (10 : 82 : 1), (53 : 31 : 1), (61 : 73 : 1), (91 : 89 : 1), (40 : 30 : 1), (60 : 51 : 1), (70 : 47 : 1), (11 : 33 : 1), (76 : 21 : 1), (20 : 92 : 1), (0 : 100 : 1), (9 : 56 : 1), (95 : 77 : 1), (34 : 49 : 1), (81 : 43 : 1), (19 : 2 : 1), (35 : 64 : 1), (85 : 42 : 1), (88 : 18 : 1), (18 : 88 : 1), (42 : 85 : 1), (64 : 35 : 1), (2 : 19 : 1), (43 : 81 : 1), (49 : 34 : 1)]
}}}

<h2 style="text-align: center;">Pic<sup>0</sup>(C) for singular hyperelliptic curves</h2>

{{{id=76|
%magma
P7<x> := PolynomialRing(FiniteField(7));
C := SingularHyperellipticCurve(x*(x^4+x+1)^2);
J := SingularPicardGroup(C);
P := Random(J);
[ n*P : n in [1..16] ];
///






















[
(x^3 + 6*x^2 + 2*x, y + 5*x^2 + 2*x),
(x^4 + 5*x^3 + 5*x^2 + 3*x + 4, y + 4*x^3 + 5*x^2 + 6*x + 1),
(x^3 + x^2 + 2*x + 3, y + 4*x^2 + 3*x + 4),
(x^4 + x^3 + 2*x^2 + 3*x, y + 2*x^3 + 3*x^2 + 6*x),
(x^4 + 6*x^3 + x + 4, y + 3*x^3 + 2*x^2 + 2*x + 5),
(x^4 + 5*x^3 + 5*x + 4, y + 5*x^3 + 2*x^2 + 2),
(x^4 + 5*x^2 + 6*x + 1, y + x^3 + 5*x + 2),
(x^3 + x^2 + 4*x + 6, y + 2*x^2 + 5*x + 1),
(x^4 + 3*x^3 + 5*x^2 + 4*x + 2, y + 6*x^3 + x^2 + 3*x + 4),
(x^4 + 3*x^3 + 6*x + 4, y + 3*x^3 + x^2 + 2*x + 4),
(x^3 + 4*x^2 + 2*x, y + x^2 + 2*x),
(x^4 + 3*x^3 + 6*x + 4, y + 5*x^3 + 5*x),
(x^4 + 4*x^3 + 2*x^2 + 2, y + 6*x^3 + 4*x^2 + 5*x + 5),
(x^4 + 6*x, y + 5*x^3 + 6*x^2),
(x^3 + 6, y + 5*x^2 + 3*x + 3),
(x^4 + 6*x^2 + 2*x + 4, y + 5*x^3 + 6*x^2)
]
}}}

{{{id=77|
%magma
(7^4-1)*P;
(7^2-1)*P;
(7^2+1)*P;
///



















(1)
(x^3 + x^2 + 5, y + x + 2)
(x^4 + 2*x^3 + x + 1, y + 6*x^3 + x^2 + x + 1)
}}}

<p>&nbsp;</p>
<p><span style="color: #000080;"><strong>Exercise:</strong></span> Create an spkg for ECHIDNA and provide comments!</p>

{{{id=87|

///
}}}