
// g1example.m

// Some examples accompanying the article
// "The invariants of a genus one curve"

// Author :   T.A.Fisher
// Version :  February 2008
// Requires Magma version 2.14.

// -----------------------------------------------------------------

// Wuthrich's example

R3<x,y,z> := PolynomialRing(Rationals(),3);

Q := x^5 + y*(-6*x^4 + 10*x^3*y - x^2*y^2 - 6*x*y^3 + y^4)
     + z*(4*x^4 + 2*x^3*z - 5*x^2*z^2 - 2*x*z^3 + z^4)
     + (1/16)*y*z*(-224*x^3 + 108*x^2*y + 116*x*y^2 + 10*y^3 + 68*x^2*z
		   - 166*x*y*z - 80*y^2*z + 160*x*z^2 + 81*y*z^2 - 56*z^3);

CC := Curve(Proj(R3),Q);

phi := GenusOneModel(5,[Rationals()|310,3,0,0,162,80,0,0,-32,0,10,
         0,0,28,16,-34,-5,0,0,-14,0,14,8,0,0,6,0,-7,4,0,-6,-3,
         0,0,-2,-4,0,0,0,0,0,2,0,0,0,0,0,-1,0,0]);

R<x1,x2,x3,x4,x5> := PolynomialRing(phi);

g0 := 1;
g1 := -3;
g2 := 5/2;
g3 := 0;
g4 := -7/4;

A := [x*(x*z-y^2),y*(x*z-y^2),z*(x*z-y^2),
	g0*x^3 + g1*x^2*y + g2*x^2*z + g3*x*y*z + g4*x*z^2 + y*z^2,
	g0*x^2*y + g1*x^2*z + g2*x*y*z + g3*x*z^2 + g4*y*z^2 + z^3];

I1 := Ideal(Image(map<CC->Proj(R)|A>));
I2 := Ideal(Equations(phi));
assert I1 eq I2;

// Computing the geometric invariants

Attach("g1geominv.m");

C := Curve(phi);
Omega := InvariantDifferential(phi);

print "We start with the genus one model";
print phi;
print "";

print "The invariants [c4,c6] are";
time cInvariants(phi);
print "";

time GeometricInvariants(C,Omega:Method:="Invariants");
print "";

time GeometricInvariants(C,Omega:Method:="Projection");
print "";

time GeometricInvariants(C,Omega:Method:="Projection",nproj:=2);
print "";

time GeometricInvariants(C,Omega:Method:="Wronskians");
print "";

//  Sample output

/*

> load "g1example.m";
Loading "g1example.m"
We start with the genus one model
Genus one model of degree 5 defined over Rational Field given by the matrix 
[0   310*x1 + 3*x2 + 162*x5   80*x1 - 32*x4   10*x1 + 28*x4 + 16*x5   -34*x1 - 
5*x2 - 14*x5]
[-310*x1 - 3*x2 - 162*x5   0   14*x2 + 8*x3   6*x1 - 7*x3 + 4*x4   -6*x1 - 3*x2 
- 2*x5]
[-80*x1 + 32*x4   -14*x2 - 8*x3   0   -4*x1   2*x2]
[-10*x1 - 28*x4 - 16*x5   -6*x1 + 7*x3 - 4*x4   4*x1   0   -x3]
[34*x1 + 5*x2 + 14*x5   6*x1 + 3*x2 + 2*x5   -2*x2   x3   0]

The invariants [c4,c6] are
[ 2656578422381215744, -2573029856234951903383912448 ]
Time: 0.130

n = 5. Using the Invariants method
[ 2656578422381215744, -2573029856234951903383912448 ]
Time: 0.140

n = 5. Using the Projection method
n = 4. Using the Invariants method
[ 2656578422381215744, -2573029856234951903383912448 ]
Time: 0.480

n = 5. Using the Projection method
n = 4. Using the Projection method
n = 3. Using the Invariants method
[ 2656578422381215744, -2573029856234951903383912448 ]
Time: 0.640

n = 5. Using the Wronskians method
  Computing 1st derivatives
Time: 1.000
  Computing 2nd derivatives
Time: 1.030
  Computing 3rd derivatives
Time: 1.060
  Computing 4th derivatives
Time: 1.050
  Computing 5th derivatives
Time: 1.050
  Computing 6th derivatives
Time: 1.060
  Computing P
Time: 0.140
  Computing P'
Time: 0.370
[ 2656578422381215744, -2573029856234951903383912448 ]
Time: 7.460

*/

