///////////////////////////////////////////////////////////////////////////
//
// 		"Torsion growth over cubic fields
//  of rational elliptic curves with complex multiplication"
//
// 		Enrique González-Jiménez
//
//      Magma script 
// 		
//
///////////////////////////////////////////////////////////////////////////
// Magma 2.24
//////////////////////////////////////////////////////////////////////////
load "CM_aux.m";
print "CHECKING ALL THE DETAILS AT SECTION 2";
print ".........";

////////////////////////////////////////////////////////////////////////////////////////////////
// 
// Growth to C2xC2 is not possible from C1 over cubic fields
//
////////////////////////////////////////////////////////////////////////////////////////////////
// Let see that if E has trivial torsion, then the 2-division polynomial Psi_2(x) is not normal/Galois
// Then it is not possible to have full 2-torsion over the cubic field defined by Psi_2(x)

// Trivial Torsion over Q for D in [-27,-11,-19,-43,-67,-163] 
boo2:=&and[IsIrreducible(DivisionPolynomial(CM_EllipticCurve(D,1),2)) : D in [-27,-11,-19,-43,-67,-163]];

 boo2x2:=&and[#GaloisGroup(DivisionPolynomial(CM_EllipticCurve(D,1),2)) ne 3  : D in [-27,-11,-19,-43,-67,-163]];
 assert boo2 and boo2x2;



////////////////////////////////////////////////////////////////////////////////////////////////
// 
// Growth to C4 is not possible from C1 over cubic fields
//
////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////
// Trivial Torsion over Q 
// (1) D in [-27,-11,-19,-43,-67,-163] 
// Study points of orde 4 over cubic
 boo:=&and[IsIrreducible(PrimitiveDivisionPolynomial(CM_EllipticCurve(D,1),4)) and (Degree(PrimitiveDivisionPolynomial(CM_EllipticCurve(D,1),4)) eq 6)  : D in [-27,-11,-19,-43,-67,-163]];
 assert boo;
// No points of order 4 over cubic

// (2) D=-3, k\ne r^2,r^3,-432. E:y^2=x^3+k
// The polynomial x^3+k never is Galois since k\ne r^3


// Trivial Torsion over Q for D=-3, d\ne r^2 ,r^3, -432 
_<d>:=RationalFunctionField(Rationals());
E:=EllipticCurve([0,d]);
P4:=PrimitiveDivisionPolynomial(E,4);
/* BY HAND:
 P4=2*(x^6 + 20*d*x^3 - 8*d^2)
 --> z=x^3 and z^2 + 20*d*z - 8*d^2=0 --> z=d*(-5+\pm 3*sqrt{3})=x^3 in CUBIC? NO, never
*/
// Conclusion: No points of order 4 over cubic fields for y^2=x^3+d, for any d

////////////////////////////////////////////////////////////////////////////////////////////////
// 
// Explicit description of the Torsion Growth over cubic fields
//
////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////
// D in [-11,-19,-43,-67,-163] 
// Torsion trivial over Q
// Only can grow to C2 or C3 or C6
 boo2:=&and[IsIrreducible(PrimitiveDivisionPolynomial(CM_EllipticCurve(D,1),2))  : D in [-11,-19,-43,-67,-163]];
 assert boo2;
// C2 over the field of definition of the curve  
boo3:=true;
 for D in [-11,-19,-43,-67,-163] do
 	PP3:=Factorization(PrimitiveDivisionPolynomial(CM_EllipticCurve(D,1),3));
 	boo:=&and[not Degree(f[1]) in [1,3] : f in PP3];
 	boo3:= boo3 and boo;
 end for;
 assert boo3;
// No pints of order 3 over cubics
// Conclusion:
/*
 for D in [-11,-19,-43,-67,-163] do
 	E,AB:=CM_EllipticCurve(D,1);
	printf "%o - %o\n",D,Coefficients(DefiningPolynomial(OptimizedRepresentation(NumberField(Polynomial([AB[2],AB[1],0,1]))))); 
  end for;
-11 - [ 1, 1, -1, 1 ]
-19 - [ -1, 3, -1, 1 ]
-43 - [ 3, -1, -1, 1 ]
-67 - [ 5, -3, -1, 1 ]
-163 - [ -10, -8, 0, 1 ]
*/

///////////////////////////////////////////////
// D=-8 
// Torsion C2 over Q
D:=-8;
E:=CM_EllipticCurve(D,1);
// Only can grow to C6 or C14
P3:=PrimitiveDivisionPolynomial(E,3);
PP3:=Factorization(P3);
assert &and[Degree(f[1]) eq 2 : f in PP3];
P7:=PrimitiveDivisionPolynomial(E,7);
assert IsIrreducible(P7) and Degree(P7) eq 24;
// No torsion growth

///////////////////////////////////////////////
// D=-7
// Torsion C2 over Q
D:=-7;
E,AB:=CM_EllipticCurve(D,1);
// Only can grow to C6 or C14
// Study points of order 3
P3:=PrimitiveDivisionPolynomial(E,3);
assert IsIrreducible(P3) and Degree(P3) eq 4;
// No points order 3 over cubics 
// Study points of order 7
P7:=PrimitiveDivisionPolynomial(E,7);
PP7:=Factorization(P7);
L7:=[f[1] : f in PP7 | Degree(f[1]) eq 3];
assert #L7 eq 1;
f:=L7[1];
//assert f eq Polynomial([ -66339, -1701, 63, 1 ]);
K<a>:=NumberField(f);
L<b>:=OptimizedRepresentation(K);
assert [ -1, -2, 1, 1 ] eq Coefficients(DefiningPolynomial(L));
coe:=Coefficients(f);
r:=Roots(Polynomial(L,coe))[1][1];
assert 36*b - 9 eq r;
y2:=r^3+AB[1]*r+AB[2];
assert y2 eq -7*(2^2*3^3*b)^2;
// Conclusion: Point of order 7 in cubic field only if quadratic teist by k=-7 

///////////////////////////////////////////////
// D=-28
// Torsion C2 over Q
D:=-28;
E,AB:=CM_EllipticCurve(D,1);
// Only can grow to C6 or C14
// Study points of order 3
P3:=PrimitiveDivisionPolynomial(E,3);
assert IsIrreducible(P3) and Degree(P3) eq 4;
// No points order 3 over cubics 
// Study points of order 7
P7:=PrimitiveDivisionPolynomial(E,7);
PP7:=Factorization(P7);
L7:=[f[1] : f in PP7 | Degree(f[1]) eq 3];
assert #L7 eq 1;
f:=L7[1];
K<a>:=NumberField(f);
L<b>:=OptimizedRepresentation(K);
assert [ -1, -2, 1, 1 ] eq Coefficients(DefiningPolynomial(L));
coe:=Coefficients(f);
r:=Roots(Polynomial(L,coe))[2][1];
assert 4*b^2 - 4*b + 13 eq r;
y2:=r^3+AB[1]*r+AB[2];
assert y2 eq 7*(4*(-3*b^2 + 3*b + 1))^2;

// Conclusion: Point of order 7 in cubic field only if quadratic teist by k=7 

///////////////////////////////////////////////
// D=-16
// Torsion C4 over Q if k=1,2, then no growth over cubics
// Torsion C2 over Q if k\ne 1,2 
// Only can grow to C6 or C14
D:=-16;
E,AB:=CM_EllipticCurve(D,1);
// Only can grow to C6 or C14
// Study points of order 3 and 7
P3:=PrimitiveDivisionPolynomial(E,3);
assert IsIrreducible(P3) and Degree(P3) eq 4;
P7:=PrimitiveDivisionPolynomial(E,7);
assert IsIrreducible(P7) and Degree(P7) eq 24;

// Conclusion: No growth over cubic fields 



///////////////////////////////////////////////
// D=-27
// Torsion C3 over Q if k=1
// Only can grow to C6 or C9
D:=-27;
E,AB:=CM_EllipticCurve(D,1);
P2:=PrimitiveDivisionPolynomial(E,2);
_<x>:=PolynomialRing(Rationals());
assert x^3-2 eq DefiningPolynomial(OptimizedRepresentation(NumberField(P2)));


P9:=PrimitiveDivisionPolynomial(E,9);
PP9:=Factorization(P9);
L9:=[f[1] : f in PP9 | Degree(f[1]) eq 3];
assert #L9 eq 1;
f:=L9[1];
K<a>:=NumberField(f);
b:=a^3+AB[1]*a+AB[2];
assert IsSquare(b);
assert DefiningPolynomial(OptimizedRepresentation(K)) eq  Polynomial([-1,-3,0,1]);
// Conclusion: Growth to C2 and C9 over cubic.

// Torsion C1 over Q if k\ne 1
// Only can grow to C2, C3 or C6
D:=-27;
E,AB:=CM_EllipticCurve(D,1);
_<x>:=PolynomialRing(Rationals());
// Order 2
P2:=PrimitiveDivisionPolynomial(E,2);
assert IsIrreducible(P2);
assert x^3-2 eq DefiningPolynomial(OptimizedRepresentation(NumberField(P2)));
// Growth to C2 over cubic field with defining polynomial x^3-2
// Order 3
P3:=PrimitiveDivisionPolynomial(E,3);
PP3:=Factorization(P3);
L3:=[f[1] : f in PP3 | Degree(f[1]) eq 3];
assert #L3 eq 1;
f:=L3[1];
K<a>:=NumberField(f);
L<b>:=NumberField(Polynomial([-3,0,0,1]));
coe:=Coefficients(f);
r:=Roots(Polynomial(L,coe))[1][1];
assert -4*(2*b^2 + 3*b + 1) eq r;
y2:=r^3+AB[1]*r+AB[2];
assert y2 eq -3*(4*(4*b^2+6*b+9))^2;

// Conclusion: Growth to C3 over cubic field with defining polynomial x^3+3 for k=-3
// and no growth to C3 for k\ne -3 

///////////////////////////////////////////////
// D=-12
// Torsion C6 over Q if k=1, then no growth over cubic fields
// Torsion C2 over Q if k\ne 1, 
// Only can grow to C6 or C14
D:=-12;
E,AB:=CM_EllipticCurve(D,1);
// Order 7
P7:=PrimitiveDivisionPolynomial(E,7);
PP7:=Factorization(P7);
boo7:=&and[IsDivisibleBy(Degree(f[1]),6) : f in PP7];
assert boo7;
// Conclusion: No growth to C7 over cubic
// Order 3
P3:=PrimitiveDivisionPolynomial(E,3);
PP3:=Factorization(P3);
L3:=[f[1] : f in PP3 | Degree(f[1]) eq 3];
assert #L3 eq 1;
f:=L3[1];
K<a>:=NumberField(f);
L<b>:=NumberField(Polynomial([-2,0,0,1]));
coe:=Coefficients(f);
r:=Roots(Polynomial(L,coe))[1][1];
assert r eq -2*b^2 - 2*b - 1;
y2:=r^3+AB[1]*r+AB[2];
assert y2 eq -3*(2*(b^2+b+1))^2;


// Conclusion: Growth to C6 over cubic field with defining polynomial x^3+3 for k=-3
// and no growth for k\ne -3 


///////////////////////////////////////////////
// D=-4
// Torsion C4 over Q if k=4, then no growth over cubics
// Torsion C2xC2 over Q if k=-r^2, then no growth over cubics
// Torsion C2 over Q if k\ne 4,-r^2, 
// Only can grow to C6 or C14
R<d>:=RationalFunctionField(Rationals());
E:=EllipticCurve([d,0]);
_<x>:=PolynomialRing(R);
P3:=PrimitiveDivisionPolynomial(E,3);
f3:=3*x^2+6*x-1;
assert P3 eq d^2*Evaluate(f3,x^2/d);
assert IsIrreducible(f3);


//assert P3 eq 3*x^4 + 6*d*x^2 - d^2;
/* BY HAND
3*x^4 + 6*d*x^2 - d^2=0 --> z=x^2 and 3*z^2 + 6*d*z - d^2 --> z=\frac{1}{3} \left(2 \sqrt{3}-3\right) d
--> Imposible x over a cubic z=x^2.
*/

P7:=PrimitiveDivisionPolynomial(E,7);
assert IsIrreducible(P7);
f7:=7*x^12 + 308*x^11 - 2954*x^10 - 19852*x^9 - 35231*x^8 - 82264*x^7 - 111916*x^6 - 42168*x^5 + 15673*x^4 + 14756*x^3 + 1302*x^2 + 196*x - 1;
assert P7 eq d^12*Evaluate(f7,x^2/d);
assert IsIrreducible(f7);
// Conclusion: No growth over cubic fields 


///////////////////////////////////////////////
// D=-3
// Torsion C6 over Q if k=1, then no growth over cubic fields
// Torsion C3 over Q if k=r^2\ne 1 or k=-432, 
// k=-432
// Only can grow to C6 or C9
E:=EllipticCurve([0,-432]);
_<x>:=PolynomialRing(Rationals());
// Order 2
P2:=PrimitiveDivisionPolynomial(E,2);
assert IsIrreducible(P2);
assert x^3-2 eq DefiningPolynomial(OptimizedRepresentation(NumberField(P2)));
// Order 9
P9:=PrimitiveDivisionPolynomial(E,9);
PP9:=Factorization(P9);
L9:=[f[1] : f in PP9 | Degree(f[1]) eq 3];
assert #L9 eq 1;
f:=L9[1];
K<a>:=NumberField(f);
y2:=a^3-432;
assert not IsSquare(y2);
// Conclusion: Growth to C6 over cubic field with defining polynomial x^3-2 
// k=r^2\ne 1
R<r>:=RationalFunctionField(Rationals());
//R:=Rationals();
//r:=4;
Rx<x>:=PolynomialRing(R);
E:=EllipticCurve([0,r^2]);
// Order 2
P2:=PrimitiveDivisionPolynomial(E,2);
// x^3 + r^2 =0  --> Q(sqrt[3]{r})
K<aa>:=NumberField(Polynomial([-1,-3,0,1]));
R<r>:=RationalFunctionField(K);
Rxy<x,y>:=PolynomialRing(R,2);
A:=quo<Rxy|y^2-(x^3+r^2)>;
F:=FieldOfFractions(A);
E:=EllipticCurve([0,F!r^2]);
P3:=E![A!0,A!r];
FX:=PolynomialRing(F);
L<b>:=quo< FX| Polynomial(FX,[-((2*aa^2 - 4*aa - 1)*r)^2+r^2,0,0,1])>;
EL:=BaseChange(E,L);
P9:=EL![b,r*(2*aa^2 - 4*aa - 1)];
assert EL!P3 eq 3*P9;
assert (2*aa^2 - 4*aa - 1)^2-1 eq 4*(aa^2 - aa - 1)^3;
assert IsNormal(K);

// We need that 4*r^2=z^3 in K. But this only happens when r=4*s^3, 
// (that is, r=4 since r^2 is sixpower free) since K is normal but z^3-4*r^2 no
//Conclusion: Torsion growth to C9 for r=4 (i.e. y^2=x^3+16), for k\ne 4 the torsion no grow to C9


// Torsion C2 over Q if k=r^3\ne 1 --> quadratic twist
D:=-3;
E,AB:=CM_EllipticCurve(D,1);
_<x>:=PolynomialRing(Rationals());
// Only can grow to C6 or C14
// Order 7
P7:=PrimitiveDivisionPolynomial(E,7);
PP7:=Factorization(P7);
boo7:=&and[IsDivisibleBy(Degree(f[1]),6) : f in PP7];
assert boo7;
// Conclusion: No growth to C7 over cubic
// Order 3
P3:=PrimitiveDivisionPolynomial(E,3);
PP3:=Factorization(P3);
L3:=[f[1] : f in PP3 | Degree(f[1]) eq 3];
assert #L3 eq 1;
f:=L3[1];
K<a>:=NumberField(f);
L<b>:=NumberField(Polynomial([-2,0,0,1]));
coe:=Coefficients(f);
r:=Roots(Polynomial(L,coe))[1][1];
assert r eq -b^2;
y2:=r^3+AB[1]*r+AB[2];
assert y2 eq -3;
// Conclusion: Growth to C6 over cubic field with defining polynomial x^3-2 for k=-3
// and no growth for k\ne -3 

// Torsion C1 over Q if k\ne r^2, r^3,-432 
// Only can grow to C2, C3  or C6
R<d>:=RationalFunctionField(Rationals());
Rx<x>:=PolynomialRing(R);
E:=EllipticCurve([0,d]);
// Order 2
P2:=PrimitiveDivisionPolynomial(E,2);
assert P2 eq 4*(x^3 + d);
// Conclusion: Growth to C2 over cubic field with defining polynomial x^3+d
// Order 3
P3:=PrimitiveDivisionPolynomial(E,3);
PP3:=Factorization(P3);
L3:=[f[1] : f in PP3 | Degree(f[1]) eq 3];
assert #L3 eq 1;
f:=L3[1];
assert f eq x^3 + 4*d;
//y^2=x^3+d=x^3+4*d-3*d=-3*d --> y^2=-3*d in a cubic, then d=-3*s^2
// Conclusion: Growth to C3 over cubic field with defining polynomial x^3-12*s^2 

// Study growth C6: 
// We need fields x^3-3*s^2 and x^3-12*s^2 isomorphic 
// --> 4^(1/3) in the field ---> K=Q(4^(1/3))
// --> (3*s^2)^(1/3) en K --> s=3*2*t^3 (we can assume t=1, since d is six-power free)
// -------> s=6 --> d=-3*6^2=-108
// Conclusion: Only torsion growth is C6 for d=-108 over cubic field of def. poly. x^3-4.
print "DONE";
quit;

