Algebraic Diagonals and Walks
aa r X i v : . [ c s . S C ] O c t Algebraic Diagonals and Walks
Alin Bostan
InriaFrance
[email protected] Louis Dumont
InriaFrance
[email protected] Bruno Salvy
Inria, Laboratoire LIP(U. Lyon, CNRS, ENS Lyon, UCBL)France
ABSTRACT
The diagonal of a multivariate power series F is the univariate powerseries Diag F generated by the diagonal terms of F . Diagonals forman important class of power series; they occur frequently in numbertheory, theoretical physics and enumerative combinatorics. We studyalgorithmic questions related to diagonals in the case where F is theTaylor expansion of a bivariate rational function. It is classical thatin this case Diag F is an algebraic function. We propose an algorithmthat computes an annihilating polynomial for Diag F . Generically, itis its minimal polynomial and is obtained in time quasi-linear in itssize. We show that this minimal polynomial has an exponential sizewith respect to the degree of the input rational function. We then ad-dress the related problem of enumerating directed lattice walks. Theinsight given by our study leads to a new method for expanding thegenerating power series of bridges, excursions and meanders. Weshow that their first N terms can be computed in quasi-linear complex-ity in N , without first computing a very large polynomial equation. Categories and Subject Descriptors:
I.1.2 [
Computing Methodologies ]: Symbolic and Algebraic Manip-ulations —
Algebraic Algorithms
General Terms:
Algorithms, Theory.
Keywords:
Diagonals, walks, algorithms.
1. INTRODUCTION
Context.
The diagonal of a multivariate power series with coeffi-cients a i ,..., i k is the univariate power series with coefficients a i ,..., i .Particularly interesting is the class of diagonals of rational power se-ries (ie, Taylor expansions of rational functions). In particular, diag-onals of bivariate rational power series are always roots of nonzerobivariate polynomials (ie, they are algebraic series) [22, 15]. Sinceit is also classical that algebraic series are D-finite (ie, satisfy lineardifferential equations with polynomial coefficients), their coefficientssatisfy linear recurrences and this leads to an optimal algorithm forthe computation of their first terms [11,12,3]. In this article, we deter-mine the degrees of these polynomials, the cost of their computationand related applications. Previous work.
The algebraicity of bivariate diagonals is classical.The same is true for the converse; also the property persists for mul-tivariate rational series in positive characteristic [15,24,13]. The first
Publication rights licensed to ACM. ACM acknowledges that this contribution wasauthored or co-authored by an employee, contractor or affiliate of a national govern-ment. As such, the Government retains a nonexclusive, royalty-free right to publish orreproduce this article, or to allow others to do so, for Government purposes only.Copyright 20XX ACM X-XXXXX-XX-X/XX/XX ...$15.00. occurrence we are aware of in the literature is Pólya’s article [22],which deals with a particular class of bivariate rational functions; theproof uses elementary complex analysis. Along the lines of Pólya’sapproach, Furstenberg [15] gave a (sketchy) proof of the general re-sult, over the field of complex numbers; the same argument has beenenhanced later [18], [26, §6.3]. Three more different proofs exist:a purely algebraic one that works over arbitrary fields of character-istic zero [17, Th. 6.1] (see also [26, Th. 6.3.3]), one based onnon-commutative power series [14, Prop. 5], and a combinatorialproof [6, §3.4.1]. Despite the richness of the topic and the fact thatmost proofs are constructive in essence, we were not able to find inthe literature any explicit algorithm for computing a bivariate polyno-mial that cancels the diagonal of a general bivariate rational function.Diagonals of rational functions appear naturally in enumerativecombinatorics. In particular, the enumeration of unidimensional walkshas been the subject of recent activity, see [1] and the referencestherein. The algebraicity of generating functions attached to suchwalks is classical as well, and related to that of bivariate diagonals.Beyond this structural result, several quantitative and effective resultsare known. Explicit formulas give the generating functions in termsof implicit algebraic functions attached to the set of allowed steps inthe case of excursions [8, §4], [17], bridges and meanders [1]. More-over, if a and b denote the upper and lower amplitudes of the allowedsteps, the bound d a , b = (cid:0) a + ba (cid:1) on the degrees of equations for excur-sions has been obtained by Bousquet-Mélou, and showed to be tightfor a specific family of step sets, as well as generically [7, §2.1]. Fromthe algorithmic viewpoint, Banderier and Flajolet gave an algorithm(called the Platypus Algorithm ) for computing a polynomial of degree d a , b that annihilates the generating function for excursions [1, §2.3]. Contributions.
We design (Section 4) the first explicit algorithmfor computing a polynomial equation for the diagonal of an arbitrarybivariate rational function. We analyze its complexity and the size ofits output in Theorem 14. The algorithm has two main steps. The firststep is the computation of a polynomial equation for the residues of abivariate rational function. We propose an efficient algorithm for thistask, that is a polynomial-time version of Bronstein’s algorithm [9];corresponding size and complexity bounds are given in Theorem 10.The second step is the computation of a polynomial equation for thesums of a fixed number of roots of a given polynomial. We designan additive version of the Platypus algorithm [1, §2.3] and analyze itin Theorem 12. We show in Proposition 16 that generically, the sizeof the minimal polynomial for the diagonal of a rational function isexponential in the degree of the input and that our algorithm computesit in quasi-optimal complexity (Theorem 14).In the application to walks, we show how to expand to high pre-cision the generating functions of bridges, excursions and meanders.Our main message is that pre-computing a polynomial equation forthem is too costly, since that equation might have exponential size inthe maximal amplitude d of the allowed steps. Our algorithms havequasi-linear complexity in the precision of the expansion, while keep-ing the pre-computation step in polynomial complexity in d (Theo-rem 18). tructure of the paper. After a preliminary section on backgroundand notation, we first discuss several special bivariate resultants ofbroader general interest in Section 3. Next, we consider diagonals,the size of their minimal polynomials and an efficient way of comput-ing annihilating polynomials in Section 4.
2. BACKGROUND AND NOTATION
In this section, that might be skipped at first reading, we introducenotation and technical results that will be used throughout the article.
In this article, K denotes a field of characteristic 0. We denote by K [ x ] n the set of polynomials in K [ x ] of degree less than n . Similarly, K ( x ) n stands for the set of rational functions in K ( x ) with numeratorand denominator in K [ x ] n , and K [[ x ]] n for the set of power series in K [[ x ]] truncated at precision n .If P is a polynomial in K [ x , y ] , then its degree with respect to x (resp. y ) is denoted deg x P (resp. deg y P ), and the bidegree of P is thepair bideg P = ( deg x P , deg y P ) . The notation deg is used for univari-ate polynomials. Inequalities between bidegrees are component-wise.The set of polynomials in K [ x , y ] of bidegree less than ( n , m ) is de-noted by K [ x , y ] n , m , and similarly for more variables.The valuation of a polynomial F ∈ K [ x ] or a power series F ∈ K [[ x ]] is its smallest exponent with nonzero coefficient. It is denotedval F , with the convention val0 = ¥ .The reciprocal of a polynomial P ∈ K [ x ] is the polynomial rec ( P ) = x deg P P ( / x ) . If P = c ( x − a ) ··· ( x − a d ) , the notation N ( P ) standsfor the generating series of the Newton sums of P : N ( P ) = (cid:229) n > ( a n + a n + ··· + a nd ) x n . A squarefree decomposition of a nonzero polynomial Q ∈ A [ y ] , where A = K or K [ x ] , is a factorization Q = Q ··· Q mm , with Q i ∈ A [ y ] square-free, the Q i ’s pairwise coprime and deg y ( Q m ) >
0. The correspond-ing squarefree part of Q is the polynomial Q ⋆ = Q ··· Q m . If Q issquarefree then Q = Q ⋆ .The coefficient of x n in a power series A ∈ K [[ x ]] is denoted [ x n ] A .If A = (cid:229) ¥ i = a i x i , then A mod x n denotes the polynomial (cid:229) n − i = a i x i .The exponential series (cid:229) n x n / n ! is denoted exp ( x ) . The Hadamardproduct of two power series A and B is the power series A ⊙ B suchthat [ x n ] A ⊙ B = [ x n ] A · [ x n ] B for all n .If F ( x , y ) = (cid:229) i , j > f i , j x i y j is a bivariate power series in K [[ x , y ]] , the diagonal of F , denoted Diag F is the univariate power series in K [[ t ]] defined by Diag F ( t ) = (cid:229) n > f n , n t n . In several places, we need bounds on degrees of coefficients ofbivariate rational series. In most cases, these power series belongto K ( x )[[ y ]] and have a very constrained structure: there exists a poly-nomial Q ∈ K [ x ] and an integer a ∈ N such that the power series canbe written c + c yQ + ··· + c n y n Q n + ··· , with c n ∈ K [ x ] and deg c n n a , for all n . We denote by E a ( Q ) the setof such power series. Its main properties are summarized as follows. Lemma 1
Let Q , R ∈ K [ x ] , a , b ∈ N and f ∈ K [[ y ]] .(1) The set E a ( Q ) is a subring of K ( x )[[ y ]] ;(2) Let S ∈ E a ( Q ) with S ( ) = , then f ( S ) ∈ E a ( Q ) ;(3) The products obey E a ( Q ) · E b ( R ) ⊂ E max ( a + deg R , b + deg Q ) ( QR ) . P ROOF . For (3) , if A = (cid:229) n a n y n / Q n and B = (cid:229) n b n y n / R n belong re-spectively to E a ( Q ) and E b ( R ) , then the n th coefficient of their prod-uct is a sum of terms of the form a i ( x ) Q n − i b n − i ( x ) R i / ( QR ) n . There-fore, the degree of the numerator is bounded by i ( a + deg R ) + ( n − i )( b + deg Q ) , whence (3) is proved. Property (1) is proved similarly.In Property (2) , the condition on S ( ) makes f ( S ) well-defined. Theresult follows from (1) .As consequences, we deduce the following two results. Corollary 2
Let Q ∈ K [ x , y ] with q ( x ) = Q ( x , ) be such that q ( ) = .Let Q ⋆ be a squarefree part of Q. Then Q ∈ q E deg x Q ⋆ ( Q ⋆ ( x , )) . P ROOF . Write Q = q + R with R / q ∈ E deg x Q ( q ) . Then the resultwhen Q is squarefree ( Q = Q ⋆ ) follows from Part (2) of Lemma 1,with f = / ( + y ) . The general case then follows from Parts (1,3) . Proposition 3
Let P and Q be polynomials in K [ x , y ] , with Q ( , ) = , deg y Q > and F = P / Q. Then for all n ∈ N ,d n Fdy n = AQ ( Q ⋆ ) n , with bideg A bideg P + n ( deg x Q ⋆ , deg y Q ⋆ − ) . P ROOF . The Taylor expansion of F ( x , y + t ) has for coefficientsthe derivatives of F . We consider it either in K ( y )[ x , t ] or in K ( x )[ y , t ] .Corollary 2 applies directly for the degree in x . The saving on thedegree in y follows from observing that in the first part of the proof ofthe corollary, the decomposition Q ( x , y + t ) = Q ( x , y ) + R ( x , y , t ) hasthe property that deg y R deg y Q −
1. This − (3) of Lemma 1. We recall classical complexity notation and facts for later use. Let K be again a field of characteristic zero. Unless otherwise specified,we estimate the cost of our algorithms by counting arithmetic oper-ations in K (denoted “ops.”) at unit cost. The soft-O notation ˜ O ( · ) indicates that polylogarithmic factors are omitted in the complexityestimates. We say that an algorithm has quasi-linear complexity if itscomplexity is ˜ O ( d ) , where d is the maximal arithmetic size (numberof coefficients in K in a dense representation) of the input and of theoutput. In that case, the algorithm is said to be quasi-optimal . Univariate operations.
Throughout this article we will use the factthat most operations on polynomials, rational functions and powerseries in one variable can be performed in quasi-linear time. Stan-dard references for these questions are the books [16] and [10]. Theneeded results are summarized in Fact 4 below.
Fact 4
The following operations can be performed in ˜ O ( n ) ops. in K :(1) addition, product and differentiation of elements in K [ x ] n , K ( x ) n and K [[ x ]] n ; integration in K [ x ] n and K [[ x ]] n ;(2) extended gcd, squarefree decomposition and resultant in K [ x ] n ;(3) multipoint evaluation in K [ x ] n , K ( x ) n at O ( n ) points in K ; in-terpolation in K [ x ] n and K ( x ) n from n (resp. n − ) values atpairwise distinct points in K ;(4) inverse, logarithm, exponential in K [[ x ]] n (when defined);(5) conversions between P ∈ K [ x ] n and N ( P ) mod x n ∈ K [ x ] n . Multivariate operations.
Basic operations on polynomials, rationalfunctions and power series in several variables are hard questionsfrom the algorithmic point of view. For instance, no general quasi-optimal algorithm is currently known for computing resultants of bi-variate polynomials, even though in several important cases such algo-rithms are available [4]. Multiplication is the most basic non-trivialoperation in this setting. The following result can be proved usingKronecker’s substitution; it is quasi-optimal for fixed number of vari-ables m = O ( ) . act 5 Polynomials in K [ x ,..., x m ] d ,..., d m and power series in K [[ x ,..., x m ]] d ,..., d m can be multiplied using ˜ O ( m d ··· d m ) ops. A related operation is multipoint evaluation and interpolation. Thesimplest case is when the evaluation points form an m -dimensionaltensor product grid I × ··· × I m , where I j is a set of cardinal d j . Fact 6 [20] Polynomials in K [ x ,..., x m ] d ,..., d m can be evaluatedand interpolated from values that they take on d ··· d m points thatform an m-dimensional tensor product grid using ˜ O ( md ··· d m ) ops. Again, the complexity in Fact 6 is quasi-optimal for fixed m = O ( ) .A general (although non-optimal) technique to deal with more in-volved operations on multivariable algebraic objects (eg, in K [ x , y ] )is to use (multivariate) evaluation and interpolation on polynomialsand to perform operations on the evaluated algebraic objects usingFacts 4–6. To put this strategy in practice, the size of the outputneeds to be well controlled. We illustrate this philosophy on the ex-ample of resultant computation, based on the following easy variationof [16, Thm. 6.22]. Fact 7
Let P ( x , y ) and Q ( x , y ) be bivariate polynomials of respectivebidegrees ( d Px , d Py ) and ( d Qx , d Qy ) . Then, deg Resultant y ( P ( x , y ) , Q ( x , y )) d Px d Qy + d Qx d Py . Lemma 8
Let P and Q be polynomials in K [ x ,..., x m , y ] d ,..., d m , d .Then R = Resultant y ( P , Q ) belongs to K [ x ,..., x m ] D ,..., D m , whereD i = + ( d − )( d i − ) . Moreover, the coefficients of R can becomputed using ˜ O ( m d ··· d m d m + ) ops. in K . P ROOF . The degrees estimates follow from Fact 7. To compute R ,we use an evaluation-interpolation scheme: P and Q are evaluated at D = D ··· D m points ( x ,..., x m ) forming an m dimensional tensorproduct grid; D univariate resultants in K [ y ] d are computed; R is re-covered by interpolation. By Fact 6, the evaluation and interpolationsteps are performed in ˜ O ( mD ) ops. The second one has cost ˜ O ( dD ) .Using the inequality D m d ··· d m d m concludes the proof.. We conclude this section by recalling a complexity result for thecomputation of a squarefree decomposition of a bivariate polynomial. Fact 9 [19] A squarefree decomposition of a polynomial in K [ x , y ] d x , d y can be computed using ˜ O ( d x d y ) ops.
3. SPECIAL RESULTANTS3.1 Polynomials for Residues
We are interested in a polynomial that vanishes at the residues ofa given rational function. It is a classical result in symbolic integra-tion that in the case of simple poles, there is a resultant formula forsuch a polynomial, first introduced by Rothstein [23] and Trager [27].This was later generalized by Bronstein [9] to accommodate multiplepoles as well. However, as mentioned by Bronstein, the complexityof his method grows exponentially with the multiplicity of the poles.Instead, we develop in this section an algorithm with polynomial com-plexity.Let f = P / Q be a nonzero element in K ( y ) , where P , Q are twocoprime polynomials in K [ y ] . Let Q Q ··· Q mm be a squarefree de-composition of Q . For i ∈ { ,... , m } , if a is a root of Q i in an al-gebraic extension of K , then it is simple and the residue of f at a isthe coefficient of t − in the Laurent expansion of f ( a + t ) at t = V i ( y , t ) is the polynomial ( Q i ( y + t ) − Q i ( y )) / t , this residue is thecoefficient of t i − in the Taylor expansion at t = f ( y + t ) Q ii ( y + t ) / V ii ( y , t ) , computed with rational op-erations only and then evaluated at y = a . If this coefficient is de-noted S i − ( y ) = A i ( y ) / B i ( y ) , with polynomials A i and B i , the residue Algorithm AlgebraicResidues ( P / Q ) Input
Two polynomials P and Q ∈ K [ y ] Output
A polynomial in K [ z ] canceling all the residues of P / Q Compute Q Q ··· Q mm a squarefree decomposition of Q ; for i ← m doif deg y Q i = then R i ← else U i ( y ) ← Q ( y ) / Q ii ( y ) ; V i ( y , t ) ← ( Q i ( y + t ) − Q i ( y )) / t ;Expand P ( y + t ) U i ( y + t ) V ii ( y , t ) = S + ··· + S i − t i − + O ( t i ) ;Write S i − as A i ( y ) / B i ( y ) with A i and B i coprime; R i ( z ) ← Resultant y ( A i − zB i , Q i ) ; return R R ··· R m Algorithm 1.
Polynomial canceling the residues at a is a root of Resultant y ( A i − zB i , Q i ) . When m =
1, this is ex-actly the Rothstein-Trager resultant. This computation leads to Al-gorithm 1, which avoids the exponential blowup of the complexitythat would follow from a symbolic pre-computation of the Bronsteinresultants.
Example 1.
Let d > G d ( x , y ) ∈ Q ( x )[ y ] bethe rational function y d / ( y − y − x ) d + . The poles have order d + d : a squarefree decomposition has m = d + Q m = y − y − x , the other Q i ’s being 1. Then V m = − y − t and the next step is toexpand ( y + t ) d ( − y − t ) d + = ( y + t ) d ( − y ) d + (cid:16) − t − y (cid:17) d + . Expanding the binomial series gives the coefficient of t d as A m B m , with A m = d (cid:229) i = (cid:18) di (cid:19)(cid:18) d + ii (cid:19) y i ( − y ) d − i , B m = ( − y ) d + . The residues are then cancelled by Resultant y ( A m − zB m , Q m ) , namely ( − t ) d + z − ⌊ d / ⌋ (cid:229) k = (cid:18) d k (cid:19)(cid:18) kk (cid:19) t k ! . (1) Bounds.
In our applications, as in the previous example, the polyno-mials P and Q have coefficients that are themselves polynomials inanother variable x . Let then ( d P , e P ) , ( d Q , e Q ) , ( d ⋆ , e ⋆ ) and ( d i , e i ) bethe bidegrees in ( x , y ) of P , Q , Q ⋆ and Q i , where Q ⋆ = Q ··· Q m isa squarefree part of Q . In Algorithm 1, V i has degree at most d i in x and total degree e i − ( y , t ) . Similarly, P ( y + t ) has degree d P in x and total degree e P in ( y , t ) . When e ⋆ >
1, by Proposition 3, the coef-ficient S j in the power series expansion of P ( y + t ) / U i ( y + t ) / V i ( y , t ) i has denominator of bidegree bounded by ( d Q + jd ⋆ , e Q − i + j ( e ⋆ − )) and numerator of bidegree bounded by ( d P + jd ⋆ , e P − j + j ( e ⋆ − )) . Thus by Fact 7, deg x R i is at most (( i − ) d ⋆ + max ( d P , d Q )) e i + d i (( i − )( e ⋆ − ) − i + max ( e P + , e Q )) , while its degree in z is bounded by the number of residues e i . Sum-ming over all i leads to the bound ( e Q − e ⋆ ) d ⋆ + ( d Q − d ⋆ )( e ⋆ − )+ e ⋆ max ( d P , d Q ) − d Q + d ⋆ max ( e P + , e Q ) . If e ⋆ =
1, a direct computation gives the bound max ( d P , d Q ) + d ⋆ e P . heorem 10 Let P ( x , y ) / Q ( x , y ) ∈ K ( x , y ) d x + , d y + . Let Q ⋆ be a square-free part of Q wrt y. Let ( d ⋆ x , d ⋆ y ) be bounds on the bidegree of Q ⋆ .Then the polynomial computed by Algorithm 1 annihilates the residuesof P / Q, has degree in z bounded by d ⋆ y and degree in x bounded by d ⋆ x ( d y + ) + ( d ⋆ y − ) d x − d ⋆ x d ⋆ y . It can be computed in O ( m d ⋆ x d ⋆ y ( m + d ⋆ y )) operations in K . Note that both bounds above (when e ⋆ > e ⋆ =
1) are upperbounded by 2 d x d y , independently of the multiplicities. The complex-ity is also bounded independently of the multiplicities by O ( d ⋆ x d ⋆ y d y ) .P ROOF . The bounds on the bidegree of R = R R ··· R m are easilyderived from the previous discussion.By Fact 9, a squarefree decomposition of Q can be computed us-ing ˜ O ( d x d y ) ops. We now focus on the computations performed in-side the i th iteration of the loop. Computing U i requires an exactdivision of polynomials of bidegrees at most ( d x , d y ) ; this divisioncan be performed by evaluation-interpolation in ˜ O ( d x d y ) ops. Sim-ilarly, the trivariate polynomial V i can be computed by evaluation-interpolation wrt ( x , y ) in time ˜ O ( d i e i ) . By the discussion preced-ing Theorem 10, both A i ( x , y ) and B i ( x , y ) have bidegrees at most ( D i , E i ) , where D i = d x + id ⋆ x and E i = d y + id ⋆ y . They can be com-puted by evaluation-interpolation in ˜ O ( iD i E i ) ops. Finally, the re-sultant R i ( x , z ) has bidegree at most ( d i E i + e i D i , e i ) , and since thedegree in y of A i − zB i and Q i is at most E i , it can be computedby evaluation-interpolation in ˜ O (( d i E i + e i D i ) e i E i ) ops by Lemma 8.The total cost of the loop is thus ˜ O ( L ) , where L = m (cid:229) i = (cid:16) ( i + e i ) D i E i + d i e i E i (cid:17) . Using the (crude) bounds D i D m , E i E m , (cid:229) mi = e i d ⋆ y and (cid:229) mi = d i e i d ⋆ x d ⋆ y shows that L is bounded by D m E m m (cid:229) i = ( i + e i ) + E m m (cid:229) i = d i e i D m E m ( m + d ⋆ y ) + E m d ⋆ x d ⋆ y , which, by using the inequalities D m md ⋆ x and E m md ⋆ y , is seento belong to O ( m d ⋆ x d ⋆ y ( m + d ⋆ y )) .Gathering together the various complexity bounds yields the statedbound and finishes the proof of the theorem. Remark.
Note that one could also use Hermite reduction combinedwith the usual Rothstein-Trager resultant in order to compute a poly-nomial ˜ R ( x , z ) that annihilates the residues. Indeed, Hermite reduc-tion computes an auxiliary rational function that admits the sameresidues as the input, while only having simple poles. A close in-spection of this approach provides the same bound d ⋆ y for the degreein y of ˜ R ( x , z ) , but a less tight bound for its degree in x , namely worseby a factor of d ⋆ y . The complexity of this alternative approach appearsto be ˜ O ( d x d y ( d y + d ⋆ y )) (using results from [2]), to be compared withthe complexity bound from Theorem 10. Given a polynomial P ∈ K [ y ] of degree d with coefficients in afield K of characteristic 0, let a ,..., a d be its roots in the algebraicclosure of K . For any positive integer c d , the polynomial of degree (cid:0) dc (cid:1) defined by S c P = (cid:213) i < ··· < i c ( y − ( a i + a i + ··· + a i c )) (2)has coefficients in K . This section discusses the computation of S c P summarized in Algorithm 2, which can be seen as an additive ana-logue of the Platypus algorithm of Banderier and Flajolet [1].We recall two classical formulas (see, eg, [4, §2]), the second one Algorithm
PureComposedSum ( P , c ) Input
A polynomial P of degree d in K [ y ] , a positive integer c dOutput The polynomial S c P from Eq. (2) D ← (cid:0) dc (cid:1) N ( P ) ← rec ( P ′ ) / rec ( P ) mod y D + S ← N ( P ) ⊙ exp ( y ) mod y D + F ← exp (cid:16) (cid:229) cn = ( − ) n − S ( ny ) n z n (cid:17) mod ( y D + , z c + ) N ( S c P ) ← ([ z c ] F ) ⊙ (cid:229) n ! y n mod y D + return rec (cid:16) exp (cid:16) R D − N ( S c P ) y d y (cid:17) mod y D + (cid:17) Algorithm 2.
Polynomial canceling the sums of c roots being valid for monic P only:: N ( P ) = rec ( P ′ ) rec ( P ) , rec ( P ) = exp (cid:18) Z d − N ( P ) y d y (cid:19) . (3)Truncating these formulas at order d + N ( P ) a represen-tation of the polynomial P (up to normalization), since both con-versions above can be performed quasi-optimally by Newton itera-tion [25, 21, 4]. The key for Algorithm 2 is the following variantof [1, §2.3]. Proposition 11
Let P ∈ K [ y ] be a polynomial of degree d, let N ( P ) denote the generating series of its Newton sums and let S be the series N ( P ) ⊙ exp ( y ) . Let Y c be the polynomial in K [ t ,..., t c ] defined by Y c ( t ,..., t c ) = [ z c ] exp (cid:229) n > ( − ) n − t n z n n ! . Then the following equality holds N ( S c P ) ⊙ exp ( y ) = Y c ( S ( y ) , S ( y ) ,... , S ( cy )) . P ROOF . By construction, the series S is S ( y ) = (cid:229) n > ( a n + a n + ··· + a nd ) y n n ! = d (cid:229) i = exp ( a i y ) . When applied to the polynomial S c P , this becomes N ( S c P ) ⊙ exp ( y ) = (cid:229) i < ··· < i c exp (( a i + a i + ··· + a i c ) y )= [ z c ] d (cid:213) i = ( + z exp ( a i y )) . This expression rewrites: [ z c ] exp d (cid:229) i = log ( + z exp ( a i y )) ! = [ z c ] exp d (cid:229) i = (cid:229) m > ( − ) m − exp ( a i my ) z m m ! = [ z c ] exp (cid:229) m > ( − ) m − S ( my ) z m m ! , and the last expression equals Y c ( S ( y ) , S ( y ) ,... , S ( cy )) .The correctness of Algorithm 2 follows from observing that thetruncation orders D + y and c + z of the power series involvedin the algorithm are sufficient to enable the reconstruction of S c P from its first Newton sums by (3). Bivariate case.
We now consider the case where P is a polynomialin K [ x , y ] . Then, the coefficients of S c P wrt y may have denominators.We follow the steps of Algorithm 2 (run on P viewed as a polynomialin y with coefficients in K ( x ) ) in order to compute bounds on the bide-ree of the polynomial obtained by clearing out these denominators.We obtain the following result. Theorem 12
Let P ∈ K [ x , y ] d x + , d y + , let c be a positive integer suchthat c d y and let D = (cid:0) d y c (cid:1) . Let a ∈ K [ x ] denote the leading coeffi-cient of P wrt y and let S c P be defined as in Eq. (2) . Then a D · S c P isa polynomial in K [ x , y ] of bidegree at most ( d x D , D ) that cancels allsums a i + ··· + a i c of c roots a i ( x ) of P, with i < ··· < i c . Moreover,this polynomial can be computed in ˜ O ( cd x D ) ops. This result is close to optimal. Experiments suggest that for generic P of bidegree ( d x , d y ) the minimal polynomial of a i + ··· + a i c hasbidegree (cid:16) d x (cid:0) d y − c − (cid:1) , (cid:0) d y c (cid:1)(cid:17) . In particular, our degree bound is precisein y , and overshoots by a factor of d y / c only in x . Similarly, thecomplexity result is quasi-optimal up to a factor of d x d y only.P ROOF . The Newton series N ( P ) has the form N ( P ) = a deg y P + yA ( x , y ) a − yB ( x , y ) = a deg y P + yA ( x , y ) a (cid:229) n > y n B ( x , y ) n a n , with deg x A , deg x B d x . Since both factors belong to E d x ( a ) , Lemma 1implies that N ( P ) ∈ E d x ( a ) . Applying this same lemma repeatedly,we get that S c P ∈ E d x ( a ) (stability under the integration of Algo-rithm 2 is immediate). Since S c P has degree D wrt y , we deduce that a D S c P is a polynomial that satisfies the desired bound. By evaluationand interpolation at 1 + d x D points, and Newton iteration for quo-tients of power series in K [[ y ]] + D (Fact 4), the power series N ( P ) can be computed in ˜ O ( d x D ) ops. The power series S is then com-puted from N ( P ) in O ( d x D ) ops. To compute F we use evaluation-interpolation wrt x at 1 + d x D points, and fast exponentials of powerseries (Fact 4). The cost of this step is ˜ O ( cd x D ) ops. Then, N ( S c P ) is computed for O ( d x D ) additional ops. The last exponential isagain computed by evaluation-interpolation and Newton iteration us-ing ˜ O ( d x D ) ops.
4. DIAGONALS4.1 Algebraic equations for diagonals
The relation between diagonals of bivariate rational functions andalgebraic series is classical [15, 22]. We recall here the usual deriva-tion when K = C while setting our notation.Let F ( x , y ) be a rational function in C ( x , y ) , whose denominatordoes not vanish at ( , ) . Then the diagonal of F is a convergentpower series that can be represented for small enough t by a Cauchyintegral Diag F ( t ) = p i I F ( t / y , y ) d yy , where the contour is for instance a circle of radius r inside an annuluswhere ( t / y , y ) remains in the domain of convergence of F . This is thebasis of an algebraic approach to the computation of the diagonal asa sum of residues of the rational function P ( t , y ) Q ( t , y ) : = y F (cid:18) ty , y (cid:19) , with P and Q two coprime polynomials. For t small enough, thecircle can be shrunk around 0 and only the roots of Q ( t , y ) tendingto 0 when t → small branches . Thus the diagonal is given asDiag F ( t ) = (cid:229) Q ( t , y i ( t ))= t → y i ( t )= Residue (cid:18) P ( t , y ) Q ( t , y ) , y = y i ( t ) (cid:19) , (4)where the sum is over the distinct roots of Q tending to 0. We call theirnumber the number of small branches of Q and denote it by Nsmall ( Q ) .Since the y i ’s are algebraic and finite in number and residues are ob-tained by series expansion, which entails only rational operations, it Algorithm AlgebraicDiagonal ( A / B ) Input
Two polynomials A and B ∈ K [ x , y ] , with B ( , ) = Output
A polynomial F ∈ K [ t , D ] such that F ( t , Diag A / B ) = G ← y AB ( ty , y ) Write G as P / Q with coprime polynomials P and Q ; R ( z ) ← AlgebraicResidues ( P / Q ) c ← number of small branches of Q F ( t , z ) ← numer ( PureComposedSum ( R , c )) return F ( t , D ) Algorithm 3.
Polynomial canceling the diagonal of a rational function follows that the diagonal is algebraic too. Combining the algorithmsof the previous section gives Algorithm 3 that produces a polyno-mial equation for Diag F . The correctness of this algorithm over anarbitrary field of characteristic 0 follows from an adaptation of thearguments of Gessel and Stanley [17, Th. 6.1], [26, Th. 6.3.3]. Example 2.
Let d > F d ( x , y ) be the rationalfunction 1 / ( − x − y ) d + . The diagonal of F d is equal to (cid:229) n > (cid:18) n + dn (cid:19)(cid:18) n + dd (cid:19) t n . By the previous argument, it is an algebraic series, which is the sumof the residues of the rational function G d of Example 1 over its smallbranches (with x replaced by t ). In this case, the denominator is y − t − y . It has one solution tending to 0 with t ; the other one tends to 1.Thus the diagonal is cancelled by the quadratic polynomial (1). Example 3.
For an integer d >
0, we consider the rational function F d ( x , y ) = x d − − x d − y d + , of bidegree ( d , d + ) . The first step of the algorithm produces G d ( t , y ) = t d − y d − t d − y d + , whose denominator is irreducible with d small branches. RunningAlgorithm 3 on this example, we obtain a polynomial F d annihilat-ing Diag F d , which is experimentally irreducible and whose bidegreesfor d = , , , ( , ) , ( , ) , ( , ) , ( , ) . From thesevalues, it is easy to conjecture that the bidegree is given by (cid:18) d ( d + ) (cid:18) d − d − (cid:19) , (cid:18) d + d (cid:19)(cid:19) , of exponential growth in the bidegree of F d . In general, these bide-grees do not grow faster than in this example. In Theorem 14, weprove bounds that are barely larger than the values above. The rest of this section is devoted to the derivation of bounds onthe complexity of Algorithm 3 and on the size of the polynomial itcomputes, which are given in Theorem 14.
Degrees.
A bound on the bidegree of F will be obtained from thebounds successively given by Theorems 10 and 12.In order to follow the impact of the change of variables in thefirst step, we define the diagonal degree of a polynomial P ( x , y ) = (cid:229) i , j a i , j x i y j as the integer ddeg ( P ) : = sup (cid:8) i − j | a i , j = (cid:9) . We col-lect the properties of interest in the following.
Lemma 13
For any P and Q in K [ x , y ] ,(1) ddeg ( P ) deg x P;(2) ddeg ( PQ ) = ddeg ( P ) + ddeg ( Q ) ;3) there exists a polynomial ˜ P ∈ K [ x , y ] , such thatP ( x / y , y ) = y − ddeg ( P ) ˜ P ( x , y ) , with ˜ P ( x , ) = and bideg ( ˜ P ) bideg ( P ) + ( , ddeg ( P )) ; (4) bideg (( ˜ P ) ⋆ ) = ( deg x P ⋆ , ddeg ( P ⋆ ) + deg y P ⋆ ) . P ROOF . Part (1) is immediate. The quantity ddeg ( P ) is nothingelse than − val y P ( x / y , y ) , which makes Parts (2) and (3) clear too.From there, we get the identity f PQ = ˜ P ˜ Q for arbitrary P and Q ,whence ( ˜ P ) ⋆ = f P ⋆ and Part (4) is a consequence of Parts (1) and (3) .Thus, starting with a rational function F = A / B ∈ K ( x , y ) , with ( d x , d y ) a bound on the bidegrees of A and B , and ( d ⋆ x , d ⋆ y ) a bound onthe bidegree of a squarefree part B ⋆ of B , the first step of the algorithmconstructs G ( t , y ) = y a PQ , with polynomials P and Q and a = ddeg ( B ) − ddeg ( A ) − P ( d x , ddeg ( A ) + d y ) , bideg Q ( d x , ddeg ( B ) + d y ) , bideg Q ⋆ ( d ⋆ x , d ⋆ x + d ⋆ y ) . These inequalities give bounds on the degrees in x of the numeratorand denominator of G .The rest of the computation depends on the sign of a . If a > y of y a P and Q are bounded by ddeg ( B ) + d y ,while if a <
0, those of P and y − a Q are bounded by ddeg ( A )+ d y + d x + d y + e , where e = (cid:26) a < y bounded by d ⋆ x + d ⋆ y + e . From there, Theorem 10 yields bideg R ( D x , D y ) , with D x : = d ⋆ x ( d x − d ⋆ x + d y − d ⋆ y + ) + d x ( ( d ⋆ x + d ⋆ y + e ) − ) , (7) D y : = d ⋆ x + d ⋆ y + e . Small branches.
It is classical that for a polynomial P = (cid:229) a i , j x i y j ∈ K [ x , y ] , the number of its solutions tending to 0 can be read off itsNewton polygon. This polygon is the lower convex hull of the unionof ( i , j ) + N for ( i , j ) such that a i , j =
0. The number of solutionstending to 0 is given by the minimal y -coordinate of its leftmostpoints. Since the number of small branches counts only distinct solu-tions, it is thus given byNsmall ( P ) = Nsmall ( P ⋆ ) = val y ([ x val x P ⋆ ] P ⋆ ) . (8)The change of variables x x / y changes the coordinates of thepoint corresponding to a i , j into ( i , j − i ) . This transformation mapsthe vertices of the original Newton polygon to the vertices of theNewton polygon of the Laurent polynomial P ( x / y , y ) . Multiplyingby y ddeg ( P ) yields a polynomial and shifts the Newton polygon upby ddeg ( P ) , thusNsmall (cid:16) y ddeg ( P ) P ( x / y , y ) (cid:17) = Nsmall ( P ⋆ ) + ddeg ( P ⋆ ) . The number of small branches of the denominator of G constructedin the first step of the algorithm is then given by c : = Nsmall ( B ⋆ ) + ddeg ( B ⋆ ) + e . (9) Complexity.
We now analyze the cost of Algorithm 3. The first stepdoes not require any arithmetic operation. Next, the computation of R takes ˜ O (( d x + d y ) ) ops. (see the comment after Theorem 10). Thenumber of small branches is obtained with no arithmetic operationfrom a squarefree decomposition computed in Algorithm 1. Finally,Algorithm 2 uses ˜ O ( cD x (cid:0) D y c (cid:1) ) ops.We now have the values required by Theorem 12, which concludesthe proof of the following bounds. Theorem 14
Let F = A / B be a rational function in K ( x , y ) with B ( , ) = . Let ( d x , d y ) (resp. ( d ⋆ x , d ⋆ y ) ) be a bound on the bidegrees of A and B (resp. a squarefree part of B). Let e , D x , D y , c be defined asin Eqs. (6,7,9). Then there exists a polynomial F ∈ K [ t , D ] such that F ( t , Diag F ( t )) = and bideg F (cid:18) D x (cid:18) D y c (cid:19) , (cid:18) D y c (cid:19)(cid:19) . Algorithm 3 computes it in ˜ O (cid:16) cD x (cid:0) D y c (cid:1) + ( d x + d y ) (cid:17) ops. A general bound on bideg F depending only on a bound ( d , d ) on thebidegree of the input can be deduced from the above asbideg F ( d ( d + ) , ) × (cid:18) d + d (cid:19) . Assume that the denominator of F ( x / y ) / y is already partially fac-tored as Q ( y ) = ˜ Q ( y ) (cid:213) ki = ( y − y i ( x )) , where the y i are k distinct ra-tional branches among the c small branches of Q . Then their corre-sponding (rational) residues r i contribute to the diagonal; thereforeit is only necessary to invoke Algorithm 3 on ( ˜ Q , c − k ) , which pro-duces a polynomial ˜ F . Then the polynomial F ( t , D ) = ˜ F ( t , D − (cid:229) i r i ) cancels the diagonal of F .In particular, this optimization applies systematically for the fac-tor y − a when a < e =
1) in the algorithm. In thiscase, it yields a polynomial F with smaller degree than the originalalgorithm: deg D F (cid:18) d ⋆ x + d ⋆ y Nsmall ( B ⋆ ) + ddeg ( B ⋆ ) (cid:19) . (A sharper bound on the degree in t can be derived as well.) The bounds from Theorem 14 on the bidegree of F are slightlypessimistic wrt the variable t , but generically tight wrt the variable D ,as will be proved in Proposition 16 below. We first need a lemma. Lemma 15
Let K be a field of characteristic , and P ∈ K [ y ] be apolynomial of degree d, with Galois group S d over K . Assume thatthe roots a ,... a d of P are algebraically independent over Q . Then,for any c d, the degree (cid:0) dc (cid:1) polynomial S c P is irreducible in K [ y ] . P ROOF . Since S = a + ··· + a c is a root of S c P , it suffices toprove that K ( S ) has degree (cid:0) dc (cid:1) over K . The a i ’s being algebraicallyindependent, any permutation s ∈ S d of all the a i ’s that leaves S unchanged has to preserve a c + + ··· + a d as well. It follows that K ( a ,..., a d ) has degree c ! ( d − c ) ! over K ( S ) and degree d ! over K ,so that K ( S ) has degree (cid:0) dc (cid:1) over K Proposition 16
Let A be a polynomial in Q [ x , y ] d x , d y , andB ( x , y ) = (cid:229) i d x , j d y b i , j x i y j ∈ Q [( b i , j ) ; x , y ] , where the b i , j are indeterminates. Then the polynomial computedby Algorithm 3 with input A / B is irreducible of degree (cid:0) d x + d y d x (cid:1) over K = Q (( b i , j ) ; x ) . P ROOF . First apply the change of variables to obtain G = P / Q ,with Q ( x , y ) = (cid:229) i , j b i , j x i y d x − i + j . Denote d = d x + d y . Then, the poly-nomial Q ( , y ) has the form (cid:229) j d t j y j where the t j ’s are algebraicallyindependent over Q . Therefore, Q ( , y ) has Galois group S d over Q ( t ,..., t d ) and its roots are algebraically independent over Q [28,§57]. This property lifts to Q ( x , y ) [28, §61], which thus has Galoisgroup S d and algebraically independent roots, denoted y ,..., y d .Now define the polynomial R ( x , y ) = (cid:213) i ( y − P ( x , y i ) / ¶ y Q ( x , y i )) .Since Q has simple roots, this is exactly the polynomial that is com-puted by Algorithm 1. The family (cid:8) P ( x , y i ) / ¶ y Q ( x , y i ) (cid:9) is algebraicallyndependent, since any algebraic relation between them would induceone for the y i ’s by clearing out denominators. In particular, the nat-ural morphism Gal ( Q / K ) = S d → Gal ( R / K ) is injective, whencean isomorphism. (Here, Gal ( P / K ) denotes the Galois group of P ∈ K [ y ] over K .) Since an immediate investigation of the Newton poly-gon of Q shows that it has d x small branches, we conclude usingLemma 15.Proposition 16 implies that for a generic rational function A / B with A ∈ K [ x , y ] d , d and B ∈ K [ x , y ] d + , d + , the degree of F in D is (cid:0) dd (cid:1) .This is indeed observed on random examples. Example 4.
We consider a rational function F ( x , y ) = / B ( x , y ) ,where B ( x , y ) is a dense polynomial of bidegree ( d , d ) chosen at ran-dom. For d = , , ,
4, algorithm
AlgebraicDiagonal ( F ) produces irreducible outputs with bidegrees ( , ) , ( , ) , ( , ) , ( , ) ,that are matched by the formulas (cid:18) d (cid:18) d − d − (cid:19) , (cid:18) dd (cid:19)(cid:19) , (10)so that the bound on deg D F is tight in this case and the irreducibilityof the output shows that Theorem 14 cannot be improved further.
5. WALKS
The exponential degree of the minimal polynomial of a diagonalproved in Proposition 16 concerns more generally other sums of residues,since this is the step where the exponential growth of the algebraicequations appears. This includes in particular constant terms of ratio-nal functions in C ( x )[[ y ]] , that can also be written as contour integralsof rational functions around the origin.By contrast, sums of residues of a rational function always satisfya differential equation of only polynomial size [2]. Thus, when analgebraic function appears to be connected to a sum of residues of arational function, the use of this differential structure is much moreadapted to the computation of series expansions, instead of goingthrough a potentially large polynomial.As an example where this phenomenon occurs naturally, we con-sider here the enumeration of unidimensional lattice walks, followingBanderier and Flajolet [1] and Bousquet-Mélou [7]. Our goal in thissection is to study, from the algorithmic perspective, the series expan-sions of various generating functions (for bridges, excursions, mean-ders) that have been identified as algebraic [1]. One of our contribu-tions is to point out that although algebraic series can be expandedfast [11, 12, 3], the pre-computation of a polynomial equation couldhave prohibitive cost. We overcome this difficulty by pre-computingdifferential (instead of polynomial) equations that have polynomialsize only, and using them to compute series expansions to precision N for bridges, excursions and meanders in time quasi-linear in N . We start with some vocabulary on lattice walks. A simple step is a vector ( , u ) with u ∈ Z . A step set S is a finite set of simplesteps. A unidimensional walk in the plane Z built from S is a finitesequence ( A , A ,..., A n ) of points in Z , such that A = ( , ) and −−−−→ A k − A k = ( , u k ) with ( , u k ) ∈ S . In this case n is called the length of the walk, and S is the step set of the walk. The y -coordinate of theendpoint A n , namely (cid:229) ni = u i , is called the final altitude of the walk.The characteristic polynomial of the step set S is G S ( y ) = (cid:229) ( , u ) ∈ S y u . Following Banderier and Flajolet, we consider three specific fam-ilies of walks: bridges, excursions and meanders [1].
Bridges arewalks with final altitude 0, meanders are walks confined to the upperhalf plane, and excursions are bridges that are also meanders. We define the full generating power series of walks W S ( x , y ) = (cid:229) n > , k ∈ Z w n , k x n y k ∈ Z [ y , y − ][[ x ]] , where w n , k is the number of walks with step set S , of length n and finalaltitude k . We denote by B S ( x ) (resp. E S ( x ) , and M S ( x ) ) the powerseries (cid:229) n > u n x n , where u n is the number of bridges (resp. excursions,and meanders) of length n with step set S .We omit the step set S as a subscript when there is no ambiguity.Several properties of the power series W , B , E and M are classical: Fact 17 [1, §2.1-2.2] The power series W , B, E and M satisfy(1) W ( x , y ) is rational and W ( x , y ) = / ( − x G ( y )) ;(2) B ( x ) , E ( x ) and M ( x ) are algebraic;(3) B ( x ) = [ y ] W ( x , y ) ;(4) E ( x ) = exp ( R ( B ( x ) − ) / x d x ) . Our main objective in what follows is to study the efficiency of com-puting the power series expansions of the series B , E and M . In thenext two sections, we first study two previously known methods, thenwe design a new one. We denote by u − (resp. u + ) the largest u such that ( , − u ) ∈ S (resp. ( , u ) ∈ S ) and denote by d the sum u − + u + . The integer d measures the vertical amplitude of S ; this makes d a good scalefor measuring the complexity of the algorithms that will follow. Weassume that both u − and u + are positive, since otherwise the study ofthe excursions and meanders becomes trivial. The direct method.
The combinatorial definition of walks yields arecurrence relation for w n , k : w n , k = (cid:229) ( , u ) ∈ S w n − , k − u , (11)with initial conditions w n , k = n , k ( n , k ) = ( , ) , and w , =
1. If ˜ w n , k denotes the number of walks of length n and finalaltitude k that never exit the upper half plane, then ˜ w n , k also satisfiesrecurrence (11), but with the additional initial conditions ˜ w n , k = k <
0. Then the bridges (resp. excursions, meanders) are countedby the numbers w n , (resp. ˜ w n , , (cid:229) k ˜ w n , k ).One can compute these numbers by unrolling the recurrence rela-tion (11). Each use of the recurrence costs O ( d ) ops., and in the worstcase one has to compute O ( dN ) terms of the sequence (for example,if the step set is S = { ( , ) ,... , ( , d ) } ). This leads to the computa-tion of each of the generating series in O ( d N ) ops. Using algebraic equations.
Another method is suggested in [1, §2.3].It relies on the algebraicity of B , E and M (Fact 17 (2) ). The series E and M can be expressed as products in terms of the small branchesof the characteristic polynomial G S (see [1, Th. 1, Cor. 1]). Fromthere, a polynomial equation can be obtained using the Platypus algo-rithm [1, §2.3], which computes a polynomial canceling the productsof a fixed number of roots of a given polynomial. Given a polyno-mial equation P ( z , E ) =
0, another one for B can be deduced from therelation B = zE ′ / E + E (( B − ) EP E + zP z , P ) .Once a polynomial equation is known for one of these three series,it can be used to compute a linear recurrence with polynomial coef-ficients satisfied by its coefficients [11, 12, 3]. This method producesan algorithm that computes the first N terms of B , E and M in O ( N ) ops. For this to be an improvement over the naive method for large N ,the dependence on d of the constant in the O () should not be too largeand the precomputation not too costly.Indeed, the cost of the pre-computation of an algebraic equationis not negligible. Generically, the minimal polynomial of E has de-gree (cid:0) du − (cid:1) , which may be exponentially large with respect to d [7].Empirically, the polynomials for B and M are similarly large.The situation for differential equations and recurrences is different: B satisfies a differential equation of only polynomial size (see below),lgorithm Walks ( S , N ) Input
A set S of simple steps and an integer NOutput B S , E S , M S mod x N + F ← W ( x , y ) / y [case B , E ] or W ( x , y ) / ( − y ) [case M ] D ← HermiteTelescoping ( F ) [2, Fig. 3] R ← the recurrence of order r associated to DI ← [ y ] W ( x , y ) mod x r + [case B , E ] [ y ] yW ( x , y ) / ( − y ) mod x r + [case M ] B ← [ y ] W ( x , y ) mod x N + (from R , I ) A ← [ y ] yW ( x , y ) / ( − y ) mod x N + (from R , I ) E ← exp ( R ( B ( x ) − ) / x d x ) mod x N + M ← exp ( − R ( A ( x ) / x ) / ( − G ( ) x ) d x ) mod x N + return B , E , M Algorithm 4.
Expanding the generating functionsof bridges, excursions and meanders whereas (empirically), those for E and M have a potentially exponen-tial size. These sizes then transfer to the corresponding recurrencesand thereby to the constant in the complexity of unrolling them. Example 5.
With the step set S = { ( , d ) , ( , ) , ( , − d ) } and d >
2, the counting series W S equals W S ( x , y ) = y d y d − x ( + y d + + y d ) . Experiments indicate that the minimal polynomial of B S ( x ) has bide-gree ( d (cid:0) d − d − (cid:1) , (cid:0) dd (cid:1) ) , exhibiting an exponential growth in d . On theother hand, they show that B S ( x ) satisfies a linear differential equa-tion of order 2 d − d + d − d ,and d + d − d . New Method.
We now give a method that runs in quasi-linear time(with respect to N ) and avoids the computation of an algebraic equa-tion. Our method relies on the fact that periods of rational functionssuch as the one in Part (3) of Fact 17 satisfy differential equations ofpolynomial size in the degree of the input rational function [2]. Wesummarize our results in the following theorem, and then go over theproof in each case individually. Theorem 18
Let S be a finite set of simple steps and d = u − + u + .The series B S (resp. E S and M S ) can be expanded at order N inO ( d N ) ops. (resp. ˜ O ( d N ) ops.), after a pre-computation in ˜ O ( d ) ops. Bridges.
To expand B ( x ) , we rely on Fact 17 (3) . The formula can bewritten B = ( / p i ) H W ( x , y ) dyy , the integration path being a circleinside a small annulus around the origin [1, proof of Th. 1]. Moreover, W ( x , y ) / y is of the form P / Q , where bideg Q ( , d ) and bideg P ( , d − ) . Since P and Q are relatively prime and Q is primitive withrespect to y , Algorithm HermiteTelescoping [2, Fig. 3] computes atelescoper for P / Q , which is also a differential equation satisfied by B ,in ˜ O ( d ) ops. The resulting differential equation has order at most d and degree O ( d ) . This differential equation can be turned into arecurrence of order O ( d ) in quasi-optimal time (see the discussionafter [5, Cor. 2]). We may use it to expand B ( x ) mod x N in O ( d N ) ops, once we have a way to compute the initial conditions. But thiscan be done using the naive algorithm described above in ˜ O ( d ) ops.Thus, the total cost of the pre-computation is ˜ O ( d ) , as announced. Excursions. If B ( x ) mod x N + is known, it is then possible to re-cover E ( x ) mod x N + thanks to Fact 17 (4) . Expanding E ( x ) comesdown to the computation of the exponential of a series, which can beperformed using ˜ O ( N ) ops. (Fact 4 (4) ). Meanders.
As in the case of excursions, the logarithmic derivativeof M ( x ) is recovered from a sum of residues by the following. Proposition 19
The series W and M are related throughA ( x ) = [ y ] y − yW ( x , y ) , M ( x ) = exp (cid:16) − R A ( x ) x d x (cid:17) − x G ( ) . P ROOF . Denote by y ,..., y u − the small branches of the polyno-mial y u − − xy u − G ( y ) . Then M is given as [1, Cor. 1]: M ( x ) = − x G ( ) u − (cid:213) i = ( − y i ) . On the other hand, A ( x ) = p i I W ( x , y ) − y d y = u − (cid:229) i = Residue y = y i ( x ) (cid:18) ( − y )( − x G ( y )) (cid:19) = − u − (cid:229) i = ( − y i ) x G ′ ( y i ) , where the integral has been taken over a circle around the origin andthe small branches. Differentiating the equation 1 − x G ( y ) = 0 with re-spect to x leads to − x G ′ ( y i ) = / ( xy ′ i ) , whence A ( x ) = x (cid:229) u − i = y ′ i / ( − y i ) . Therefore, (cid:213) ( − y i ) = exp ( − R A / x d x )) , finishing the proof.Thus we apply the same method as in the case of the excursions. Wefirst compute a differential equation for A ( x ) using the method of [2].The computation of the initial conditions for A can also be performednaively from its definition as a constant term, by simply expanding yW ( x , y ) / ( − y ) . The formula of the proposition then recovers M ( x ) .The complexity analysis goes exactly as in the previous case, givinga global cost of ˜ O ( d ) ops. Acknowledgements.
This work has been supported in part by Fas-tRelax ANR-14-CE25-0018-01.
6. REFERENCES [1] C. Banderier and P. Flajolet. Basic analytic combinatorics of directed lattice paths.
TCS , 281(1-2):37–80, 2002.[2] A. Bostan, S. Chen, F. Chyzak, and Z. Li. Complexity of creative telescoping forbivariate rational functions. In
ISSAC’10 , pages 203–210. ACM, 2010.[3] A. Bostan, F. Chyzak, G. Lecerf, B. Salvy, and É. Schost. Differential equationsfor algebraic functions. In
ISSAC’07 , pages 25–32. ACM Press, 2007.[4] A. Bostan, P. Flajolet, B. Salvy, and É. Schost. Fast computation of specialresultants.
JSC , 41(1):1–29, 2006.[5] A. Bostan and É. Schost. Polynomial evaluation and interpolation on special setsof points.
J. Complexity , 21(4):420–446, 2005.[6] M. Bousquet-Mélou. Rational and algebraic series in combinatorial enumeration.In
International Congress of Mathematicians , pages 789–826. EMS, 2006.[7] M. Bousquet-Mélou. Discrete excursions.
Séminaire Lotharingien deCombinatoire , 57:Art. B57d, 23, 2006/08.[8] M. Bousquet-Mélou and M. Petkovšek. Linear recurrences with constantcoefficients: the multivariate case.
Discrete Math. , 225(1-3):51–75, 2000.[9] M. Bronstein. Formulas for series computations.
AAECC , 2(3):195–206, 1992.[10] P. Bürgisser, M. Clausen, and M. A. Shokrollahi.
Algebraic complexity theory ,volume 315 of
Grundlehren der Mathematischen Wissenschaften . Springer, 1997.[11] D. V. Chudnovsky and G. V. Chudnovsky. On expansion of algebraic functions inpower and Puiseux series, I.
Journal of Complexity , 2(4):271–294, 1986.[12] D. V. Chudnovsky and G. V. Chudnovsky. On expansion of algebraic functions inpower and Puiseux series, II.
Journal of Complexity , 3(1):1–25, 1987.[13] J. Denef and L. Lipshitz. Algebraic power series and diagonals.
Journal ofNumber Theory , 26(1):46–67, 1987.[14] M. Fliess. Sur divers produits de séries formelles.
Bull. Soc. Math. France ,102:181–191, 1974.[15] H. Furstenberg. Algebraic functions over finite fields.
Journal of Algebra ,7(2):271–277, 1967.[16] J. von zur Gathen and J. Gerhard.
Modern Computer Algebra . Cambridge Univ.Press, second edition, 2003.[17] I. M. Gessel. A factorization for formal Laurent series and lattice pathenumeration.
JCTA , 28(3):321–337, 1980.[18] L. J. Hautus and D. A. Klarner. The diagonal of a double power series.
DukeMathematical Journal , 38:229–235, 1971.[19] G. Lecerf. Fast separable factorization and applications.
AAECC , 19(2):135–160,2008.20] V. Y. Pan. Simple multivariate polynomial multiplication.
JSC , 18(3):183–186,1994.[21] V. Y. Pan. New techniques for the computation of linear recurrence coefficients.
Finite Fields and their Applications , 6(1):93–118, 2000.[22] G. Pólya. Sur les séries entières, dont la somme est une fonction algébrique.
L’Enseignement Mathématique , 22:38–47, 1921.[23] M. Rothstein.
Aspects of symbolic integration and simplification of exponentialand primitive functions . PhD thesis, 1976.[24] K. V. Safonov. On conditions for the sum of a power series to be algebraic andrational.
Math. Notes , 41(3–4):185–189, 1987.[25] A. Schönhage. The fundamental theorem of algebra in terms of computationalcomplexity. Technical report, Tübingen, 1982.[26] R. P. Stanley.
Enumerative Combinatorics , volume II. Cambridge Univ. Press,1999.[27] B. M. Trager. Algebraic factoring and rational function integration. SYMSAC’76,pages 219–226. ACM, 1976.[28] B. L. van der Waerden.