//Code used in Lemma 5.1.
Q:=PolynomialRing(Rationals());
K:=CyclotomicField(3);
//Elliptic curves we define here are defined by using their Cremona labels.
//Labels mentioned in paper are LMFDB labels. It can be seen on LMFDB page
//for each of these curves that LMFDB label in paper and Cremona labels here
//are the labels for the same elliptic curve.
E1:=EllipticCurve("50a1"); // j(E1)=-25/2
E2:=EllipticCurve("450b2"); // j(E2)=-5^2*241^3/2^3
E3:=EllipticCurve("50a3"); // j(E3)=-29^3*5/2^(5)
E4:=EllipticCurve("450b4"); // j(E4)=211^3*5/2^(15)
list:=;
for E in list do
f3:=DivisionPolynomial(E,3);
f5:=DivisionPolynomial(E,5);
f15:=DivisionPolynomial(E,15);
f15:=f15 div f3;
f15:=f15 div f5; //f15 is primitive 15th division polynomial associated to E.
Factorization(f15: DegreeLimit:=10);
Factorization(f15,K);
end for;
//All irreducible factors of f15 remain irreducible over cyclotomic field K.
///////////////////////////////////////////////////////////////////////////////////////
//Code used in Lemma 4.2.
//C21
// If E'/Q has a rational 21-isogeny, then j(E)=a_i, for i<=4.
a1:=-3^2*5^6/2^3;
a2:=3^3*5^3/2^1;
a3:=3^3*5^3*101^3/2^(21);
a4:=-3^3*5^3*383^3/2^7;
list:=;
//take a random elliptic curve with j(E)=a
for a in list do
E:=EllipticCurveWithjInvariant(a);
//computing primitive division polynomial f21.
g3:=DivisionPolynomial(E,3);
g7:=DivisionPolynomial(E,7);
f21:=DivisionPolynomial(E,21);
f21:=f21 div g7;
f21:=f21 div g3; //this is the 21st primitive division polynomial
Factorisation(f21: DegreeLimit:=14);
end for;
//Irreducible factors that appear are of degrees 3, 6 or 9. Let n be any of these 3 values. This means that there exista point P=(x,y) on E' of order 21 such
// that [Q(P):Q] is either n or 2n. But we also need to have that P is defined over L, a degree 14 number field.
//This implies that [Q(P):Q]<=2, which is impossible by Theorem 2.2 and Theorem 2.4.
///////////////////////////////////////////////////////////////////////////////////////
//Code used in Lemma 5.1.
//C50
//We will show that E' has a rational 25-isogeny.
Z25:=Integers(25);
Z5:=Integers(5);
Sub25:=[H`subgroup: H in Subgroups(GL(2,Z25))];
Borel25:=sub; //group of upper triang.matrices.
B0:=sub; //Subgroup of Borel25 such that each matrix in B0 has first column vector equal to [1,0]^T.
G5B11:=sub;
G5B12:=sub;
G5B14:=sub;
G5B13:=sub;
G5B41:=sub;
G5B42:=sub;
G5B:=sub;
//We first find all possibilities for G_E(25) such that E does not have a rational 25-isogeny. Equivalently, G_E(25)
// is not conjugate subgroup to Borel25, a group of upper triangular matrices in GL(2,Z25).
// Imm5B11 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.1.1
Im_rho:=G5B11;
Imm5B11:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B11:=[H : H in Imm5B11 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B12 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.1.2
Im_rho:=G5B12;
Imm5B12:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B12:=[H : H in Imm5B12 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B14 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.1.4
Im_rho:=G5B14;
Imm5B14:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B14:=[H : H in Imm5B14 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B13 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.1.3
Im_rho:=G5B13;
Imm5B13:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B13:=[H : H in Imm5B13 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B41 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.4.1
Im_rho:=G5B41;
Imm5B41:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B41:=[H : H in Imm5B41 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B42 is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B.4.2
Im_rho:=G5B42;
Imm5B42:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B42:=[H : H in Imm5B42 | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
// Imm5B is the set of subgroups GG of GL(2,Z/25Z) (up to conjugacy) such that GG = G (mod 5), where G=5B
Im_rho:=G5B;
Imm5B:=[H : H in Sub25 | IsConjugate(GL(2,Z5),sub,Im_rho)];
Imm5B:=[H : H in Imm5B | IsConjugateSubgroup(GL(2,Z25),Borel25,H) eq false];
list:=;
//for each possibility G of G_E'(25), we check if G has a subgroup of index 10 that is conjugate
//subgroup of B0. Equivalently, if E' has a point of order 25 defined over degree 10 extension of Q.
for GG in list do
for G in GG do
M:=[s`subgroup: s in Subgroups(G: IndexEqual:=10)];
for m in M do
if IsConjugateSubgroup(GL(2,Z25),B0,m) eq true then
m;
end if;
end for;
end for;
end for;
//The code outputs nothing, which means that there does not exist an elliptic curve E'/Q with a rational 5-isogeny such that
//E' does not have a rational 25-isogeny and a point of order 25 defined over degree 10 extension of Q.