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

ZX<x> := PolynomialRing( Integers() );
load "D7Mipos.m";
load "D5Mipos.m";
load "D3Mipos.m";


DB := CremonaDatabase();

/* In the following we look for D3, D5 or D7 examples with analytic rank 0.
*/
low := 11; high := 100;
Listen := SplitMultEllCurves(low, high);
Es := Listen[1];
EEs := [];
N := -1;
/* It would be more reasonable to pick one curve in each isogeny class !!!
   The following lines reproduce the examples listed in the paper. With more effort more
   examples can be computed, but this takes time.
*/
for E in Es do
    if Conductor(E[2]) ne N then
        Append(~EEs, E[2]);
        N := Conductor(E[2]);
    end if;
end for;

D3TamePols := [];
for f in D3_pols do
    if IsTamelyRamified(NumberField(f[1])) then Append(~D3TamePols, f[1]); end if;
end for;
pols := [ D3TamePols[i] : i in [1..3]];
Es := [E : E in EEs | Conductor(E) le 50];
D3GoodExamples := FindGoodDpExample(pols, Es);

count := 1;
for ex in D3GoodExamples do
    print "\n\n************* Example ", count, " *************\n\n";
    E, S, HP, QG :=  etnc(ex[1], ex[2], 12);
    count +:= 1;
end for;


D5TamePols := [];
for f in D5_pols do
    if IsTamelyRamified(NumberField(f[1])) then Append(~D5TamePols, f[1]); end if;
end for;
pols := [ D5TamePols[i] : i in [1..5]];
Es := [E : E in EEs | Conductor(E) le 50];
D5GoodExamples := FindGoodDpExample(pols, Es); 

count := 1;
for ex in D5GoodExamples do
    print "\n\n************* Example ", count, " *************\n\n";
    E, S, HP, QG :=  etnc(ex[1], ex[2], 12);
    count +:= 1;
end for;


D7TamePols := [];
for f in D7_pols do
    if IsTamelyRamified(NumberField(f[1])) then Append(~D7TamePols, f[1]); end if;
end for;
pols := [ D7TamePols[i] : i in [1..2]];
Es := [E : E in EEs | Conductor(E) le 50];
D7GoodExamples := FindGoodDpExample(pols, Es);

count := 1;
for ex in D7GoodExamples do
    print "\n\n************* Example ", count, " *************\n\n";
    E, S, HP, QG :=  etnc(ex[1], ex[2], 12);
    count +:= 1;
end for;
