Local computation of differents and discriminants

We obtain several results on the computation of different and discriminant ideals of finite extensions of local fields. As an application, we deduce routines to compute the $\p$-adic valuation of the discriminant $\dsc(f)$, and the resultant $\res(f,g)$, for polynomials $f(x),g(x)\in A[x]$, where $A$ is a Dedekind domain and $\p$ is a non-zero prime ideal of $A$ with finite residue field. These routines do not require the computation of neither $\dsc(f)$ nor $\res(f,g)$; hence, they are useful in cases where this latter computation is inefficient because the polynomials have a large degree or very large coefficients.


Introduction
Let A be a Dedekind domain whose field of fractions K is a global field. Typical instances of A are the ring of integers of a number field, or the polynomial ring in one indeterminate over a finite field. Let L/K be a finite separable extension and B the integral closure of A in L. Let θ ∈ L be a primitive element of L/K, with minimal polynomial f (x) ∈ A[x]. Also, let p be a non-zero prime ideal of A, v p the canonical p-adic valuation and K p the completion of K at p.
The Montes algorithm [5] computes an OM representation of every prime ideal P of B lying over p [7]. An OM representation is a computational object supporting several data and operators, linked to one of the irreducible factors (say) F (x) of f (x) in K p [x]. Among these data, the OM representation contains the Okutsu invariants of F , which reveal a lot of arithmetic information about the finite extension of K p determined by F [11,4].
In this paper, we present an algorithm to compute the P-adic valuation of the different ideal Diff(L/K) in terms of the OM representation of P. Of course, this determines the p-adic valuation of the discriminant Disc(L/K). This computation does not require the computation of the discriminant Disc(f ) of f (x); actually, the algorithm provides the value of v p (Disc(f )) as a by-product. We use this fact to derive a routine to compute v p (Disc(g)) for an arbitrary polynomial g(x) ∈ K[x]. Also, we use similar ideas to compute the p-adic valuation of the resultant Res(g, h) of two polynomials g(x), h(x) ∈ K[x]. These routines may be useful in cases where the natural computation of Disc(g) or Res(g, h) is inefficient because the polynomials have a large degree or very large coefficients.
The algorithms are described in sections 2, 3. If A/p is small, the computation of δ := v p (Disc(g)) requires O n 2+ǫ + n 1+ǫ δ 2+ǫ word operations, where n = deg g. The computation of v p (Res(g, h)) has the same complexity, but taking n = max{deg g, deg h}, δ = v p (Res(g, h)). The algorithms have an excellent practical performance. In section 4 we present some numerical tests with Magma, in which we compare running times with the naive algorithms that compute first Disc(g) or Res(g, h), and then its p-valuation.
The core of the paper is section 1, where we discuss the computation of the different ideal of an extension of local fields. Let L P be the completion of L at the prime ideal P. Consider an embedding, L ⊂ L P ֒→ K p , of L into a fixed algebraic closure of K p , and let F (x) ∈ K p [x] be the monic irreducible factor of f (x) that vanishes on the image of θ in K p , which we denote still by the same symbol θ. Let e(F ) = e(P/p) be the ramification index of P over p, and f (F ) = f (P/p) the residual degree. The different ideal Diff(L P /K p ) is equal to the (e(F ) − 1 + ρ)-th power of the maximal ideal of the ring of integers of L P , where ρ is a non-negative integer that vanishes if and only if P is tamely ramified over p. On the other hand, from Theorem 1.7 we deduce identities: v p (Disc(F )) = nv p (F ′ (θ)) = nµ(F ) + f (F )ρ, for some invariant µ(F ) ∈ Q. The three numbers e(F ), f (F ), µ(F ) are Okutsu invariants of F , which can be expressed in terms of data contained in the OM representation of F by a direct formula (Proposition 1.4). Therefore, for the computation of Diff(L P /K p ) and v p (Disc(F )), we need only to compute v p (F ′ (θ)). Since it is impossible in general to get an exact computation of the polynomial F (x), in Theorem 1.11 we show how to construct a polynomial φ(x) ∈ A[x] which is sufficiently close to F (x) to have v p (φ ′ (θ)) = v p (F ′ (θ)). Finally, once we get this sufficiently good approximation φ to F , the value of v p (φ ′ (θ)) may be determined by using Newton polygons of higher order (Proposition 1.5), whose computation relies as well in data contained in the OM representation.

Computation of local different ideals
Let k be a local field, i.e. a locally compact and complete field with respect to a discrete valuation v. Let O be the ring of integers of k, m the maximal ideal, and F = O/m the residue field, which is a finite field. Let p be the characteristic of F.
Let k sep ⊂ k be the separable closure of k inside a fixed algebraic closure. Let v : k → Q ∪ {∞}, be the canonical extension of the discrete valuation v to k, normalized by v(k) = Z.
be a monic irreducible separable polynomial, θ ∈ k sep a root of F (x), and L = k(θ) the finite separable extension of k generated by θ. Denote n := [L : k] = deg F . Let O L be the ring of integers of L, m L the maximal ideal and F L the residue field. We indicate with a bar, -: , the canonical homomorphism of reduction of polynomials modulo m.
Let [φ 1 , . . . , φ r ] be an Okutsu frame of F (x), and let φ r+1 be an Okutsu approximation to F (x). That is, φ 1 , . . . , φ r+1 ∈ O[x] are monic separable polynomials of strictly increasing degree: 1 ≤ m 1 := deg φ 1 < · · · < m r := deg φ r < m r+1 := deg φ r+1 = n, and for any monic polynomial g(x) ∈ O[x] we have, for all 0 ≤ i ≤ r: with the convention that m 0 = 1 and φ 0 (x) = 1. It is easy to deduce from these conditions that the polynomials The length r of the frame is called the Okutsu depth of F (x). Okutsu frames were introduced by K. Okutsu in [11] as a tool to construct integral bases. Okutsu approximations were introduced in [4], where it is shown that the family φ 1 , . . . , φ r+1 determines an optimal F -complete type of order r + 1: In the special case φ r+1 = F , we have λ r+1 = −∞ and ψ r+1 is not defined. We call t F an OM representation of F . An OM representation of the polynomial F carries (stores) several invariants and operators yielding strong arithmetic information about F and the extension L/k. Let us recall some of these invariants and operators.
Attached to the type t F , there is a family of discrete valuations of the rational function field k(x), the MacLane valuations: Also, t F determines a family of Newton polygon operators: where 2 R 2 is the set of subsets of the Euclidean plane. Any non-zero polynomial g(x) ∈ k[x] has a canonical φ i -development: and the polygon N i (g) is the lower convex hull of the set of points (s, v i (a s φ s i )). Usually, we are only interested in the principal polygon N − i (g) ⊂ N i (g) formed by the sides of negative slope. For all 1 ≤ i ≤ r, the Newton polygons N i (F ) and N i (φ i+1 ) are one-sided and they have the same slope, which is a negative rational number λ i ∈ Q <0 . The Newton polygon N r+1 (F ) is one-sided and it has an (extended) integer negative slope, which we denote by There is a chain of finite extensions: . We have ψ i (y) = y, for all i > 0. Finally, there are also residual polynomial operators: The exponents ω i+1 are all positive and ω r+1 = 1. The operator R r+1 is defined only when φ r+1 = F ; in this case, we also have R r+1 (F ) ∼ ψ r+1 , with ψ r+1 (y) ∈ F r+1 [y] monic of degree one such that ψ r+1 (y) = y.
We recall that the length of a Newton polygon N is the abscissa of its right end point; we denote it by ℓ(N ). There is a strong link between the operators R i and From all these data of the OM representation some more numerical invariants are deduced. Initially we take: Then we define for all 1 ≤ i ≤ r + 1: The general definition of a type may be found in [6,Sec. 2.1]. In later sections, we shall consider types which are not necessarily optimal nor F -complete. So, it may be convenient to distinguish these two properties among all features of a type that we have just mentioned.
) be a type of order i.
• We say that t is optimal if m 1 < · · · < m i .
• We say that t divides the polynomial g( . We say that t is g-complete if ord ψi R i (g) = 1.
Thus, for a general type of order i we have m 1 | · · · | m i and ω i > 0, but not necessarily m 1 < · · · < m i = deg F , and ω i = 1. These were particular properties of our optimal and F -complete type t F of order i = r + 1, constructed from an Okutsu frame and an Okutsu approximation to F . An irreducible polynomial F admits infinitely many different OM representations. However, the numerical invariants e i , f i , h i , for 0 ≤ i ≤ r, and the MacLane valuations v 1 , . . . , v r+1 attached to t F , are canonical invariants of F .
The data λ r+1 , ψ r+1 are not invariants of F ; they depend on the choice of the Okutsu approximation φ r+1 . The integer slope λ r+1 = −h r+1 measures how close is φ r+1 to F . We have φ r+1 = F if and only if h r+1 = ∞.
Since the Okutsu invariants of F can be computed from data contained in the OM representation of F , the only extra information we need to compute the different ideal is the value of the non-negative integer ρ, which is a measure of the wildness of the ramification. If L/k is a Galois extension, then it is well-known how to deduce the value of ρ from the higher ramification subgroups of the Galois group [15]. We are interested in the computation of ρ for an arbitrary extension L/k.
By applying the formula for ind(F ) in Proposition 1.4, we get a first formula for ρ in terms of the Okutsu invariants µ(F ), f (F ) and the v-value of Disc(F ).
However, we are interested in a computation of ρ that does not require the computation of Disc(F ). This can be achieved as follows.
Proof. Since deg F ′ < n = m r+1 , item 1 of Corollary 1.6 and Proposition 1.4 show that v(F ′ (θ)) = v r+1 (F ′ )/e. Hence, by (2) and Theorem 1.7, If we divide both terms of the equality by f , we get the result.
As a consequence, the conductor of F (x) is an Okutsu invariant too. In fact, it is well-known that [15, Ch.III, §6,Cor.2] On the other hand, Corollary 1.8 shows that Thus, by comparing the two identities we get an expression of f(F ) as an Okutsu invariant.
In practice, we deal with some polynomial f (x) with coefficients in a Dedekind domain A, and F (x) is an irreducible factor of f (x) over the completion of A at a nonzero prime ideal p of A. Thus, we never get an exact computation of the polynomial F (x), but only an approximation to it. Therefore, if L/k is wildly ramified and we want to apply Corollary 1.8 to compute ρ, we need to find a polynomial φ( To this end is devoted the next section.

Okutsu approximations and the different. Suppose
be an Okutsu approximation to F (x). That is, φ is a monic separable polynomial of degree n such that v(φ(θ))/n > v(φ r (θ))/m r , where r is the Okutsu depth of F (x) and [φ 1 , . . . , φ r ] is some Okutsu frame of F (x). This polynomial φ(x) is always irreducible and it has the same Okutsu invariants as F (x) [4,Lem. 4.3]. In particular, Proposition 1.4 shows that However, the non-negative integer ρ( . The aim of this section is to find how close to F must be taken the approximation φ, to ensure that v r+1 (φ ′ ) = v r+1 (F ′ ). By Corollary 1.8 and (3), this implies ρ(φ) = ρ(F ); thus, the polynomial φ may be used to determine the value of ρ(F ) and hence the different ideal of L/k.
) is a measure of the quality of φ as an approximation to F . By item 2 of Corollary 1.6, we have Since V r+1 and e are constant, the positive integer h φ is a measure of the quality of the approximation too. The main result in this section (Theorem 1.11) finds a sufficient condition to ensure that φ is sufficiently close to F to have the same exponent of the different ideal. Before proving this theorem we need a lemma, inspired by [12].
be a monic irreducible separable polynomial, t F an OM representation of F as in (1), and θ ∈ k sep a root of F .
Let i ≥ 1, and suppose the statement of the lemma is true for all polynomials of degree less than m i . Assume m i ≤ deg g < m i+1 , and let For any s ≥ 0, let (0, H s ) be the intersection point of the vertical axis with the line of slope λ i passing through (s, v i (a s φ s i )). Clearly, deg a s (φ i ) s ≤ deg g < m i+1 ; hence, Proposition 1.5 and Corollary 1.
and v(g(θ)) = v i+1 (g)/e = H/(e 0 e 1 · · · e i−1 ), where (0, H) is the intersection point of the vertical axis with the line of slope λ i that first touches N i (g) from below (see Figure 2). Therefore, Let us write: and if p | e 0 e 1 · · · e i−1 , then the inequality is strict.
satisfy this inequality. By the induction hypothesis and Corollary 1.
In particular, if L ′ /k is the extension determined by φ, then Diff(L/k) and Diff(L ′ /k) are divided by the same power of m L and m L ′ , respectively.
the last equality by Corollary 1.
In order to get an algorithm to compute ρ(F ) (and Diff(L/k)), we must replace the condition h φ > ρ(F ) by something checkable. This is done in a different way for local fields of equal or unequal characteristic. Corollary 1.12. If k has characteristic zero and h φ ≥ ev(e), then ρ(φ) = ρ(F ).
Proof. It is well-known that in this case ρ(F ) ≤ ev(e). Hence, h φ ≥ ev(e) implies h φ ≥ ρ(F ), and the arguments of the proof of Theorem 1.
In the equal characteristic case, the value of ρ(F ) is unbounded among all polynomials F of a fixed degree. We may proceed as follows in this case.
Therefore, we may apply the Single-factor lifting (SFL) algorithm of [8] to improve the Okutsu approximation φ till the checkable condition of either Corollary 1.12 or Corollary 1.13 is satisfied, and then we obtain a computation of ρ(F ) as ρ(φ). In each iteration, from a given Okutsu approximation φ, we compute a better one Φ satisfying h Φ ≥ 2h φ ; thus, only a finite (and small) number of iterations are required.
In the equal characteristic case, the condition h φ > ρ(φ) must be attained after a finite number of iterations, because ρ(F ) is fixed and when we reach h φ > ρ(F ), then we have already ρ(φ) = ρ(F ) < h φ , by Theorem 1.11.

Computation of the p-adic valuation of discriminants
Let A be a Dedekind domain whose field of fractions K is a global field. Let p be a non-zero prime ideal of A, and v p : , and let B be the integral closure of A in L.
In this section, we apply the results of the preceding section to compute the p-adic valuation of the discriminant ideal Disc(L/K), and the v p -value of the discriminant Disc(g) of an arbitrary polynomial g(x) ∈ K[x]. Both tasks are based on a combination of the Montes algorithm [5] and the Single-factor lifting (SFL) algorithm [8].
2.1. Local computation of the different. Let K p be the completion of K at the prime ideal p and let O p be the ring of integers of K p . We denote still by v p the canonical extension of the p-adic valuation to an algebraic closure of K p . Let be the factorization of f (x) into a product of monic irreducible polynomials in O p [x]. Let L 1 , . . . , L t be the finite extensions of K p obtained by adjoining to K p a root of F 1 , . . . , F t , respectively. After a classical theorem of Hensel, there are exactly t prime ideals P 1 , . . . , P t in B lying over p, and Let us denote by F P (x) ∈ O p [x] the irreducible factor that corresponds to any such prime ideal P dividing p, and let L P be the corresponding extension of K p . At the input of f (x) and p, the Montes algorithm computes an OM representation of every P | p, or equivalently, of every irreducible factor F P [7]: (6) t P = (ψ 0 ; (φ 1 , λ 1 , ψ 1 ); · · · ; (φ r , λ r , ψ r ); (φ r+1 , λ r+1 , ψ r+1 )), carrying all invariants and operators described in section 1.1. The polynomials φ 1 , . . . , φ r+1 have all coefficients in A. Each type t P is f -complete and F P -complete; it singles out P (or F P ) by the following property: In particular, all Okutsu invariants of F P , like e(F P ), f (F P ), µ(F P ), ind(F P ), f(F P ) and exp(F P ), are computed by direct formulas in terms of data supported by the OM representation of P.
(2) The restriction to k of the valuation v r+1 coincides with e(P/p)v P . Hence, the value of v r+1 (a 0 ) does not change if we replace φ(x) by φ(x) + b(x), with b(x) ∈ A[x] of degree less than n P and b(x) ≡ 0 (mod p m ), for some m > (h φ + V r+1 )/e(P/p). In particular, the coefficients of the Okutsu approximation φ may be always simplified modulo such a power of p.
At the input of an OM representation of P (or F P ) and a prescribed precision ν ∈ N, the SFL algorithm computes an Okutsu approximation φ(x) to F P (x), such that φ(x) ≡ F (x) (mod p ν ) [8]. In each iteration of the main loop of SFL, a given Okutsu approximation φ(x) is used to construct a better Okutsu approximation Φ(x) with h Φ ≥ 2h φ . By [4,Lem. 4.5], we reach the desired precision ν when h φ ≥ e(P/p)(ν − ν r ), where r is the Okutsu depth of F P , and ν r is the Okutsu invariant described in section 1.1.
Therefore, the results of section 1 lead to the following routine to compute the different of the local extension L P /K p . 1 e ← e 0 e 1 · · · e r , µ ← 1≤j≤r (e j f j · · · e r f r − 1)h j /(e 1 · · · e j ).

IF precision = 0 THEN DO
3.1 Apply the SFL algorithm to compute an Okutsu approximation φ ∈ A[x] to F P , such that h φ ≥ precision. 3 OUTPUT: − The P-valuation of Diff(L P /K p ), as the value of the variable Diff.
. − An OM representation t P , as in (6), of a prime ideal P of B.
Apply one iteration of the SFL algorithm to compute an Okutsu OUTPUT: − The P-valuation of Diff(L P /K p ), as the value of the variable Diff.
Let us analyze the complexity of this routine. All tasks we are interested in may be performed modulo p ν , for a sufficiently high precision ν. Thus, we may assume that the elements of A are finite π-adic developments, for some π ∈ A which is a local generator of p. In particular, the computation of the p-adic valuation v p has a negligible cost.

Definition 2.2. An operation of A is called p-small if it involves two elements belonging to a fixed system of representatives of A/p.
Let q := #A/p. A p-small operation is equivalent to O log(q) 1+ǫ word operations, the cost of an operation in the residue field A/p. Working at precision ν, each multiplication in A costs O(ν 1+ǫ ) p-small operations if we assume the fast multiplications techniques of Schönhage-Strassen [14].
Note that n, e, f, n P are intrinsic invariants of L/K, but δ P depends on the choice of the polynomial f (x) ∈ A[x] used to construct this extension. In the tamely ramified case the routine is trivial; thus, we assume from now on that the characteristic p of A/p divides e. In particular, the different ideal Diff(L P /K p ) is divided by the e-th power of the maximal ideal, and n P ≤ v p (Disc(L P /K p )) ≤ δ P . Lemma 2.3. The SFL algorithm requires O nn P (h/e) 1+ǫ + n(δ P ) 1+ǫ p-small operations in A to compute an Okutsu approximation φ to F P , such that h φ ≥ h.
Proof. Let r be the Okutsu depth of F P and consider the Okutsu invariants e j , f j , µ j , ν j , V j , described in section 1.1. Along the proof of [8,Lem. 6.5], it is obtained an estimation of O nn P ((h/e) 1+ǫ + (V r+1 /e) 1+ǫ ) p-small operations for the SFL routine. The lemma is then a consequence of The inequality ν r ≤ µ r is a consequence of e i f i > 1, for all 1 ≤ i ≤ r, and the explicit formulas for these Okutsu invariants given in section 1.1. The inequality µ r = µ(F P ) ≤ δ P /n P follows from Proposition 1.4 and Theorem 1.7.
By [6,Lem. 4.21], the computation of v r+1 (φ ′ ) is essentially equivalent to the computation of the (φ 1 , . . . , φ r )-multiadic expansion of φ ′ . By [1,Lem. 5.4], this requires O((n P ) 1+ǫ ) operations in A. By Remark 2.1,(2) and (7), this is equivalent to the last equality because n P ≤ δ P . By (8), the complexity of step 3.2 is dominated by that of step 3.1. This ends the proof of the lemma in this case. If char(K) = p > 0, the routine Different is less efficient in practice because we must compute v r+1 (φ ′ ) after every iteration of the SFL routine. By the remarks following Corollary 1.13, the number of iterations is bounded from above by log 2 (ρ), where ρ := ρ(F P ).
By Lemma 2.3, the complexity of all SFL iterations is In the last equality we used n P ρ/e = f ρ ≤ δ P , by Theorem 1.7. Assume that we start the iterations with h φ = 1 (the worst possible case). If we compute each Okutsu approximation φ at the precision described in Remark 2.1, the complexity of the computation of all v r+1 (φ ′ ) is, by (8):

2.2.
Local computation of discriminants. The discriminant of L/K is the product of the local discriminants, so that v p (Disc(L/K)) = P|p v p (Disc(L P /K p )).
Since the local discriminant ideal Disc(L P /K p ) is the norm of the local different ideal Diff(L P /K p ), the routine Different leads in an obvious way to a routine to compute v p (Disc(L/K)). This routine does not require the previous computation of the discriminant Disc(f ) of the polynomial f (x); actually v p (Disc(f )) may be deduced from the identity v p (Disc(f )) = v p (Disc(L/K)) + 2 ind p (f ), where (9) ind This local index ind p (f ) is computed by the Montes algorithm as a by-product. This allows us to consider a more general routine pDiscriminant that admits an arbitrary monic polynomial g(x) ∈ A[x] as input. Before describing the routine, let us review some generalities on discriminants of polynomials and the role of the local index ind p (g) for a non-irreducible polynomial.
Let g(x) = a n x n + · · · + a 1 x + a 0 be a polynomial of degree n, with coefficients in K. The discriminant of g(x) is defined as: where θ 1 , . . . , θ n are the n roots of g(x) in an algebraic closure, with due counting of multiplicities. Clearly, for arbitrary a, b ∈ K * , one has Disc(ag(bx)) = a 2n−2 b n 2 −n Disc(g(x)).
Thus, as regards the computation of Disc(g), we may assume from now on that g(x) is a monic polynomial with coefficients in A.
. Let L G be the finite extension of K p determined by each irreducible factor G(x), and denote by P G the maximal ideal of the ring of integers of L G .
The discriminant has a well-known good behaviour with respect to products: We define the p-index of g(x) to be: where ind p (G i ) is, by definition, the local index ind(G i ) that was considered in section 1. The reader may check that this definition coincides with that of (9) For each i we have v p (Disc(G i )) = 2 ind p (G i ) + v p (Disc(L Gi /K p )). Therefore, (10) and (11) show that: is a separable polynomial, the Montes algorithm computes OM representations of all these local factors and also the value of ind p (g) as a by-product. Thus, properly combined with the routine Different, we get the following routine to compute 1≤i≤t v p (Disc(L Gi /K p )) and v p (Disc(g)).

Routine pDiscriminant
1 Apply the Montes algorithm to get OM representations of the different irreducible factors G(x) ∈ O p [x] of g(x), and the value of ind p (g). Different(g, t G ) and accumulate f · v PG (Diff(L G /K p )) to Disc. 4 DiscPol ← Disc + 2 ind p (g).
OUTPUT: − The value of Disc is the sum of the p-adic valuations of all local discriminants Disc(L G /K p ), for G running on all irreducible factors of g over K p . The value of DiscPol is the p-valuation of Disc(g).
By Theorem 2.4, the complexity of step 3 may be estimated as: where P runs on the wildly ramified primes lying over p. Clearly, this cost is dominated by that of step 1.
In this routine the input polynomial must have Disc(g) = 0, otherwise the Montes algorithm enters into an endless loop. Nevertheless, if char(K) = 0, we can use upper bounds for the discriminant to design an algorithm that works for an arbitray monic input g(x) ∈ A[x]. For instance, if A = Z and p = pZ, for some prime number p, then Mahler's bound [9]: | Disc(g)| < n n g 2n−2 ∞ , g ∞ := |a 0 | + · · · + |a n | leads to v p (Disc(g)) < n v p (n) + (2n − 2)v p ( g ∞ ). The reader may derive similar upper bounds, v p (Disc(g)) < N (g), in the general case. Along the flow of Montes algorithm, partial p-indices (taking positive integer values) are accumulated to a variable Index, whose final output value is ind p (g). If Disc(g) = 0, we run into an endless loop that strictly increases Index at each iteration. Thus, we may introduce a control instruction that allows the next iteration while the value of Index is less than N (g), but it breaks the loop and outputs v p (Disc(g)) = ∞ otherwise.

Computation of the p-adic valuation of resultants
Consider two polynomials f (x) = a n x n + · · · + a 1 x + a 0 , g( of degree n, m, respectively. For any a, b, c ∈ K * we have Res(af (bx), cg(bx)) = a m c n b nm Res(f (x), g(x)).
Hence, as regards the computation of the resultant, we may suppose that f (x), g(x) are monic and have coeficients in A.
In [6,Sec. 4.1] the p-adic valuation of the resultant of two monic polynomials in A[x] is computed by applying a kind of non-optimized version of the Montes algorithm. In this section we reformulate those ideas into a concrete algorithm based on the optimized Montes algorithm as described in [5].
3.1. Partial exponents of resultants. In this section we introduce certain positive integers Res h t,φi (f, g), whose accumulation is equal to v p (Res(f, g)). These partial v p -values of resultants are computed in terms of combinatorial data of adequate Newton polygons of the polynomials f (x), g(x).
Let us describe in some detail the relevant Newton polygon routine. Along the algorithm that computes v p (Res(f, g)), we shall construct types of order i − 1, dividing f (x). All polynomials φ 1 , . . . , φ i−1 will have coefficients in A, and the type will always be loaded with three level i invariants, The choice of a representative of t determines a Newton polygon operator N i , with respect to φ i and the MacLane valuation v i supported by t (see section 1.1).
The invariant cs i is a cutting slope; it is a positive integer h telling us that we must compute only the subpolygon N h i (f ) formed by the sides of N i (f ) of slope less than −h. By a variation of Lemma 1.1, we are able to compute a priori the length of this subpolygon, and this is the role of the third invariant: ω i = ℓ(N csi i (f )). Since we always know a priori the length of the Newton polygons we are interested in, we may use the following Newton routine.
Routine Newton(t, ω, g) INPUT: − A type t of order i − 1 ≥ 0 and a representative φ of t. − A positive integer ω. − A non-zero polynomial g(x) ∈ K[x].
Compute the first ω + 1 coefficients a 0 (x), . . . , a ω (x) of the canonical φ-expansion of g(x) and the Newton polygon N of the set of points (s, v i (a s φ s )), for 0 ≤ s ≤ ω.
OUTPUT: − A list [S 1 , . . . , S t ] of the sides of N .
A side S of N is a segment of negative slope of the Euclidean plane, whose end points have non-negative integer coordinates. The length, E = ℓ(S), and height, H, of S are the lengths of its projections to the horizontal and vertical axes, respectively. Following the convention of [6, Sec.1.1], we admit sides S of slope −∞; we may think that the left end point of such an S is (0, ∞), and the right end point is (s, u), with s ∈ Z >0 and u ∈ Z ≥0 . The length of such a side is E = s and the height is H = ∞ (see Figure 3).
If the left end point of a Newton polygon N has a positive abscissa, we consider (formally) that the side of slope −∞ determined by this point is also one of the sides of N . According to this formalism, if N = S 1 + · · · + S t are all sides, finite and infinite, of N , we have always ℓ(N ) = ℓ(S 1 ) + · · · + ℓ(S t ). Let t = (ψ 0 ; (φ 1 , λ 1 , ψ 1 ); · · · ; (φ i−1 , λ i−1 , ψ i−1 )) be a type of order i − 1 and let φ i be a representative of t. Let f (x), g(x) ∈ A[x] be two monic polynomials. We define As the notation suggests, Res The Montes algorithm is fully described in [5], in terms of the theoretical background developed in [6]. For a short review, we address the reader to [10], or [1,Sec. 4].
We present a detailed description of the routine pResultant, directly in pseudocode. We denote by φ t i , λ t i , ψ t i , V t i , etc. the data at the i-th level of a type t.
3 FOR every irreducible factor ϕ DO 4 Set b ← ord ϕ (g (mod p)). IF b = 0 THEN continue to the next factor ϕ. 5 Take a monic φ(x) ∈ A[x] such that φ(y) (mod p) = ϕ(y). 6 Create a type t of order zero with: . WHILE Stack is non-empty DO 1 Extract (and delete) the last type t 0 from Stack. Let i − 1 be its order.
. IF b = 0 THEN continue to the next factor ψ. 9 IF ω i > 1 THEN make a copy t of the type t 0 and extend it to an order i type by setting: , and delete all data in the (i + 1)-th level of t ELSE set φ t i+1 ← φ, cs t i+1 ← 0.  (1) We mentioned already that ω i = ℓ(N csi i (f )). Thus, the computation (and storing) of this invariant saves operations in the Newton routine because we know a piori how many coefficients of the φ i -development must be computed. For the same reason, we compute and store in all types a completely analogous invariant α i telling a priori the value of ℓ(N csi i (g)).
(2) In step 9, the property ω i = 1 implies that t 0 is already f -complete (Definition 1.2), and φ t i is an Okutsu approximation to one of the irreducible factors (say) F (x) of f (x) over O p . In this case, the SFL routine may be applied, and one single iteration of its main loop leads to an Okutsu approximation φ with h φ ≥ 2h φ t i [8]. On the other hand, the standard construction of a representative of the type t leads to an Okutsu approximation φ with h φ ≥ h φ t i . Thus, the use of SFL accelerates the process of getting φ sufficiently close to F , to have (t 0 ; (φ, λ, ψ)) ∤ g(x) in a future iteration of the WHILE loop.
This acceleration leads to a significant improvement of the routine in cases where the polynomials f (x) and g(x) have p-adic irreducible factors which are very close one to each other. (3) Step 10 takes care of the optimization. If deg φ = deg φ t i , then the future information provided by the Newton polygon N − i+1 (f ), with respect to the pair (t, φ), is equivalent to the information provided by N csi i (f ), with respect to the pair (t 0 , φ) [5,Sec. 3.2]. The latter option is more efficient because we work at a lower order.
Proof. Let us call basic pResultant the algorithm obtained by eliminating the optimization procedure of step 10; that is, by replacing this step by: [6,Thm. 4.10], the basic pResultant algorithm terminates and the final output value of the variable Resvalue is v p (Res(f, g)).
On the other hand, pResultant and basic pResultant are equivalent algorithms, in the sense that they have the same number of iterations of the WHILE loop and they accumulate the same value to the variable Resvalue at each iteration. This is a consequence of [5, Props. 3.4+3.5] and the rest of the arguments of [5, Secs. 3.2+3.3], where a completely analogous situation was discussed when we compared basic and optimized versions of the Montes algorithm, both leading to the computation of ind p (f ) by the accumulation of partial indices.
The complexity analysis is obtained by completely analogous arguments to those used in [1] to estimate the complexity of the Montes algorithm.
As it was the case for the routine pDiscriminant, if char(K) = 0, the assumption Res(f, g) = 0 may be omitted by considering an upper bound for v p (Res(f, g)). For instance, for A = Z, n = deg f ≤ m = deg g, we have [3, Thm. 6.23], Res(f, g) ≤ f m 2 g n 2 = (|a 0 | 2 + · · · + |a n | 2 ) m/2 (|b 0 | 2 + · · · + |b m | 2 ) n/2 . We leave to the reader the derivation of similar upper bounds, v p (Res(f, g)) < N (f, g), in the general case. If Res(f, g) = 0, the WHILE loop of pResultant is an endless loop. However, it increases Resultant by a positive integer value at each iteration. Thus, we may introduce a control instruction allowing the next iteration as long as the value of Resultant is less than N (f, g), and breaking the loop with the output v p (Res(f, g)) = ∞ otherwise.

Numerical tests
We have implemented the routines pDiscriminant and pResultant in the case A = Z. They are included in the Magma package pFactors.m, which may be downloaded from http://montesproject.blogspot.com.
We present in this section some numerical tests for several polynomials selected from the families of test polynomials in the appendix of [8]. All tests have been done in a Linux server, with two Intel Quad Core processors, running at 3.0 Ghz, with 32Gb of RAM memory. Times are expressed in seconds.
We compare running times of our routines (abbreviated as pDis, pRes in the tables), with the naive routine that computes first Disc(g) or Res(g, h), and then its p-valuation. The numerical results show that the pDiscriminant and pResultant routines are much more efficient than the corresponding naive routines, when the degree of the polynomials and/or the size of the coefficients grow. f (x) = x + p + p 2 + · · · + p 20 n + p 20n+1 . This polynomial is irreducible over Z p [x] and it has Okutsu depth equal to one. It has v p (Disc(f )) = (20n + 1)(n − 1) + nv p (n) [ Let us test the influence of the existence of many p-adic irreducible factors. Let p > 5 be a prime number, and m a positive integer, m < p/2. Let g 0 (x) = x 10 + 2p 11 . Consider the polynomial of degree 10m: g(x) = g 0 (x)g 0 (x + 2) · · · g 0 (x + 2(m − 1)) + 2p 110m .