///////////////////////////////////////////////////////////////////////////
//
// 		"Torsion growth over cubic fields
//  of rational elliptic curves with complex multiplication"
//
// 		Enrique González-Jiménez
//
//      Magma script related to Remark 4
// 		
//
///////////////////////////////////////////////////////////////////////////
// Magma 2.24
//////////////////////////////////////////////////////////////////////////



// Bourdon, Abbey; Clark, Pete L.; Stankewicz, James 
// Torsion points on CM elliptic curves over real number fields. 
// Trans. Amer. Math. Soc. 369 (2017), no. 12, 8457–8496.
// Theorem 1.4 

function Kubert(b,c)
	return EllipticCurve([1-c,-b,-b,0,0]);
end function;



// Z/9Z -- cubic

L<c>:=NumberField(Polynomial([-1,-3,0,1]));
L1<c1>:=NumberField(Polynomial([-1,-9,-15,1])); 
L2<c2>:=NumberField(Polynomial([-1,-33,105,1]));
boo1,mapL1toL:=IsIsomorphic(L1,L);
assert boo1;
boo2,mapL2toL:=IsIsomorphic(L2,L);
assert boo2;


EL1:=Kubert(mapL1toL(1/4*c1^2+5/2*c1+1/4),mapL1toL(c1));
assert [9] eq AbelianInvariants(TorsionSubgroup(EL1));
WL1:=EllipticCurve([L!0,16]);
assert IsIsomorphic(EL1,WL1);

EL2:=Kubert(mapL2toL(-17/76*c2^2+25/19*c2+1/76),mapL2toL(c2));
assert [9] eq AbelianInvariants(TorsionSubgroup(EL2));
WL2:=EllipticCurve([L!-480,4048]);
assert IsIsomorphic(EL2,WL2);



// Z/14Z -- cubic

K1<b1>:=NumberField(Polynomial([1,3,-4,1]));
K2<b2>:=NumberField(Polynomial([1,3,-186,1]));
K<b>:=NumberField(Polynomial([-1,-2,1,1]));
boo1,mapK1toK:=IsIsomorphic(K1,K);
assert boo1;
boo2,mapK2toK:=IsIsomorphic(K2,K);
assert boo2;

EK1:=Kubert(mapK1toK(-2*b1^2+4*b1+1),mapK1toK(b1));
assert [14] eq AbelianInvariants(TorsionSubgroup(EK1));
WK1:=EllipticCurve([K!-2835*(-7)^2,-71442*(-7)^3]);
assert IsIsomorphic(EK1,WK1);

EK2:=Kubert(mapK2toK(2/27*b2^2+10/27*b2-1/27),mapK2toK(b2));
assert [14] eq AbelianInvariants(TorsionSubgroup(EK2));
WK2:=EllipticCurve([K!-595*(7)^2,5586*(7)^3]);
assert IsIsomorphic(EK2,WK2);


// Z/11Z -- quintic

M<e>:=NumberField(Polynomial([-1,-7,42,6,-9,1]));
MM<ee>:=Subfields(CyclotomicField(11),5)[1,1];
boo,map:=IsIsomorphic(M,MM);
assert boo;

EMM:=Kubert(map(-1/16*e^4+1/4*e^3+5/8*e^2+1/4*e-1/16),map(e));
assert [11] eq AbelianInvariants(TorsionSubgroup(EMM));

W:=EllipticCurve("121b1");
WMM:=BaseChange(W,MM);
assert IsIsomorphic(EMM,WMM);