Attach("RelAlgKTheory.m");
Attach("INB.m");
Attach("etnc.m");

ZX<x> := PolynomialRing( Integers() );


/* This file shows how to use the intrinsics NonPerfectEtnc and etncII.

   NonPerfectEtnc checks ETNC at l for a cyclic extension K/Q of order
   l^n in Q(zeta_p)/Q.
   prec specifies the precision of the floating point arithmetic

   etncII combines NonPerfectEtnc with the methods of the paper
   "Numerical evidence for the equivariant BSD conjecture (part I)"
   and also checks ETNC for primes q ne l.
   This can only be used for rank 0 curves !!

*/

/* The elliptic curve of conductor N = 5077 and algebraic rank 3 */
E := EllipticCurve([0,0,1,-7,6]);
l := 3; n := 1; p := 37; prec := 50;
IsExample, ETNCvalid, calU, calE, K := NonPerfectEtnc(E, l, n, p, prec);
IsExample, ETNCvalid;


DB := CremonaDatabase();
low := 10; high := 500;
Listen := SplitMultEllCurves(low, high);
/* Listen[r+1] is a list of split multiplicative 
   elliptic curves of algebraic rank r with low \le N_E \le high */

prec := 50; PrimeBound := 500;

/* Fix the rank r and degree l^n and compute possible curves and primes p */
r := 0; l := 3; n := 1;
Es := Listen[r+1];
ps := [p : p in PrimesUpTo(PrimeBound) | p mod l^n eq 1];

#Es;
ps;

/* Choose E and p */
E := Es[1,2]; p := ps[3];
CremonaReference(E); print "p = ", p;
IsExample, ETNCvalid, calU, calE, K := NonPerfectEtnc(E, l, n, p, prec);
IsExample, ETNCvalid, calU, calE;

/* If r=0 we can also check ETNC at p ne l */
IsExample, ETNCvalid, NotChecked := etncII(E, l, n, p, prec);
IsExample, ETNCvalid, NotChecked; 

