<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Computing Euler factors of genus 2 curves at odd primes of almost good reduction</title></titleStmt>
			<publicationStmt>
				<publisher>SpringerNature</publisher>
				<date>03/01/2025</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10626970</idno>
					<idno type="doi">10.1007/s40993-024-00605-7</idno>
					<title level='j'>Research in Number Theory</title>
<idno>2522-0160</idno>
<biblScope unit="volume">11</biblScope>
<biblScope unit="issue">1</biblScope>					

					<author>Céline Maistret</author><author>Andrew V Sutherland</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[<title>Abstract</title> <p>We present an efficient algorithm to compute the Euler factor of a genus 2 curve<inline-formula><alternatives><tex-math>$$C/\mathbb {Q}$$</tex-math><math><mrow><mi>C</mi><mo>/</mo><mi>Q</mi></mrow></math></alternatives></inline-formula>at an odd prime<italic>p</italic>that is of bad reduction for<italic>C</italic>but of good reduction for the Jacobian of<italic>C</italic>(a prime of “almost good” reduction). Our approach is based on the theory of cluster pictures introduced by Dokchitser, Dokchitser, Maistret, and Morgan, which allows us to reduce the problem to a short, explicit computation over<inline-formula><alternatives><tex-math>$$\mathbb {Z}$$</tex-math><math><mi>Z</mi></math></alternatives></inline-formula>and<inline-formula><alternatives><tex-math>$$\mathbb {F}_p$$</tex-math><math><msub><mi>F</mi><mi>p</mi></msub></math></alternatives></inline-formula>, followed by a point-counting computation on two elliptic curves over<inline-formula><alternatives><tex-math>$$\mathbb {F}_p$$</tex-math><math><msub><mi>F</mi><mi>p</mi></msub></math></alternatives></inline-formula>, or a single elliptic curve over<inline-formula><alternatives><tex-math>$$\mathbb {F}_{p^2}$$</tex-math><math><msub><mi>F</mi><msup><mi>p</mi><mn>2</mn></msup></msub></math></alternatives></inline-formula>. A key feature of our approach is that we avoid the need to compute a regular model for<italic>C</italic>. This allows us to efficiently compute many examples that are infeasible to handle using the algorithms currently available in computer algebra systems such as Magma and Pari/GP.</p>]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">Introduction</head><p>The L-functions and modular forms database (LMFDB) <ref type="bibr">[21]</ref> currently contains a database of 66,158 genus 2 curves C/Q with absolute discriminant bounded by 10 6 whose computation is described in <ref type="bibr">[4]</ref>. The bound on the discriminant is motivated by the fact that it also serves as a bound on the conductor of the L-function of C. In the context of the LMFDB one naturally organizes objects according to the conductor of their L-function, since this invariant determines the level of the corresponding modular form predicted by the Langlands program (in the case of genus 2 curves, a Siegel modular form that is generically a paramodular form). One prioritizes examples of small conductor, because this makes it more feasible to compute their L-functions, and to identify other objects in the LMFDB (including modular forms) that have the same L-function.</p><p>But bounding the discriminant is overly restrictive: genus 2 curves of small conductor need not have small discriminant. This is also true of elliptic curves, but becomes much more pronounced in higher genus due to the possibility that the minimal discriminant of a curve may be divisible by primes p that do not divide the conductor of its L-function, which cannot happen in genus 1. This necessarily happens when the Jacobian of C, reduces to a product of elliptic curves over F p , which forces the curve to have bad reduction. This is not an uncommon occurrence, and may happen even when the Jacobian is geometrically simple. We call a prime of bad reduction for C that does not divide the conductor of its L-function a prime of almost good reduction for C.</p><p>There is work in progress to expand the genus 2 curve database in the LMFDB to include more than five million genus 2 curves over Q with conductor below 2 20 &#8776; 10 6 , and more than half of these curves have almost good reduction at some prime, including almost half a million that have geometrically simple Jacobians <ref type="bibr">[20]</ref>. The primes p involved need not be small and may substantially exceed the conductor bound. For example, the curve C : y 2 + (x 3 + x 2 + x)y = -144061786290072x 6 -23062462482396x 5   -1266273619292236x 4 -3052943051575761x 3   + 3989955132045666x 2 + 50048078951052415x -24854569174209566 has prime conductor 270761 and minimal discriminant 270761 &#8226; 14556001 22 , with p = 14,556,001 a prime of almost good reduction, and there are examples with conductor less than 2 20 that have primes of almost good reduction as large as 43,858,540,753.</p><p>None of the computer algebra systems Magma <ref type="bibr">[2]</ref>, Pari/GP <ref type="bibr">[22]</ref>, or SageMath <ref type="bibr">[23]</ref> is currently able to compute the Euler factor at p = 14,556,001 for the L-function of the curve C listed above, and the method for computing bad Euler factors using the approximate functional equation described in <ref type="bibr">[4]</ref> cannot be feasibly applied here. In this example p is so much larger than the conductor that the inability to compute the Euler factor is not critical (one can approximate special values and bound the analytic rank without it), but there are hundreds of thousands of cases with p close to the square root of the conductor, a regime where it is difficult to accurately approximate the L-function without knowing the Euler factor at p and also difficult to guess the correct Euler factor and heuristically check it using the functional equation. Moreover, a single genus 2 curve may have multiple primes of almost good reduction, which complicates matters further. There are several curves in the new dataset that have five or more primes of almost good reduction, all of which are small enough to have a major impact on the functional equation, and the number of possibilities for the bad Euler factors is far too large to make heuristic checking feasible. These almost good primes have proven to be a major obstacle to attempts to expand the database of genus 2 curves in the LMFDB, which is what motivated the work we present here. Our main result is the following. Theorem 1.1 Let C/Q be a genus 2 curve y 2 = f (x) = i f i x i &#8712; Z[x] with almost good reduction at an odd prime p. There is a deterministic algorithm that, given a nonsquare element of F &#215; p , computes the L-polynomial L p (C, T ) in time O( f 2 log 2 f / log p + log 5 p), where f = max i log f i |. There is also a Las Vegas algorithm with the same expected running time that does not require a nonsquare element of F &#215; p to be provided as part of the input.</p><p>For large p the running time of this algorithm is dominated by the time to count points on elliptic curves using Schoof's algorithm. When p is small and the power of p dividing the discriminant is bounded, the running time is quasi-linear in f , which is the size of the input. The algorithm is described in detail in Sect. 4, and it is easy to implement. A simple implementation of the new algorithm in Magma is available in the GitHub repository associated to this paper <ref type="bibr">[13]</ref>, and it is already a dramatic improvement over the EulerFactor function implemented in Magma. <ref type="foot">1</ref> It took roughly 242 CPU days to compute Euler factors at approximately 3.5 million primes of almost good reduction arising in our small conductor dataset using the EulerFactor function, except for 489 cases where the computation did not terminate within 8 hours, an average of about 6 seconds per Euler factor. By contrast, a simple Magma implementation of our new algorithm takes less than 1.3 CPU hours to compute every Euler factor, averaging close to one millisecond per Euler factor with a maximum time of less than 25 milliseconds, including the 489 examples we were not able to compute using the EulerFactor intrinsic. A low level C implementation of the new algorithm takes only 30 CPU seconds to accomplish the same task (about 8 microseconds per Euler factor). See Sect. 5 and Tables 2, 3, 4 and 5 for further details of our implementation and the tests we ran.</p><p>Our algorithm does not treat curves with almost good reduction at the prime p = 2, even though there are many such examples, notably including the modular curve X 0 (22) whose Jacobian has conductor 11 <ref type="foot">2</ref> , the smallest conductor possible for an abelian surface. But our algorithm is still helpful in treating these cases because it makes it feasible to apply the methods of <ref type="bibr">[4]</ref> that can efficiently use the functional equation to compute the Euler factor at 2, provided the Euler factors at all larger primes are known.</p><p>We expect that the cluster picture approach we use here can be extended to other types of bad reduction for genus 2 curves, at least in a semistable setting; this is an area for future work. We should note that while our algorithms could conceivably be extended to handle almost good primes of genus 3 hyperelliptic curves, our method does not scale well with the genus. There is recent work on new methods for computing regular models, notably that of Dokchitser <ref type="bibr">[7]</ref> and Muselli <ref type="bibr">[15]</ref> that is likely to handle higher genus curves better than our approach, and may also allow one to treat other reduction types, with similar efficiency.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">Background</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.1">Euler factors</head><p>Let C be a smooth projective curve of genus g &#8805; 2 over Q. The L-function of C is defined as the Euler product</p><p>and has degree 2g at primes of good reduction for the Jacobian of C, including primes of almost good reduction for C, and otherwise has degree strictly less than 2g.</p><p>Here Frob p denotes an arithmetic Frobenius element, I p is the inertia subgroup of a decomposition group D p &#8834; Gal(Q alg /Q) and &#8467; is a prime distinct from p. Proposition 2.1 Let C/Q be a genus 2 curve and let p be a prime of almost good reduction for C. Let C be a Z p -model which is regular, and let C denote its special fiber. Then</p><p>Proof Note that all the components of C have multiplicity 1, since C has semistable reduction at p. The proposition then follows directly from Proposition 2.8 in <ref type="bibr">[3]</ref>.</p><p>One can compute the Euler factor L p (C, T ) via its connection to the zeta function of C/F p , although we note that this is not the only possible approach; see Section 1.1 of <ref type="bibr">[3]</ref>. Definition 2.2 Let X/F p be a curve. We define its zeta function by</p><p>,</p><p>Proof This is Theorem 13.1 in <ref type="bibr">[14]</ref> with X = C, combined with Proposition 2.1.</p><p>It follows from Theorem 2.3 that one can compute L p (C, T ) by computing the zeta function of the special fiber of a Z p -regular model of C/Q p . However, this may be computationally expensive; indeed, in the 489 cases mentioned in the introduction where Magma struggled to compute Euler factors at primes of almost good reduction, the difficulties arose while computing a regular model.</p><p>We will use the theory of cluster pictures to avoid computing a regular model. For a general exposition of the theory of cluster pictures, we refer the interested reader to <ref type="bibr">[1]</ref>,</p><p>where explicit examples are used to illustrate theoretical points. In particular, <ref type="bibr">[1,</ref><ref type="bibr">Section 6]</ref> provides examples of construction of special fibers from cluster pictures.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2.2">Cluster pictures</head><p>Let K be a local field of odd residue characteristic p, let v be a normalized valuation with respect to K , and let C/K a hyperelliptic curve of genus g &#8805; 2 given by</p><p>where f &#8712; K [x] is separable with deg(f ) = 2g + 1 or 2g + 2, and where R denotes the set of roots of f (x) in K sep . Definition 2.4 (Clusters and cluster pictures) A cluster is a non-empty subset s &#8838; R of the form s = D &#8745; R for some disc D = {x &#8712; K alg | v(xz) &#8805; d} for some z &#8712; K alg and d &#8712; Q.</p><p>For a cluster s with |s| &gt; 1, its depth d s is the maximal d for which s is cut out by such a disc, that is d s = min r,r &#8712;s v(r -r ). If moreover s = R, we define the parent cluster P(s) of s to be the smallest cluster with s P(s). Then the relative depth of s is &#948; s = d s -d P(s) .</p><p>We refer to this data as the cluster picture of C.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Remark 2.5</head><p>The absolute Galois group of K acts on clusters via its action on the roots. This action preserves depths and containments of clusters.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Definition 2.6</head><p>If s s is a maximal subcluster, we refer to s as a child of s.</p><p>For two clusters (or roots) s 1 , s 2 write s 1 &#8743; s 2 for the smallest cluster containing them.</p><p>Definition 2.7 A cluster s is principal except when:</p><p>&#8226; |s| &#8804; 2, or &#8226; s has a child of size 2g, or &#8226; s = R is even and has exactly two children.</p><p>Definition 2.8 For a cluster s set</p><p>Notation 2.9 We draw cluster pictures by drawing roots r &#8712; R as , and we draw ovals around roots to represent clusters (of size &gt; 1), such as:</p><p>The subscript on the largest cluster R is its depth, while the subscripts on the other clusters are relative depths.</p><p>Example 2.10 Consider the genus 2 curve C :</p><p>where p &#8805; 5 is a prime. Its cluster picture at p is given by 3 Cluster pictures and special fibers Proposition 3.1 Let C/Q be a genus 2 curve and p an odd prime of almost good reduction for C. Then the possible cluster pictures for C at p are for some integers m, n, t, with m &#8805; n in case 2) and m &gt; n in case 4), such that the following congruence relations are satisfied: v p (c) and n are even in cases 1), v p (c) &#8801; n &#8801; m mod 2 in cases 2) and 4), v p (c) &#8801; t mod 2 and n is even in cases 3). Proof This is Theorem 10.3 (5) in <ref type="bibr">[6]</ref> which implies that clusters s = R in the picture must contain an odd number of roots. This gives the classification of pictures above. The parity of the valuation of the leading term and the depths follow from the fact that &#957; s &#8712; 2Z for principal clusters.</p><p>The assumption that p is a prime of almost good reduction for C is essential in Proposition 3.1, as it controls the parity of v p (c). Changing the parity of v p (c) amounts to taking a quadratic twist, which does not change the cluster picture but will force Jac C to have bad reduction at p. Our algorithms will produce the same output given C or its quadratic twist by p, but in the latter case the input will not satisfy the necessary assumption that the Jacobian has good reduction at p; our algorithms cannot be used to compute the L-polynomial of the quadratic twist. 2. The assumption that p is a prime of good reduction for Jac C implies that the splitting field L of f is unramified (Theorem 10.3 (5) in <ref type="bibr">[6]</ref>). It follows that p is a uniformizer for L and that the normalized valuation v extends the valuation v p of K = Q p with index 1. 3. The reduction type for C in Proposition 3.1 corresponds to Namikawa-Ueno type I 0 -I 0r listed in <ref type="bibr">[6]</ref> Table <ref type="table">18</ref>.2. One can check using Theorem 8.6 in <ref type="bibr">[6]</ref> that the dual graphs of the special fibers corresponding to the four cluster pictures are</p><p>In the drawings above, vertices represent genus 1 components. These are linked by chains of 1 2 n, 1 2 (m + n), 1 2 n, and 1 2 (mn) edges respectively, representing genus 0 components in the special fiber. 4. When n = m in picture 2) of Proposition 3.1, the Frobenius automorphism will permute the two clusters of size 3 if their centers are defined over the unramified quadratic extension of Q p (and therefore are Galois conjugates). If this is the case we will draw a line between the two clusters in the picture as so: Note that in this case, the depths are necessarily equal.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Remark 3.3</head><p>1. We can assume without loss of generality that C : y 2 = f (x) is defined by a polynomial f &#8712; Z[x] of degree 6. This will ensure that the cluster picture of C is never of type 3). 2. The depth d R = t of the outer cluster in types 1), 2), 4) of Proposition 3.1 can be set to t = 0. This is the first step of our algorithm (see Definition 3.4 and Corollary 3.5 below). 3. We can assume without loss of generality that v p (c) is 0 or 1, and in the latter case that every coefficient of f &#8712; Z[x] is divisible by p.</p><p>We will give a constructive proof of the claims made in Remark 3.3 when we present our algorithms in the next section, but they motivate the following definition. </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Definition 3.4 Let p be an odd prime. A squarefree sextic polynomial</head></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Proposition 3.6 Let p be an odd prime and let C :</head><p>and let c = cp -v p (c) mod p &#8712; F p . Then depending on the type of the cluster picture of C at p, exactly one of the following holds:</p><p>with &#363;(r) = 0. Types 2a and 4 follow from a similar argument.</p><p>Type 2b: Here the Frobenius automorphism permutes the &#945;s and &#946;s pairwise. In particular, it has order 2 so that f splits into two cubic polynomials f 1 , f 2 over the unramified quadratic extension F of Q p .</p><p>From the cluster picture we have that &#945; 1 &#8801; &#945; 2 &#8801; &#945; 3 mod pO F and similarly for the &#946;s. It follows that f (x) &#8801; (x -&#955;) 3 </p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Corollary 3.7 Let C/Q be a genus 2 curve and p an odd prime of almost good reduction for C. Then the special fiber C/F p of the minimal regular model of C/Q p consists of a union of two elliptic curves linked by a chain of P 1 s.</head><p>Proof This follows directly from the list of possible cluster pictures given in Proposition 3.1 and [6, Definition 8.5 and Theorem 8.6], where explicit models for the components of the special fibers are constructed. One can then check that the components associated to principal clusters are indeed elliptic curves (see the proof of Corollary 3.10 for an example of such a construction). Alternatively, since Jac C has good reduction, it follows from the work of <ref type="bibr">Raynaud ( [16]</ref>, [8, <ref type="bibr">Section 9]</ref>) that its N&#233;ron model is an abelian scheme. Since the identity component of the special fiber of the N&#233;ron model is Pic 0 C, this forces C to be a genus 2 curve or a union of two elliptic curves. The former is a contradiction to the prime p being of bad reduction for C. Remark 3.8 For cluster pictures of type 2b in Corollary 3.5, the elliptic curves are defined over F p 2 and permuted by Frobenius, hence have the same L-polynomial.</p><p>Let E 1 and E 2 be the two elliptic curves in C given by Corollary 3.7. We now show how to compute L p (C, T ) from L p (E 1 , T ) and L p (E 2 , T ). Proposition 3.9 Let C/Q be a genus 2 curve, p an odd prime of almost good reduction for C, and r &#8805; 0 an integer. Let E 1 and E 2 be the two elliptic curves linked by a chain of P 1 s of length r, whose union forms the special fiber of the minimal regular model of C/Q p as given by Corollary 3.7.</p><p>Proof <ref type="bibr">(1)</ref> Suppose that E 1 and E 2 are defined over F p . It follows that each individual P 1 in the chain linking E 1 to E 2 is also defined over F p . Therefore P 2 (T ) = (1 -pT ) 2+r , by definition, since each component of C contributes a factor (1 -pT ).</p><p>Let</p><p>where we removed r + 1 intersection points that were counted twice. Therefore</p><p>and we have</p><p>T n n</p><p>The result then follows from Theorem 2.3.</p><p>(2) Suppose that E 1 and E 2 are defined over F p 2 . We have two cases. (i) If r is even, then all P 1 s in the chain linking E 1 and E 2 are defined over F p 2 and are permuted by Frobenius. Therefore</p><p>and the result follows from Theorem 2.3.</p><p>(ii) If r is odd, say r = 2k + 1, then the 2k P 1 s in the chain linking E 1 and E 2 are defined over F p 2 and permuted pairwise, while the "central" P 1 is defined over F p .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>It follows that we have</head><p>As in (i), let &#945;, &#946; be algebraic numbers such that</p><p>and the result follows from Theorem 2.3.</p><p>Corollary 3.10 Let C : y 2 = f (x) and p be as in Proposition 3.6 with type 1, 2a, 4, and let</p><p>Let L be the splitting field of f over Q p , let r 1 &#8712; O L be a root in the cluster of depth n, and for types 2a, 4 let r 2 &#8712; O L be a root in the cluster of depth m. Fix s 1 &#8712; Z with r 1 &#8801; s 1 mod p n O L , and for types 2a, 4, s 2 &#8712; Z with r 2 &#8801; s 2 mod p m O L . The elliptic curves E 1 /F p and E 2 /F p of Proposition 3.9 may be explicitly computed as follows:</p><p>1) E 1 : y 2 = &#7713;1 (x), where &#7713;1 &#8712; F p [x] is the squarefree part of f mod p, and</p><p>, and</p><p>is the squarefree part of f (p n x + s 1 )/p 5n mod p, and</p><p>Proof This follows from Definition 8.5 and Theorem 8.6 in <ref type="bibr">[6]</ref>, where explicit models for the components associated to principal clusters are constructed. We explicitly work out the case of Type 1, the other types are similar. There are two principal clusters in the cluster picture of Type 1: the full set of roots R = {&#945; 1 , &#945; 2 , &#945; 3 , &#946; 1 , &#946; 2 , &#946; 3 } ordered from left to right in the cluster picture, and the cluster of depth n, say s. We now follow Definition 8.5 in <ref type="bibr">[6]</ref>, which associates a component to each principal cluster. Recall that since C is semistable, v p (c) &#8712; 2Z (Definition 1.8 and Theorem 1.9 in <ref type="bibr">[6]</ref>), and therefore v p (c) = 0 by our assumption. For a root r, let r denote r mod pO L . We have</p><p>This gives 3 mod p. Note that &#946;1 &#8712; F p but that &#8113;1 , &#8113;2 , &#8113;3 may be permuted by Frobenius.</p><p>For E 2 , we look at the component associated to s. Choose z s = r 1 . We have v(r</p><p>which is f (p n x + s 1 )/p 3n mod p as claimed. </p><p>Then y 2 = &#7713;(x) and its Gal(&#954;/F p )-conjugate are models for the elliptic curves E 1 /F p 2 and E 2 /F p 2 of Proposition 3.9.</p><p>Proof Denote s 1 and s 2 the two clusters of size 3 in the picture. As for Type 1 in the proof above, we closely follow Definition 8.5 and Theorem 8.6 in <ref type="bibr">[6]</ref>. Both s 1 and s 2 are principal. Since the Frobenius automorphism permutes both clusters, the associated components (E 1 and E 2 ) must be Galois conjugate as mentioned in Remark 3.8. We construct E 1 explicitly. Denote &#945; 1 , &#945; 2 , &#945; 3 the roots in s 1 and &#946; 1 , &#946; 2 , &#946; 3 the roots in s 2 .</p><p>Permuting indices if necessary, Frobenius permutes &#945; i and &#946; i for i = 1, 2, 3. We choose r = z s 1 a center for s 1 . In particular, r is one of the &#945;s. Since v(r -</p><p>, where for a root &#946;, we have &#946; = &#946; mod pO L . It follows that E 1 /F p 2 is given by</p><p>which is f (p n x + s)/p 3n mod pO since v(r -&#945; i ) = n for i = 1, 2, 3. Now the construction of s 2 , which defines E 2 /F p 2 , is the same as that of s 1 with the roots &#945;s and &#946;s swapped. Since Frobenius permute them pairwise, it follows that E 2 is given by the Gal(&#954;/F p )conjugate of &#7713;(x).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">Algorithms</head><p>In this section we describe our algorithm for computing L p (C, T ) for a genus 2 curve C/Q at an odd prime p of almost good reduction; so p divides the minimal discriminant (C) &#8712; Z of C but does not divide the conductor N (C) &#8712; Z of its Jacobian. Computing the set of primes that satisfy this assumption is at least as hard as factoring (C), a problem for which no polynomial-time algorithm is known, but there are efficient algorithms to compute (C) <ref type="bibr">[12]</ref> and the p-adic valuation of N (C) at a given odd prime <ref type="bibr">[11]</ref>, and these have been widely implemented in computer algebra systems such as Magma <ref type="bibr">[2]</ref>, Pari/GP [22], and SageMath <ref type="bibr">[23]</ref>. We shall henceforth assume that any prime p provided as an input to our algorithms is a prime of almost good reduction for C.</p><p>As we will be working exclusively in rings of odd or zero characteristic, we may assume that C is specified by an integral model of the form y 2 = f (x), where f &#8712; Z[x] is a squarefree polynomial of degree 5 or 6 whose discriminant (f ) is divisible by p. We will state complexity bounds for our algorithms in terms of the logarithmic height Schoof's algorithm <ref type="bibr">[17,</ref><ref type="bibr">18]</ref> Here b denotes the number of bits used to represent the inputs, all of which we represent using O( <ref type="formula">1</ref> In our complexity analyses we will always count bit operations. For ease of reference we list asymptotic bit-complexity bounds for various operations used by our algorithms in Table <ref type="table">1</ref>, in which the parameter b bounds the bit-sizes of the inputs. We assume throughout that elements of the finite field F p are uniquely represented as integers in [0, p-1], so that reduction from Z to F p amounts to computing a remainder modulo p. We assume that elements of F p 2 F p [z]/(&#7713;(z)) are explicitly represented as linear polynomials z that have been reduced modulo an irreducible quadratic polynomial &#7713; &#8712; F p [x] that will be chosen by our algorithms. The bounds in Table <ref type="table">1</ref> apply to operations on elements of F p , F p 2 , Z, and also to polynomials over these rings that have bounded degree (we will only consider polynomials of degree at most 6), as well as elements and polynomials of bounded degree over the ring O := Z[z]/(g(z)), with g &#8712; Z[x] an irreducible monic quadratic that we will use to represent elements of the monogenic order O in the quadratic field Q[z]/(g(z)).</p><p>In the descriptions of our algorithms that follow we will frequently need to reduce elements of characteristic zero rings modulo p, and also to lift elements of characteristic p rings to characteristic zero. In our implementations all elements of characteristic p rings are represented as integers in [0, p -1] or lists of such integers, so there is no actual computation involved in lifting, but when describing our algorithms we will use the notation</p><p>to indicate that a is the lift of &#257; from a characteristic p ring (such as</p><p>). For the sake of clarity we use the overline notation "&#257;" to indicate that &#257; is an element of a characteristic p ring, and the absence of an overline in the notation "a" indicates that a lives in characteristic zero.</p><p>As can be seen from the cluster pictures in Proposition 3.1, while the polynomial f &#8712; Z[x] that defines the curve C : y 2 = f (x) must be squarefree, the reduction of p -v p (c) f modulo p will typically have repeated factors (with repeated roots defined over F p or F p 2 ); these factors are made explicit in Proposition 3.6 in the case that f is p-normalized. Efficiently determining these repeated factors and their multiplicity plays a key role in our algorithms and motivates the following definition.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Definition 4.1 For each positive integer k and polynomial</head><p>where g ranges over monic irreducible elements of F p [x] and v g (f ) = max{e &#8712; Z : g e |f }.</p><p>When p &gt; deg(f ) we can efficiently compute gcd k (f ) via gcd k (f ) = gcd f, f (1) , . . . , f (k-1) , where the gcd on the right is understood to be monic. In order to apply the main results of the previous section, which assume we are in the setting of Corollary 3.5, we may need to adjust the model of C : y 2 = f (x) to ensure that it is defined by a p-normalized polynomial f (see <ref type="bibr">Definition 3.4)</ref>. This leads to our first algorithm.</p><p>Algorithm 1 Given a squarefree f (x) = i f i x i &#8712; Z[x] of degree 5 or 6 and an odd prime p, construct a polynomial g(x) = i g i x i &#8712; Z[x] with v p (g 6 ) = min i {v p (g i )} &#8804; 1 for which the genus 2 curve y 2 = g(x) has an outer cluster of depth zero at p and is Q-isomorphic to y 2 = f (x).</p><p>1. If deg f = 5, compute f (a) for a = 0, 1, 2, . . . until f (a) = 0, replace f (x) by f (x + a), and then replace f (x) by x 6 f (1/x) so that deg f = 6. 2. Let v = v p (f 6 ), and if v &gt; 1 or v = min i {v p (f i )} then do the following:</p><p>, where w = 2 v/2 , and replace v by v p (f 6 ). Proof That y 2 = f (x) and y 2 = g(x) are Q-isomorphic follows from the fact that the sextic forms z 6 f (x/z) and z 6 g(x/z) are related by an invertible linear transformation of P 1 and multiplication by an even power of p, neither of which changes the Q-isomorphic class of the corresponding genus 2 curves. After step 2 we have v p (f 6 )</p><p>Step 2 can increase the depth of the outer cluster by at most e = O( f / log p).</p><p>In step 4 we have h(x) = i h i x i &#8712; Z[x] with v p (h 6 ) = 0. The outer cluster of y 2 = h(x) at p will have nonzero depth if and only if the roots of h mod p all coincide, equivalently, if and only if &#363; has positive degree. If this happens then deg &#363; = 1 (since deg(h mod p) = 6), and &#363; = x&#257;, where &#257; has multiplicity 6 as a root of h mod p, and then replacing h(x) by p -6 h(px + lift(&#257;)) &#8712; Z[x] reduces the depth of the outer cluster by one. Step 4 will terminate after O( f / log p) iterations when the depth reaches zero, and the genus 2 curve y 2 = g(x) = p v h(x) has its outer cluster of depth zero.</p><p>For the time bound, let b = f . We have a &#8804; 6 in step 1, which performs O( <ref type="formula">1</ref> </p><p>). This has the virtue of not increasing the depth of the outer cluster, which potentially saves time in step 4, but this may not work when p = 3, 5.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Remark 4.4</head><p>The loop in step 4 of Algorithm 1 which is used to decrease the depth of the outer cluster can be viewed as computing a common initial p-adic approximation to the roots of h(x), which all coincide modulo a power of p equal to the depth of the outer cluster. The same technique will be used in our algorithms below which work with the inner clusters. If h mod p had a simple root modulo p, or more generally, if we had an integer s for which v p (h(s)) &gt; 2v p (h (s)), we could use Hensel lifting to approximate a root to O( h / log p) digits of p-adic precision in quasi-linear time (as a function of h ), rather than the quasi-quadratic time required by step 4, since we can double the p-adic precision of our approximation in each step, rather than simply incrementing it. But we are in precisely the situation where Hensel's lemma does not apply, and in general h(x) need not have any Q p -rational roots, so there is no reason to expect that we can use Hensel lifting.</p><p>Remark 4.5 Unlike all our remaining algorithms, Algorithm 1 makes no assumptions about f (x) other than requiring it to be squarefree of degree 5 or 6, so that C : y 2 = f (x) is a genus 2 curve. Its output is p-normalized when C has almost good reduction at p, which will be true in the context of our main algorithm (see Algorithm 7 below) where it is used.</p><p>is a p-normalized polynomial we shall refer to the type of f as the type of the cluster picture of y 2 = f (x) at p, one of 1, 2a, 2b, 4. Our next algorithm uses Proposition 3.6 to efficiently determine the type of f . Proof By Proposition 3.6, we have a unique triple root if we are in case 1, two triple roots if we are in case 2a, the cube of an irreducible quadratic if we are in case 2b, and a unique quintuple root if we are in case 4, and these are mutually exclusive. The degree of &#7713; is thus 1, 2, or 3, depending on whether we are in case 1, 2a/2b, or 4, respectively, and the cases 2a and 2b are distinguished by whether &#7713; has F p -rationals roots or not, equivalently, whether (&#7713;) is a square or not.</p><p>Let b = f . From Table <ref type="table">1</ref> we see that Step 1 takes O(b log b) time, the cost of step 3 is negligible, and steps 2 and 4 both take O(b log 2 b) time, which bounds the total complexity.</p><p>Having determined the type of a p-normalized f &#8712; Z[x], we can use Corollaries 3.10 and 3.11 to compute the L-polynomial of C : y 2 = f (x) at p. To simplify the presentation we treat each of the four types separately.</p><p>3. Let r = lift(r) and repeat the following steps:</p><p>and go to step 4. c. Compute gcd 3 (&#7713; 2 ) = xr &#8712; F p [x] and replace r with lift(r).</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4.">Return</head><p>Remark 4. <ref type="bibr">7</ref> Step 3b only needs to be performed every second iteration, since the depth must be even, by Proposition 3.1. Proposition 4.8 Algorithm 3 is correct and runs in time O f 2 log 2 f / log p + log 5 p .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Proof</head><p>Step 2 computes h as the squarefree part of f , while step 3 iteratively computes the polynomial &#7713;2 (x) = f (p n x + s 1 )/p 3n mod p, where s 1 &#8801; r 1 mod p n for some root r 1 in the inner cluster of depth n; correctness follows from Corollary 3.10.</p><p>Let b = f . From Table <ref type="table">1</ref> we see that Our algorithm for type 2a is the one case where it is difficult to give an efficient deterministic algorithm because we need to compute the roots of a quadratic polynomial over F p . This can be done efficiently using a probabilistic algorithm, or by assuming the extended Riemann hypothesis, but in order to give an unconditional deterministic algorithm we will assume we are given a nonsquare s &#8712; F &#215; p . We can use s to deterministically compute the square root of any element of F p via the Tonelli-Shanks algorithm, which effectively computes square roots using a deterministic discrete logarithm computation in the 2-Sylow subgroup H of F &#215; p with respect to a given generator of H, which we can take to be s m where p = 2 e m + 1 with m odd. Remark 4.9 The nonsquare s &#8712; F &#215; p can be precomputed in O(log p(log log p) 2 ) expected time by picking random s &#8712; F &#215; p until one finds ( s p ) = -1; this computation depends only on p, not f . Algorithm 4 ( Type 2A) Given a p-normalized polynomial f = i f i x i &#8712; Z[x] of type 2a and a nonsquare s &#8712; F &#215; p , compute the L-polynomial of C : y 2 = f (x) at p.</p><p>3. Compute the roots r1 , r2 &#8712; F p of &#363; via the quadratic formula, using s to compute (&#363;). 4. Use r1 and r2 to compute elliptic curves E 1 and E 2 as in step 3 of Algorithm 3 (using   1. Use Algorithm 1 to replace f with a p-normalized polynomial f . 2. Use Algorithm 2 to determine the type of f (1, 2a, 2b, or 4). 3. Use whichever of Algorithms 3-6 matches the type to compute L p (C, T ) &#8712; Z[T ]. Proposition 4.13 Algorithm 7 is correct and runs in time O( f 2 log 2 f /log p + log 5 p). Proof This follows immediately from Propositions 4.2, 4.6, 4.8, 4.10, 4.11 and 4.12. Corollary 4.14 There is a probabilistic implementation of Algorithm 7 that does not require the input s &#8712; F &#215; p and runs in O( f 2 log 2 f /log p + log 5 p) &#8838; O( f 5 ) expected time. Proof As noted in Remark 4.9, we can compute a nonsquare s &#8712; F &#215; p in O(log p(log log p) 2 ) expected time and then apply Algorithm 7.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">Implementation</head><p>A simple Magma implementation of Algorithms 1-7 is available in the Genus2Euler GitHub repository associated to this paper <ref type="bibr">[13]</ref>. There is also a low-level C implementation based on the smalljac library <ref type="bibr">[10]</ref> that is still being refined; we report preliminary timings here. We tested our algorithms on a dataset of approximately 2.5 million genus 2 curves C/Q of small conductor that have almost good reduction at some prime p. This dataset covers a conductor range comparable to the current database of genus 2 curves in the LMFDB (2 20  Many of these curves have almost good reduction at more than one odd prime, and the total number of (C, p) pairs is 3 454 506. We attempted to compute each of the corresponding Euler factors in three ways: (1) using the EulerFactor intrinsic in Magma <ref type="bibr">[2]</ref>, (2) using the Magma implementation of Algorithm 7 available in <ref type="bibr">[13]</ref>, (3) using a smalljacbased C implementation of Algorithm 7. We ran our tests on a server equipped with dual 128-core AMD EPYC 9754 CPUs running at 2.25 GHz and 1.5 TB memory, with at most 256 tests running in parallel to avoid hyperthreading. All reported times are CPU times for a single core. We repeated each computation using our Magma and C implementations of Algorithm 7 for 100 and 10,000 iterations, respectively, to increase the accuracy of the timings (the algorithms are deterministic so there is very little variance in running times on the same input, but it is difficult to accurately time computations that take less than one millisecond), but we ran the computations using EulerFactor only once, due to the time involved; we terminated 489 of the tests involving EulerFactor that did not finish within 8 hours.</p><p>The total, average, median, and maximum running times to compute Euler factors for the 3 454 506 pairs (C, p) are shown above, with the 489 cases not completed by EulerFactor capped at 8 hours (Table <ref type="table">2</ref>).</p><p>The maximum time for the C implementation of Algorithm 7 is larger than one might expect (relative to the Magma implementation of Algorithm 7) because in some of the 2b cases we need to count points on elliptic curves over F p 2 with p &#8776; 2 30 , a regime for which the smalljac library has not been optimized (it is much faster over prime fields); if one excludes the type 2b cases the maximum running time for our C implementation drops to 34 microseconds, even with p &#8776; 2 35 .</p><p>More detailed timing information broken out by type for small primes p &#8804; 2 10 (about 90% of the test cases) can be found in Table <ref type="table">3</ref>. Finally, Tables <ref type="table">4</ref> and <ref type="table">5</ref> list ten examples of pairs (C, p) where Magma's EulerFactor function struggled; Table 4 lists 10 examples where EulerFactor took roughly an hour, and Table 5 lists 10 of the 489 examples where EulerFactor failed to terminate within 8 hours. A complete list of these 489 cases can be found in [13]. </p></div><note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="1" xml:id="foot_0"><p>We compare our algorithm to the EulerFactor intrinsic in Magma because it is the only implementation we are aware of that gives correct results when the computation terminates without reporting an error; neither Pari/GP nor SageMath currently support the computation of Euler factors for genus</p></note>
			<note xmlns="http://www.tei-c.org/ns/1.0" place="foot" n="2" xml:id="foot_1"><p>curves at primes of almost good reduction.</p></note>
		</body>
		</text>
</TEI>
