/*

Electronic appendix to "Ranks of elliptic curves over function fields",
by Alan G.B. Lauder. Published in LMS JCM.

The purpose of this Magma file is to allow the reader to verify the randomness of the choice of polynomials in Section 9 of the paper. 

During loading five lists will be created: 

ALLp7d6, ALLp7d12, ALLp7d18, ALLp7d24, ALLp7d30.

For d = ?, the list ALLp7d? contains 2000 randomly chosen polynomials of the form f(x,y) = x^3 + a(y)x + b(y) where a,b lie in Q[y] with deg_y a <= d/2 and deg_y b = d, and coefficients lie in the set {0,1,2,3,4,5,6}. Here Q denotes the rational numbers.

Let F_7 denote the finite field with 7 elements. Table 1 in Section 9 contains the results of applying the method in the paper to compute the ranks of the curves z^2 = f(x,y) over F_7(y) for the first 1000 polynomials f(x,y) on the list ALLp7d? (? = 6,12,18,24,30) which satisfy the following three conditions.

1. The polynomial f(x,0) mod 7 is squarefree.
2. The discriminant 4a^3 + 27b^2 mod 7 is squarefree.
3. The projective surface defined by the affine equation
z^(12e) = f(x^(4e),y) mod 7 is smooth, where d = 6e.

Table 2 in Section 9 contains the results of applying the method in the paper to compute the ranks of the curves z^2 = f(x,y) over F_7(y) for the first 1000 polynomials f(x,y) on the list ALLp7d? (? = 6,12,18,24,30) which satisfy conditions 1 and 2.

The reader may check the conditions using standard Magma functions, and thus recover the input used by the author.

The electronic appendix also contains the files UnitarisedLfunctions-p7d?.m 
(? = 6,12,18,24,30). The file UnitarisedLfunctions-p7d?.m contains a list of 1250
pairs [*f,P*]. The polynomials f are the first 1250 ones on the list
ALLp7d? which satisfy conditions 1 and 2, coerced by hand into
F_7[X,Y]. The polynomial P(T) is the unitarised L-function of the elliptic curve 
z^2 = f(x,y) over F_7(y). Thus P(7T) is the L-function of this curve.

*/

// START OF CODE

// Note that Magma v. 2.13-7 was originally used to generate the input.

// Global structures.

Q:=Rationals();
Qy<y>:=FieldOfFractions(PolynomialRing(Q));
Qyx<x>:=PolynomialRing(Qy);

/*

The function RandPol(m,d,lc) is used for polynomial generation.

Input: Integers m>=1, and d>=0, and lc in {0,1,2}
Output: Random polynomial with coefficients in {0,1,2,...,m-1} and either degree <= d (lc eq 0), degree = d and monic (lc eq 1), or degree = d (lc eq 2).

*/

function RandPol(m,d,lc)

 y:=Qy.1;

 if (lc eq 0) then
  OUT:=Random(0,m-1)*y^d;
 end if;
 if (lc eq 1) then
  OUT:=y^d;
 end if;
 if (lc eq 2) then
  OUT:=Random(1,m-1)*y^d;
 end if;
 if (lc lt 0) or (lc gt 2) then
  print "Error: RandPol!";
  return 0;
 end if;
 
 for i:=0 to d-1 do
  OUT:=OUT + Random(0,m-1)*y^i;
 end for;

 return OUT; 

end function;

/*

Code to generate the lists ALLp7d? (? = 6,12,18,24,30).

The seeds for the pseudorandom number generator at derived from ISBNs of books used by the author in the preparation of the paper.

*/

// Examples with p = 7 and d = 6.

p:=7;
d:=6; 
NO:=2000; // number generated

SetSeed(8238,691);
// The ISBN of "Etale Cohomology" by Milne is 0-691-08238-3

ALLp7d6:=[]; // list of all polynomials f(x,y) generated

for i:=1 to NO do
 f:=x^3 + RandPol(p,Floor(d/2),0)*x + RandPol(p,d,2);
 ALLp7d6:=Append(ALLp7d6,f);
end for;

// Examples with p = 7 and d = 12

p:=7;
d:=12; 
NO:=2000; // number generated

SetSeed(540,44228);
// The ISBN of "Galois Theory ..." by Singer, van der Put is 3-540-44228-6

ALLp7d12:=[]; // list of all polynomials f(x,y) generated

for i:=1 to NO do
 f:=x^3 + RandPol(p,Floor(d/2),0)*x + RandPol(p,d,2);
 ALLp7d12:=Append(ALLp7d12,f);
end for;

// Examples with p = 7 and d = 18

p:=7;
d:=18; 
NO:=2000; // number generated

SetSeed(52180283,69109151);
// The ISBN of "Hodge Theory ... II" by Voisin is 0 521 80283 0 (hardback)
// The ISBN of "Twisted L-functions ..." by Katz is 0 691 09151-X

ALLp7d18:=[]; // list of all polynomials f(x,y) generated

for i:=1 to NO do
 f:=x^3 + RandPol(p,Floor(d/2),0)*x + RandPol(p,d,2);
 ALLp7d18:=Append(ALLp7d18,f);
end for;

// Examples with p = 7 and d = 24

p:=7;
d:=24; 
NO:=2000; // number generated

SetSeed(69112330,54020665);
// The ISBN of "Moments, Monodromy, ..." by Katz is 0-691-12330-6 (pbk)
// The ISBN of "Sheaves in Topology" by Dimca is 3-540-20665-5

ALLp7d24:=[]; // list of all polynomials f(x,y) generated

for i:=1 to NO do
 f:=x^3 + RandPol(p,Floor(d/2),0)*x + RandPol(p,d,2);
 ALLp7d24:=Append(ALLp7d24,f);
end for;

// Examples with p = 7 and d = 30

p:=7;
d:=30; 
NO:=2000; // number generated

SetSeed(52164176,69103681);
// The ISBN of "Modern Computer Algebra" by von zur Gathen, Gerhard is
// 0 521 64176 (hbk)
// The ISBN of "Introduction to G-functions" by Dwork, Gerotto, Sullivan is
// 0 691 03681 0 (pbk)

ALLp7d30:=[]; // list of all polynomials f(x,y) generated

for i:=1 to NO do
 f:=x^3 + RandPol(p,Floor(d/2),0)*x + RandPol(p,d,2);
 ALLp7d30:=Append(ALLp7d30,f);
end for;

// END OF CODE.