A<x,y> := PolynomialRing(GF(5),2);
P,homogenize := Homogenization(A);
print("f := The polynomial from math.mit.edu/~drew/FFFc42.txt reduced mod 5");
f := x^16*y^4+4*(y+2)*y^4*x^15+(y^3+3*y^2+4*y+1)*(y+1)^2*(y+3)*y^3*x^14+4*(y^6+3*y^5+4*y^2+2*y+2)*(y+3)*y^3*x^13+3*(y^4+2*y^2+2*y+1)*(y^3+4*y^2+4*y+4)*(y+3)*y^2*x^12+2*(y+1)^2*y^2*(y^6+4*y^5+4*y^3+3*y^2+1)*x^11+3*(y^8+y^7+3*y^6+3*y^5+4*y^3+y^2+2*y+1)*y^2*x^10+4*(y^7+y^6+4*y^5+4*y^4+4*y^3+2*y+2)*(y^5+2*y^4+2*y^2+4*y+4)*y^2*x^9+(y+2)*(y^11+3*y^10+2*y^9+4*y^8+4*y^7+y^6+4*y^5+2*y^4+4*y^3+2*y^2+3*y+2)*(y^2+y+1)*y*x^8+2*(y^3+y^2+y+3)*(y+1)*(y^11+4*y^9+2*y^8+4*y^7+3*y^6+4*y^4+3*y^3+4*y^2+1)*x^7+3*(y^4+2*y^3+2*y^2+y+1)*(y^2+y+2)^2*(y^5+3*y^4+y^3+y^2+3*y+3)*y*(y+4)*x^6+4*(y^5+3*y^4+2*y^3+1)*(y^5+4*y^4+4*y^3+y^2+4)*y*(y^2+2*y+4)*(y+4)^2*x^5+(y+2)^2*(y+3)^2*y*(y+4)^5*x^4+3*(y^4+3*y^3+3*y+2)*y*(y+4)^5*x^3+3*(y+2)*y*(y+4)^5*(y^3+2*y^2+1)*x^2+2*(y^3+2*y^2+4*y+2)*y*(y+4)^6*x+(y^2+4*y+1)*y*(y+4)^7 ;

f := homogenize(f);
XF2 := Scheme(ProjectiveSpace(P),f);
FF := FunctionField(XF2);
AFF := AlgorithmicFunctionField(FF);
plc1 := Places(AFF,1);
cuspsum := &+ plc1;

function FunctionDegrees(divisor)
    constantField := ConstantField(FunctionField(divisor));
    space,map := RiemannRochSpace(divisor);
    return [Degree(map(i)) : i in space | map(i) notin constantField];
end function;

print("The number of places of degrees 1..6 is:");
[#Places(AFF,i) : i in [1..6]];
// [ 12, 6, 8, 183, 648, 2288 ]

// Say f is a function of degree <= 8, since f^(-1)({0,1,2,3,4,infinity}) contains
// all 12 rational points, by the pigeon hole principle we may assume that
// f^(-1)({infinity} contains at least 2 distinct rational points, and so
// the remaining-polar-part of f has degree at most 6.

pl,val := Support(Divisor(AFF.1));
for i in [1..#val] do
      if val[i] eq 3 then
                orb1 := pl[i];
      end if;
      if val[i] eq -7 then
		orb2 := pl[i];
      end if;
end for;

// Contains one member of each diamond-orbit:
orbs := [orb1, orb2];

// The cases below are semi-automatically generated:


// Degree >1 places: []
// Rat-places: [4, 6] (only multiplicities >1 are listed).
s := {(cuspsum + 3*Q1+5*Q2) : Q1 in plc1, Q2 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [3, 3]
// Rat-places: [] (only multiplicities >1 are listed).
s := {(cuspsum + P1+P2) : P1 in Places(AFF,3), P2 in Places(AFF,3)};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2, 3]
// Rat-places: [2] (only multiplicities >1 are listed).
s := {(cuspsum + P1+P2 + 1*Q1) : P1 in Places(AFF,2), P2 in Places(AFF,3), Q1 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2]
// Rat-places: [3, 4] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 2*Q1+3*Q2) : P1 in Places(AFF,2), Q1 in plc1, Q2 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [3]
// Rat-places: [2, 3] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 1*Q1+2*Q2) : P1 in Places(AFF,3), Q1 in plc1, Q2 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2, 2, 2]
// Rat-places: [] (only multiplicities >1 are listed).
s := {(cuspsum + P1+P2+P3) : P1 in Places(AFF,2), P2 in Places(AFF,2), P3 in Places(AFF,2)};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: []
// Rat-places: [2, 3, 4] (only multiplicities >1 are listed).
s := {(cuspsum + 1*Q1+2*Q2+3*Q3) : Q1 in plc1, Q2 in plc1, Q3 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2, 2]
// Rat-places: [2, 2] (only multiplicities >1 are listed).
s := {(cuspsum + P1+P2 + 1*Q1+1*Q2) : P1 in Places(AFF,2), P2 in Places(AFF,2), Q1 in plc1, Q2 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2, 4]
// Rat-places: [] (only multiplicities >1 are listed).
s := {(cuspsum + P1+P2) : P1 in Places(AFF,2), P2 in Places(AFF,4)};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [5]
// Rat-places: [2] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 1*Q1) : P1 in Places(AFF,5), Q1 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [2]
// Rat-places: [2, 2, 2] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 1*Q1+1*Q2+1*Q3) : P1 in Places(AFF,2), Q1 in plc1, Q2 in plc1, Q3 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [6]
// Rat-places: [] (only multiplicities >1 are listed).
s := {(cuspsum + P1) : P1 in Places(AFF,6)};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: []
// Rat-places: [2, 2, 2, 2] (only multiplicities >1 are listed).
s := {(cuspsum + 1*Q1+1*Q2+1*Q3+1*Q4) : Q1 in plc1, Q2 in plc1, Q3 in plc1, Q4 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// Degree >1 places: [4]
// Rat-places: [2, 2] (only multiplicities >1 are listed).
s := {(cuspsum + P1 + 1*Q1+1*Q2) : P1 in Places(AFF,4), Q1 in plc1, Q2 in orbs};
print "The number of RR-computations to be done for this case is:", #s;
s := &cat[FunctionDegrees(D) : D in s];
if not s eq [] then s := Min(s); end if;
s;

// This file showed that X1(42)(F5) has no functions of degree <= 8, so
// the F5-gonality is at least 9, so the Q-gonality is also at least 9.


