Integral D-Finite Functions

∗ † Manuel Kauers Christoph Koutschan RISC / Johannes Kepler University RICAM / Austrian Academy of Sciences 4040 Linz, Austria 4040 Linz, Austria [email protected] [email protected]

ABSTRACT combination of 1, α, α2. An integral basis in this example is {1, α, 1 α2}. We propose a differential analog of the notion of integral 2 closure of algebraic function fields. We present an algorithm The concept of integral closure has been studied in rather for computing the integral closure of the algebra defined general domains [9,6]. To compute an integral basis for an by a linear differential operator. Our algorithm is a direct algebraic number field, special algorithms have been devel- analog of van Hoeij’s algorithm for computing integral bases oped [7,5]. At least two different approaches are known of algebraic function fields. for algebraic function fields, i.e., the case when R = C[x] for some field C, k = C(x), and K = k[y]/hMi for some irreducible polynomial M ∈ k[y]. The algorithm derived by Categories and Subject Descriptors Trager [10] in his thesis is an adaption of an algorithm for I.1.2 [Computing Methodologies]: Symbolic and Alge- number fields, and the algorithm by van Hoeij [12] is based braic Manipulation—Algorithms on the idea of successively canceling lower terms of . General Terms The theory of algebraic functions parallels in many ways the theory of D-finite functions, i.e., the theory of solutions Algorithms of linear differential operators. It is therefore natural to ask what corresponds to the notion of integrality in this latter Keywords theory. In the present paper, we propose such a definition Integral Basis, D-finite Function, Differential Operator and give an algorithm which computes integral bases accord- ing to this definition. Our algorithm and the arguments un- derlying its correctness are remarkably similar to van Hoeij’s 1. INTRODUCTION algorithm for computing integral bases of algebraic function The notion of integrality is a classical concept in the the- fields. ory of algebraic field extensions. If R is an integral domain, k In view of the key role that integral bases play for in- the quotient field of R, and K = k(α) an algebraic extension definite integration (Hermite reduction) of algebraic func- of k of degree d, then an element of K is called integral if its tions [10,3,2], we have hope that results presented below monic minimal polynomial has coefficients in R. While K will help to develop new algorithms for indefinite integration forms a k-vector space of dimension d, the set of all integral of D-finite functions. An example pointing in this direction elements of K forms an R-module, called the integral clo- is given in the end. sure (or normalization) of R in K, and commonly denoted by OK .A k-vector space basis of K which at the same time Acknowledgment. We want to thank the anonymous ref- generates OK as an R-module is called an integral basis. For erees for their detailed and valuable comments. √3 example, when R = Z, k = Q, and K = Q(α) with α = 4, 2 then the canonical vector space basis√ {1, α, α } of K is not 1 2 3 an integral basis, because 2 α = 2 is an integral element 2. INTEGRAL FUNCTIONS, 3 of K (its minimal polynomial is x − 2) but not a Z-linear INTEGRAL CLOSURE, AND ∗Supported by the Austrian Science Fund (FWF): Y464. INTEGRAL BASES † Supported by the Austrian Science Fund (FWF): W1214. Throughout this paper, let C be a computable field of characteristic zero, C¯ an algebraically closed field contain- Permission to make digital or hard copies of all or part of this work for personal or ing C (not necessarily the smallest), and x transcendental classroom use is granted without fee provided that copies are not made or distributed ¯ ¯ for profit or commercial advantage and that copies bear this notice and the full cita- over C. When R is a of C(x), we write R[D] for the tion on the first page. Copyrights for components of this work owned by others than algebra of differential operators with coefficients in R, i.e., r ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or re- the algebra of all (formal) polynomials `0 + `1D + ··· + `rD publish, to post on servers or to redistribute to lists, requires prior specific permission with `0, . . . , `r ∈ R. This algebra is equipped with the natu- and/or a fee. Request permissions from [email protected]. ral addition and the unique noncommutative multiplication ISSAC’15, July 6–9, 2015, Bath, United Kingdom respecting the commutation rules Dc = cD for all c ∈ R ∩ C¯ Copyright is held by the owner/author(s). Publication rights licensed to ACM. and Dx = xD + 1. Typical choices of R will be C[x], C¯[x], ACM 978-1-4503-3435-8/15/07 ...$15.00. ¯ DOI: http://dx.doi.org/10.1145/2755996.2756658 C(x), or C(x) in the following. r ¯ For an operator L = `0 + `1D + ··· + `rD ∈ C[x][D] The function ι(·, j) specifies for each element ν +Z of C/Z ν j with `r 6= 0 we denote by ord(L) = r the order of L. Recall the smallest element ν such that x log(x) should be consid- ν j ν+1 j that such an operator with x - `r admits a fundamental sys- ered integral. If ι(ν+Z, j) = ν, then x log(x) , x log(x) , tem of formal power series solutions, i.e., the vector space ... are integral and xν−1 log(x)j , xν−2 log(x)j ,... are not. V ⊆ C¯[[x]] consisting of all the power series f with L · f = 0 The condition ι(Z, 0) = 0 implies that formal Laurent series has dimension r. When x | `r 6= 0, there is still a fun- are integral if and only if they are in fact formal power series. damental system of generalized series solutions of the form −1/s ν 1/s Example 2. A natural choice for C ⊆ is perhaps ι(z + exp(p(x ))x a(x , log(x)) for some s ∈ N, p ∈ C¯[x], C ν ∈ C¯, a ∈ C¯[[x]][y]. (This notation is not meant to imply Z, 0) = z for all z ∈ C with 0 ≤ <(z) < 1, and ι(z+Z, j) = z that a has a nonzero constant term, so the series in general for all z ∈ C with 0 < <(z) ≤ 1 when j ≥ 1. With this ν ν+i convention, a term xν log(x)j is integral if and only if the does not start at x but at some x where i ∈ N is such i that x is the lowest order term of a.) We restrict our at- corresponding function is bounded√ in a small neighborhood of the origin. For example, 1, x −1, x log(x) all are integral, tention here to the case where p = 0 and s = 1. Moreover, √ we want to assume that ν ∈ C (this can always be achieved while x−1, x −1−1, log(x) are not. Unless otherwise stated, by a suitable choice of C), to ensure that the output of our we shall always assume this choice of ι in the examples given algorithm involves only coefficients in C. Hence we only below. consider operators L which admit a fundamental system in ¯ ¯ S xν C¯[[x]][log x]. It is well known [8] how to determine Proposition 3. Let α ∈ C and let R be the set of all C- ν∈C ν ¯ the first terms of a basis of such solutions for a given oper- linear combinations of series in (x−α) C[[x−α]][log(x−α)], ator L ∈ C¯[x][D]. By a linear change of variables, the same ν ∈ C. Then: techniques can also be used to find the first terms of solu- 1. In every series f ∈ R there are at most finitely many tions in S (x − α)ν C¯[[x − α]][log(x − α)], for any given ν∈C terms (x − α)µ log(x − α)j which are not integral. α ∈ C¯. More precisely, if L belongs only to C[x][D] and α ∈ C¯, then these solutions are actually linear combinations 2. The set R together with the natural addition and mul- S ν of elements of ν∈C (x − α) C(α)[[x − α]][log(x − α)]. For a tiplication forms a , and { f ∈ R | f is integral } field K with C ⊆ K ⊆ C¯ we will use the notation forms a subring of R. [ ν K[[[x − α]]] := (x − α) K[[x − α]][log(x − α)]. Proof. 1. First consider the case when f ∈ (x − α)ν C¯[[x − ν∈C α]][log(x − α)] for some ν ∈ C. Let deg(f) denote the Observe that this is not a ring or a K-vector space. Also highest power of log(x − α) in f. Then the only possible observe that the exponents ν are restricted to the small non-integral terms in f can be (x − α)ν+i log(x − α)j for field C ⊆ K, although the dependence on the choice of C j ∈ {0,..., deg(f)} and i ∈ {0, . . . , ι(ν + Z, j) − ν − 1}. is not reflected by the notation. We hope that the intended These are finitely many. In general, if f is a linear combi- field C will always be clear from the context. nation of some series in (x − α)ν C¯[[x − α]][log(x − α)] with An operator L ∈ C¯[x][D] shall be considered integral if possibly distinct ν ∈ C, the set of all non-integral terms is all the terms in all its series solutions remain above a cer- still a finite union of finite sets of non-integral terms, and tain threshold. In the algebraic case, where series solutions therefore finite. involve at worst only fractional exponents, the stipulation 2. It is clear that R is a ring. To see that the integral of having only nonnegative exponents in all the solutions elements form a subring, let f, g ∈ R be integral. Then the happens to be equivalent to the requirement that the monic series f + g cannot contain any term which is not present minimal polynomial has polynomial coefficients. In the dif- in at least one of the two summands, so all terms of f + g ferential case, solutions involving fractional exponents cause are integral and f + g as a whole is integral. Now consider factors in the leading coefficient of L regardless of whether multiplication: for any term (x − α)µ log(x − α)j in f · g the exponents are positive or negative. Therefore it doesn’t there must be some terms τ in f and σ in g such that στ = seem promising to use the leading coefficient of L for defin- (x − α)µ log(x − α)j , say τ = (x − α)µ1 log(x − α)j1 and ing integrality. Instead, we will consider the exponents of its σ = (x − α)µ2 log(x − α)j2 . Since f and g are integral, we series solutions. These exponents ν may however belong to have µ1 − ι(µ1 + Z, j1) ≥ 0 and µ2 − ι(µ2 + Z, j2) ≥ 0. The a field C which is not necessarily ordered, and there may be assumption on ι in Definition1 implies that ( µ1 + µ2) − logarithmic terms. For our purposes we will use the follow- ι(µ1 + µ2 + Z, j1 + j2) = µ − ι(µ + Z, j) ≥ 0. Hence all ing definition of integrality, depending on a function ι which terms of f ·g are integral, so also the product of two integral can be chosen according to the needs of the user. elements is integral. Definition 1. Let ι: C/ × → C be a function such that Z N Definition 4. Let L ∈ C¯(x)[D] and ι be as in Definition1. 1. ι(ν + Z, j) ∈ ν + Z for every ν ∈ C and j ∈ N, 1. We call L regular if it has a fundamental system in 2. ι(ν1 + Z, j1) + ι(ν2 + Z, j2) − ι(ν1 + ν2 + Z, j1 + j2) ≥ 0 C¯[[[x − α]]] for every α ∈ C¯. for every ν1, ν2 ∈ C and j1, j2 ∈ N, 3. ι( , 0) = 0. 2. L is called (locally) integral at α with respect to ι if Z it admits a fundamental system in C¯[[[x − α]]] whose A series f ∈ C¯[[[x − α]]] is called integral with respect to ι elements all are integral. if for all terms (x−α)µ log(x−α)j occurring with a nonzero coefficient in f we have µ − ι(µ + Z, j) ≥ 0. (For this to 3. L is called (globally) integral with respect to ι if it is make sense the left-hand sides of the occurring inequalities locally integral at α in the sense of part 2 for every have to be interpreted as integers, not as elements of C.) α ∈ C¯. Of course part 2 of this definition is independent of the It is easy to see that OL is a C¯[x]-left module. Note choice of the fundamental system. In fact, L is locally inte- however that OL is in general not a C¯[x][D]-left module, gral at α iff all its series solutions in x − α are integral and because the application of D may turn integral elements ¯ 1/2 1 −1/2 form a C-vector space of dimension ord(L). into non-integral ones (for example, D · x = 2 x when ι( 1 + , 0) = 1 ). Example 5. 1. The operator (2−x)+2(2−2x+x2)D + 2 Z 2 2 4(x − 1)xD ∈ Q[x][D] is locally integral at α = 0, Example 7. 1. The operator L = 1 − D ∈ Q[x][D] has because its two linearly independent solutions for every α ∈ C one power series solution of the form f = 1 + O(x − α). Since f is integral we have 1 ∈ O . 1 − 1 x − 1 x3 − 7 x4 − 53 x5 + O(x6), L 2 24 384 3840 Since (x − α)−1f is not integral for any α, we have in 2 1 3 1 4 13 5 6 x + 6 x + 6 x + 120 x + O(x ) fact that {1} is an integral basis. 1 are both integral. It is also locally integral at α = 1, 2. The operator L = 1 + xD has the solution f = x . It because its two linearly independent solutions is integral for every α 6= 0, but not integral at α = 0. 1/2 6 However, xf = 1 is integral, hence x ∈ OL, and in (x−1) + O((x−1) ), fact {x} is an integral basis. 1 − 1 (x−1) + 1 (x−1)2 − 1 (x−1)3 + O((x−1)4) 2 8 48 3. Whenever L has only power series solutions at every r−1 are integral as well. α ∈ C¯, we clearly have {1,D,...,D } ⊆ OL. How- The operator is also globally integral because at all α ∈ ever, there may still be integral elements that are not C[x]-linear combinations of these. For example, ob- C \{0, 1} it has a fundamental system of formal power serve that for the operator L = (x − 1) + D − xD2, series, and formal power series are always integral. 1 2 3 which has two solutions exp(x) = 1 + x + 2 x + O(x ) 2. The operator 1 + xD ∈ Q[x][D] is not locally integral and (2x + 1) exp(−x) = x2 + O(x3), we have the non- at α = 0, because it has the non-integral solution 1 . It 1 x trivial element x (1 − D) ∈ OL. Note that it is integral is therefore also not globally integral. at all α 6= 0 as well. 2 3 4 2 3. The operator (−1 − 2x) + (x + 2x )D + (x + x )D ∈ 4. It can also happen that 1 ∈ OL but D 6∈ OL. For Q[x][D] is not locally integral at α = 0 although all example, for L = (−1 + 2x) + (1 − 4x)D + 2xD2 we its series solutions are. The reason is that it has only 1 2 3 1/2 have two solutions 1 + x + 2 x + O(x ) and x + one series solution in C[[[x]]] while our definition re- 3/2 1 5/2 3 x + 2 x + O(x ) at α = 0. Since both are integral quires that the number of linearly independent series (and there are two linearly independent power series solutions must match the order of the operator. In solutions for every α 6= 0) we have 1 ∈ OL. However, other words, generalized series solutions involving ex- 1 D 6∈ OL, because the derivative of the second solution ponential terms, like the solution exp( ) in the present 1 −1/2 3 1/2 5 3/2 2 x is x + x + x +O(x ), which is not integral example, are always considered as not integral. 2 2 4 since it involves the term x−1/2. An integral basis in r Let L = `0 +···+`rD ∈ C[x][D] with `r 6= 0 and consider this case turns out to be {1, xD}. the quotient algebra C¯(x)[D]/hLi, where hLi := C¯(x)[D]L 5. We have produced a prototype implementation in Math- denotes the left generated by L in C¯(x)[D]. The al- ematica of the algorithm described below. The code is gebra C¯(x)[D]/hLi is generated as a C¯(x)-vector space by available on the homepage of the first author. For the the basis {1,D,...,Dr−1}. It is also a C¯(x)[D]-left module, operator L = x3D3 + xD − 1, it finds the integral basis and we can interpret its elements as all those “functions” 2 1 ¯ {1, xD, xD − D + x }. A fundamental system of L is which can be reached by letting an operator P ∈ C(x)[D] 2 act on a “generic solution” of L, very much like the elements {x, x log(x), x log(x) }. ¯ of an algebraic extension field C(x)[y]/hMi can be described 6. Let L = 24x3D3 − 134x2D2 + 373xD − 450. This op- as those objects which can be reached by applying a poly- erator has the solutions x3/2, x10/3, and x15/4. Our ¯ nomial P ∈ C(x)[y] to a “generic root” of M. A difference code finds the integral basis in this analogy is that in the algebraic case there are only n o finitely many roots while in the differential case we have a 1 1 3 1 2 7 9 , 2 D − 3 , D − 2 D + 3 . finite dimensional C¯-vector space of solutions. x x 2x x 2x 2x

r In the analogy with algebraic functions, the integral op- Definition 6. Let L = `0 +···+`rD ∈ C[x][D] with `r 6= 0 erators from Definition4 correspond to the monic minimal be a regular operator and let ι be as in Definition1. polynomials with coefficients in a ring, and the integral ele- 1. An element P ∈ A = C¯(x)[D]/hLi is called integral ments of Definition6 correspond to integral elements of an (with respect to ι) if P · f is integral (with respect to ι) algebraic function field. Definitions4 and6 are obviously for every series solution f of L. connected as follows. ¯ Proposition 8. Let L ∈ C[x][D] and L˜ ∈ C¯(x)[D] be regu- 2. The C[x]-left module OL of all integral elements of A ¯ is called the integral closure of C¯[x] in A. lar and assume that there exists P ∈ C(x)[D] such that for every α ∈ C¯ we have 3.A C¯(x)-vector space basis { f | L˜ · f = 0 } = { P · f | L · f = 0 } {B ,...,B } ⊆ C¯(x)[D]/hLi 1 r where f runs over C¯[[[x−α]]] on both sides. Then P +hLi ∈ ¯ is called an integral basis if it also generates OL as C(x)[D]/hLi is integral in the sense of Definition6 if and C¯[x]-left module. only if L˜ is integral in the sense of Definition4. r Lemma 9. Let L = `0 + ··· + `rD ∈ C¯[x][D] with `r 6= 0 6 Construct A ∈ E of the form be a regular operator. Let p , . . . , p ∈ C¯(x) and let p = 0 r−1 1  x − α ∈ C¯[x] be a factor of the common denominator of A = a0B0 + ··· + ad−1Bd−1 + Bd r−1 p p0, . . . , pr−1. If p0 + ··· + pr−1D ∈ OL then p | `r. with a0, . . . , ad−1, p ∈ C[x]. Proof. After performing a change of variables, we may as- 7 We have sume that p = x. By a classical result about linear differen- C¯[x]B0 + ··· + C¯[x]Bd−1 + C¯[x]Bd tial equations (e.g., [8]), x - `r implies that L admits a fun- i r ¯ ¯ ¯ damental system b0, . . . , br−1 in C[[x]] with bi = x + O(x ) ( C[x]B0 + ··· + C[x]Bd−1 + C[x]A ⊆ OL. j i−j for i = 0, . . . , r −1. Then D bi = i(i−1) ··· (i−j +1)x + r−j Replace Bd by A. (This makes E strictly smaller.) O(x ) for i = 0, . . . , r − 1 and j = 0, . . . , r − 1. Let ei e 8 Return {B ,...,B }. be the largest integer such that x i divides the denominator 0 r−1 of pi, let e = max{e0, . . . , er−1}, and let i ∈ {0, . . . , r−1} be In the refined version of the algorithm, we will see that i −e −e+1 some index with ei = e. Then piD bi = i!x + O(x ) the set E is never explicitly constructed. Instead, it suffices j −e+1 and pj D bi = O(x ) for all j 6= i. Hence (p0 + p1D + to be able to solve the following subproblems. First, we need r−1 −e −e+1 ··· + pr−1D ) · bi = i!x + O(x ) is not integral be- to decide whether E = ∅ for recognizing the termination of cause −e − ι(−e + Z, 0) = −e − ι(Z, 0) = −e < 0, and hence the loop in lines 5–7; this is discussed in Section5. Second, r−1 p0 + p1D + ··· + pr−1D 6∈ OL. we need to show the existence of an element A ∈ E of the form required in step 6 whenever E 6= ∅; see Section4. In 3. ALGORITHM OUTLINE Section5 we explain how such an A is constructed. Finally, We shall now discuss how to construct an integral basis the termination of the loop in lines 5–7 is proved in Section6. Except for these issues, the correctness of the algorithm is {B0,...,Br−1} for a given regular operator L ∈ C[x][D]. The key observation is that van Hoeij’s algorithm for com- obvious. puting integral bases for algebraic function fields as well as the arguments justifying its correctness and termination 4. EXISTENCE OF A IF E 6= ∅ carry over almost literally to the present setting. The re- The arguments in this section are almost identical to those mainder of this paper therefore follows closely the corre- in [12]. Nevertheless, for sake of completeness, we formulate sponding sections of van Hoeij’s paper. them here for the differential case. The algorithm computes the basis elements B0,...,Br−1 In the d-th iteration of the algorithm we can assume by in order, at each stage d ∈ {0, . . . , r−1} starting with an ini- induction that B0,...,Bd−1 with ord(Bi) = i for all i form a tial conservative guess for Bd and refining it repeatedly until C¯[x]-left module basis of all integral elements of order up to an operator Bd is found which together with B0,...,Bd−1 d − 1. We consider the case where the current choice of Bd, ¯ generates the C[x]-left module consisting of all the elements together with B0,...,Bd−1, does not generate all integral of OL corresponding to operators of order d or less. Al- elements of order up to d, i.e., E 6= ∅. Recall that ¯ though parts of the calculation take place in the large field C,  E = { A ∈ OL : ord(A) ≤ d }\ C¯[x]B0 + ··· + C¯[x]Bd . it will be shown that the elements Bi in the resulting inte- gral basis always have coefficients in the small field C, in We need to show that there exists an integral element A ∈ E which the coefficients of the input operator L live. 1  which can be written in the form p a0B0 + ··· + adBd with It is not hard to find a suitable B0: For each root α ∈ C¯ a0, . . . , ad, p ∈ C[x] and ad = 1. The idea is as follows: of the leading coefficient `r of L, compute the first terms of ¯ starting from an arbitrary element A ∈ E, we construct, in a basis {b1, . . . , br} of solutions in C[[[x − α]]]. Determine several steps, simpler elements in E until we obtain one with eα the smallest integer eα such that (x − α) bi is integral for the desired properties. every i according to the chosen ι. Then B0 can be set to the eα product of (x − α) over all α. Since eα = eα˜ wheneverα ˜ Lemma 11. If E 6= ∅, then there exists A ∈ E of the form is a conjugate of α, it follows that B0 belongs to C(x). 1  The outline of the algorithm is now given on a conceptual A = a0B0 + ··· + ad−1Bd−1 + adBd (1) level. In Section5 a more detailed description of steps 5–7 x − α will be given. with α ∈ C¯, a0, . . . , ad−1, ad ∈ C¯[x].

Algorithm 10. Proof. Let A ∈ E, say A = a0B0 + ··· + adBd for some r INPUT: A regular operator L = `0 + ··· + `rD ∈ C[x][D] ai ∈ C¯(x). Since A 6∈ C¯[x]B0 + ··· + C¯[x]Bd, at least one with `r 6= 0 ai must be in C¯(x) \ C¯[x]. Let p ∈ C¯[x] be the common OUTPUT: {B0,...,Br−1} ⊆ C(x)[D]/hLi, an integral basis denominator of all the ai, and let α ∈ C¯ be a root of p. ¯ p of C(x)[D]/hLi. Then x−α A has the required form. To see that it belongs p ¯ ¯ 1 Set s to the squarefree part of `r. to E, notice that x−α ∈ C[x] and OL is a C[x]-module, and p ¯ ¯ 2 Set B0 to the zero-order operator described above. that x−α A 6∈ C[x]B0 + ··· + C[x]Bd. 3 For d = 1, . . . , r − 1, do the following: d d Lemma 12. If A ∈ E and P ∈ C¯[x]B0 + ··· + C¯[x]Bd, then 4 Set Bd = s D Bd−1. (Also Bd = s D B0 would work.) Consider A + P ∈ E.  Proof. A ∈ E ⊆ O and P ∈ C¯[x]B + ··· + C¯[x]B ⊆ O E = { A ∈ OL : ord(A) ≤ d }\ C¯[x]B0 + ··· + C¯[x]Bd . L 0 d L implies that A+P ∈ OL. It is also clear that ord(A+P ) ≤ d, 5 While E 6= ∅, do the following: because ord(A) ≤ d and ord(P ) ≤ d. Finally, to show that A+P 6∈ C¯[x]B0 +···+C¯[x]Bd, assume otherwise. Then also To prove this, we have to show that for everyα ˜ ∈ C¯ A = (A + P ) − P ∈ C¯[x]B0 + ··· + C¯[x]Bd in contradiction and every solution ˜b ∈ C(˜α)[[[x − α˜]]] of L we still have to A ∈ E. that A · ˜b is integral. Whenα ˜ is not a root of p, this is clear because 1/p admits an expansion in C[[x − α˜]], and Lemma 13. If E contains an element of the form (1), then multiplication of the integral series B · ˜b by a formal power ¯ it also contains such an element with a0, . . . , ad−1 ∈ C and series preserves integrality by Proposition3. When ˜α = α, a = 1. d write p = (x − α)q for some q ∈ C¯[x] with x − α - q and note ¯ 1 ˜ 1  that 1/q admits an expansion in C[[x − α]] and B · b is Proof. Let A = a0B0 + ··· + adBd ∈ E be of the x−α x−α 1 0 integral, so B · ˜b is integral too. Whenα ˜ is a conjugate form (1). For each i = 0, . . . , d, write ai = (x − α)pi + ai p ¯ 0 ¯ 1 ˜ with pi ∈ C[x] and ai ∈ C. By Lemma 12, A ∈ E implies of α, note that x−α˜ B · b must be integral, because if it were 0 0 1 0 0 0  A ∈ E for A := x−α a0B0 +···+ad−1Bd−1 +adBd . Since not, then for the series b ∈ C(α)[[[x − α]]] obtained from ˜b B0,...,Bd−1 are assumed to generate the submodule of all via the conjugation map that sendsα ˜ to α we would have 0 1 the elements of OL of order at most d − 1, we have ad 6= 0. that B · b is also not integral, in contradiction to our 0 0 x−α Dividing A by ad yields an element of E of the requested choice of a0, . . . , ad. Therefore the same argument as in the form. caseα ˜ = α applies. This completes the proof of the claim. To complete the Lemma 14. If E contains an element of the form (1) with proof of the theorem, note that the claimed degree bounds a0, . . . , ad−1 ∈ C¯ and ad = 1, then it also contains such an on ai can be ensured by Lemma 12. element with a0, . . . , ad−1 ∈ C(α) and ad = 1. 5. CONSTRUCTION OF A IN STEP 6 Proof. Let A ∈ E be of the form (1) with a0, . . . , ad−1 ∈ C¯ and ad = 1. Since C¯ is necessarily a C(α)-vector space, there In the previous section we have demonstrated that in are some C(α)-linearly independent elements e0, . . . , en of step 6 of the algorithm it suffices to search for an integral C¯ such that a0, . . . , ad all belong to V = e0C(α) + ··· + element A of the form enC(α). We may assume e0 = 1. Consider a fundamental 1  A = a0B0 + ··· + ad−1Bd−1 + Bd system b1, . . . , br ∈ C(α)[[[x − α]]] of L. Then each A · bj p has coefficients in V and, since A ∈ E ⊆ OL, only involves where a , . . . , a , p ∈ C[x], p | ` and deg(a ) < deg(p). integral terms. For an element v ∈ V let us write [ei]v 0 d−1 r i Conversely, this means that if no such A exists, the set E is for the coordinate of v with respect to ei. By the linear  empty. independence of the ei over C(α), the series [ei] A · bj = For each irreducible factor p of ` one can set up an ansatz ([ei]A)·bj obtained from A·bj by replacing each coefficient by r for A with undetermined coefficients a , . . . , a . We want its ei-coordinate will be integral. In particular, the operator 0 d−1 to find a , . . . , a such that A · f is integral for all solu- A0 = [e0]A ∈ C(α)[x][D] must belong to E. Because of 0 d−1 tions f of L. Note that we need to enforce integrality only [e0]ad = [e0]1 = 1, it meets all the requirements. for series solutions in x − α where α is a root of p. Choosing Lemma 15. If E contains an element of the form (1) with a fundamental system b1, . . . , br of such solutions, comput- a0, . . . , ad−1 ∈ C(α) and ad = 1, then it also contains such ing the first terms of Bj · bi, plugging them into the ansatz, an element with a0, . . . , ad−1 ∈ C[x] and ad = 1. and equating the coefficients of all non-integral terms to zero yields a linear system for a0, . . . , ad−1. If this system does Proof. For every n > 0 we have x − α | xn − αn in C¯[x], not admit a solution, one knows that no such A with de- and thus also x − α | p(x) − p(α) for p ∈ C¯[x] \ C¯. There- nominator p exists. fore, if we view the ai ∈ C(α) as polynomials in α, then In summary, the loop in lines 5–7 of Algorithm 10 can be replacing α in them by x amounts to adding some polyno- described in more detail as follows. mial multiple of (x − α) to them. This change means for 1 5a Let Q ⊆ C¯ be a set containing exactly one root α ∈ C¯ A = x−α (a0B0 + ··· + ad−1Bd−1 + Bd) that adding a suit- for each irreducible factor p of `r. able element P ∈ C(α)[x]B0 +···+C(α)[x]Bd−1 ⊆ OL turns 5b While Q 6= ∅, do the following: A into an operator of the requested form. By Lemma 12, this new operator also belongs to E. 5c For all α ∈ Q, do the following: 6a Let b1, . . . , br be a fundamental system of L in Theorem 16. If E 6= ∅, then there exists an element A ∈ E C(α)[[[x − α]]]. of the form 6b With variables a0, . . . , ad−1, form the series 1  A = a B + ··· + a B + B  a0B0 + ··· + ad−1Bd−1 + Bd bi p 0 0 d−1 d−1 d for i = 1, . . . , r. with p ∈ C[x] an irreducible factor of `r and a0, . . . , ad−1 ∈ 6c Construct a linear system for a0, . . . , ad−1 by equat- C[x] such that deg(ai) < deg(p) for all i. ing the coefficients of all the non-integral terms in these series to zero. Proof. The assumption E 6= ∅ in combination with Lem- d mas 11, 13, 14, and 15 implies that E contains an element of 7a If the system has a solution (a0, . . . , ad−1) ∈ C(α) : the form (1) with a0, . . . , ad−1 ∈ C[x] and ad = 1. Further- 7b Let p be the minimal polynomial of α over C. more, Lemma9 implies that α is a root of `r. Let p | `r be 7c Replace each ai ∈ C(α) = C[x]/hpi by the corre- 1 the minimal polynomial of α. We claim that A := p B ∈ E sponding polynomial in C[x] of degree less than where B := a0B0 + ··· + ad−1Bd−1 + Bd. deg(p). 1 µ 7d Replace Bd by p (a0B0 + ··· + ad−1Bd−1 + Bd). wrL,α(B0,...,Br−1) is therefore of the form (x − α) with 7e Otherwise µ = ι(µ + Z, 0) + m for some nonnegative integer m. For ¯ 7f discard α from Q. each α ∈ C let mα be the smallest such integer. Now let n = P α∈Q mα where Q is defined as in step 5a. Each time Bd Despite being more detailed than the listing given in Al- is updated in the algorithm (either in step 4 or in step 7d), gorithm 10, these lines are still somewhat conceptual. An none of the mα can increase and exactly one of them strictly actual implementation cannot just “let” bi be some infinite decreases, so also n decreases. More precisely, if for exam- series object, and it does not need to. What we need are only 1  ple Bd is replaced by a0B0 + ··· + ad−1Bd−1 + Bd in the terms of b that give rise to some non-integral terms of p i step 7, then wr (B ,...,B ) is divided by p (recall that a B +···+a B +B )b . These are only finitely many L,α 0 d 0 0 d−1 d−1 d i p is a non-constant polynomial in C[x]). But the m can- by Proposition3. In Section7 we address the question how α not become negative as this would violate the integrality of many terms of bi we need to compute. wrL,α(B0,...,Br−1). Therefore the algorithm must termi- nate. 6. TERMINATION The termination of van Hoeij’s algorithm [12] is estab- 7. BOUNDS lished by the observation that the degree of a certain poly- ∂M  In the algebraic case, van Hoeij [12] gave a-priori bounds nomial, starting with the discriminant Resy M, ∂y , de- creases in each iteration of the main loop. In the case of on the orders to which the bi have to be calculated. His D-finite functions, the role of the discriminant is played by algorithm computes their terms at the very beginning once the Wronskian and a generalized version of it. Recall that and for all in order to avoid their recomputation inside the loop. He also suggested that the terms of Bj · bi for j < d the Wronskian of the functions f1(x), . . . , fr(x) is defined as the should not be recomputed but cached. Nowadays, in an object-oriented programming environ-

f1(x) f2(x) ··· fr(x) ment, the algorithm can be implemented in such a way that 0 0 0 f1(x) f2(x) ··· fr(x) recomputations of series terms are avoided even when no

W = ...... (2) a-priori bound on the truncation order is available, via the . . . . paradigm of lazy series [4, 11]. f (r−1)(x) f (r−1)(x) ··· f (r−1)(x) 1 2 r Nevertheless it is desirable to have a-priori bounds avail- able also in the D-finite case. A rough bound follows imme- Definition 17. Let L ∈ C¯[x][D] be regular and let b1, . . . , br be a fundamental system of L in C¯[[[x−α]]] for some α ∈ C¯. diately from the discussion in Section6: as we have seen, the Wronskian wr B , sDB , . . . , sr−1Dr−1B  gives a For B0,...,Br−1 ∈ C¯(x)[D]/hLi we define the generalized L,α 0 0 0 Wronskian at α, as denominator bound for the elements of the integral basis. More refined bounds are elaborated in the following.

B0 · b1 ··· B0 · br Let α ∈ C¯ be a root of the leading coefficient ` and r . . . {b1, . . . , br} ⊂ C(α)[[[x − α]]] be a fundamental system of L: wrL,α(B0,...,Br−1) := . .. . . ∞ Br−1 · b1 ··· Br−1 · br X  νi+k bi = bi,k log(x − α) (x − α) , bi,0 6= 0, (3) Note that the generalized Wronskian wrL,α(B0,...,Br−1) k=0 belongs to C¯[[[x − α]]] and that the choice of a different where bi,k ∈ C(α)[log(x − α)] are polynomials in log(x − α) fundamental system instead of b1, . . . , br only changes its value by a nonzero multiplicative constant, which will be such that for each i the degrees of bi,0, bi,1,... are bounded irrelevant for our purpose. by some integer di. According to step 5c, we have to consider i each α ∈ Q separately, so for the rest of this section we fix For the special choice Bi = D , the generalized Wron- r−1 such an α. skian wrL,α(1,D,...,D ) reduces to the Wronskian (2) In step 6a we want to replace b1, . . . , br by truncated series with fi = bi. It is well-known and easy to check that the t1, . . . , tr of the form classical Wronskian (2) of b1, . . . , br satisfies the first-order equation `rDW +`r−1W = 0 and hence is hyperexponential. Ni Since the generalized Wronskian can be obtained from the X  νi+k ti = bi,k log(x − α) (x − α) with Ni ∈ N. (4) usual Wronskian by elementary row operations over C(x), k=0 it is clear that also the generalized Wronskian is hyperexpo- nential. The bounds Ni must be chosen such that this replacement does not change the result of the algorithm. The only criti- Theorem 18. Algorithm 10 terminates. cal step is when b1, . . . , br are used to test the integrality of certain elements from the algebra C(x)[D]/hLi, which are Proof. First observe that during the whole execution of the not known in advance. Theorem 20 below gives a sufficient algorithm, B0,...,Br−1 ∈ C(x)[D]/hLi are integral, i.e., condition that allows us to use ti instead of bi in the inte- B0 · f, . . . , Br−1 · f are integral for any series solution f grality test, by asserting that its answer does not change, of L according to Definition6. (Actually, the Bd’s are whatever element of C(x)[D]/hLi we consider. For brevity, constructed one after the other, but they can be initialized let R denote the ring C(α)[[x − α]][log(x − α)] in the subse- d d with Bd = s D B0.) This means that, at any time and for quent reasoning. any α ∈ C¯, the generalized Wronskian wrL,α(B0,...,Br−1) is integral, as it is the sum of products of integral series Lemma 19. Let {b1, . . . , br} ⊂ C(α)[[[x − α]]] be a fun- (see Proposition3). Since it is hyperexponential, it follows damental system of the form (3) with νi as above, and let j that it has no logarithmic terms. Every nonzero term of Wb = (D · bi)1≤i≤r,0≤j

ν1+···+νr −r(r−1)/2 it follows that B · t is non-integral as well. To see this, det(Wb) ∈ (x − α) R. let n be the largest integer such that a term of the form (x−α)ι(µ+Z,k)−n log(x−α)k appears in B ·b for some µ ∈ C Note that det(Wb) 6= 0 because it is precisely the Wronskian and k ∈ . Let i be an index such that a term of the given of b1, . . . , br. It follows that a unique m ≥ 0 with the desired N property exists. form appears in B · bi with nonzero coefficient. This term cannot be canceled in Theorem 20. Let L ∈ C(x)[D] be an operator of order r r X −1 B · t = B · b − ZW  B · b  and {b1, . . . , br} ⊂ C(α)[[[x − α]]] be a fundamental system i i b i,j j of L with νi and di as above. Moreover, let m ∈ N be as in j=1 Lemma 19 and let N ,...,N ∈ be given by 1 r N because all terms of the series (ZW −1 are of the form   b i,j ι(νi−νj + ,k)+` k Ni = m + max ι(νi − νj + Z, k) − (νi − νj ) . (x − α) Z log(x − α) with ` ≥ 1 by our choice 1≤j≤r of N . So also B · t is not integral. 0≤k

If ti is the truncation (4) of bi at order Ni, for 1 ≤ i ≤ r, then for all B ∈ C(x)[D]/hLi we have the equivalence: 8. COMPARISON WITH THE ALGEBRAIC CASE ∀i: B · bi is integral ⇐⇒ ∀i: B · ti is integral. (5) We have shown that the underlying ideas of van Hoeij’s algorithm for computing integral bases of algebraic function Proof. We introduce the matrix W = (Dj · b ) b i 1≤i≤r,0≤j

−1 −1 Since C(x)[y]/hMi is also a C(x)-vector space of dimen- WtWb = Idr − ZWb . (7) sion d, it is clear that any d + 1 elements must be C(x)- The proof is split into two parts, according to the two linearly dependent. This implies the existence of an opera- directions of the equivalence (5). tor L ∈ C(x)[D] of order at most d with L · y = 0. Usually Part 1: If we assume that B·b is integral, then (6) exhibits there is no such operator of lower order, which means that −1 y, D · y, . . . , Dd−1 · y are C(x)-linearly independent and thus that the integrality of WtWb is a sufficient condition to conclude that also B · t is integral, using Proposition3. By a basis of C(x)[y]/hMi. In this case, a vector space basis −1 {B1,...,Bd} ⊆ (x)[y]/hLi is an integral basis in the sense (7) it suffices to show that ZWb is integral. First of all we C −1 r×r of Definition6 if and only if {B1·y, . . . , Bd·y} ⊆ (x)[y]/hMi have to argue that Wb ∈ C(α)[[[x−α]]] since otherwise C Definition1 would not be applicable. In Section6 we have is an integral basis of the algebraic function field in the clas- sical sense. remarked that the Wronskian det(Wb) is hyperexponential. In particular, it involves no logarithmic terms and therefore When y ∈ C(x)[y]/hMi is annihilated by an operator L is invertible in C(α)[[[x − α]]]. Using Cramer’s rule we find of order less than d, we can compute the minimal-order op- 0 d−1 that erators L0,...,Ld−1 which annihilate y , . . . , y , respec- tively, and take L = lclm(L0,...,Ld−1). Then the C(x)- [j,i] det W vector space generated by all solutions of L is the whole W −1 = (−1)i+j b ∈ (x − α)i−νj −m−1R, b i,j det Wb field C(x)[y]/hMi, and if {B1,...,Bn} is an integral basis for L, then {B ·yj : i = 1, . . . , n, j = 0, . . . , d−1} generates [j,i] i where Wb is the matrix obtained by deleting row j and the C[x]-module of all integral elements of C(x)[y]/hMi. −1 column i from Wb. So the entries of Wb are series in As a less brutal approach, we can simply replace y by [j,i] C(α)[[[x − α]]]. The fact that det Wb satisfies a differ- some other generator of the field. In practice, most field ential equation of order less than or equal to r implies that generators will have an annihilating operator of order d, but the highest power of log(x−α) that can appear in the entries none of smaller order. Example 21. An integral basis for the field Q(x)[y]/hMi constraint 3 2  1 2 with M = y − x is 1, y, y . The lowest-order differ-  ω 0  ω 0 x a ω + a ω ≡ b uvm 0 + b uvm 1 mod v ential operator annihilating y is L = 3xD − 2, which is not 0 0 1 1 0 vm−1 1 vm−1 useful because its order is less than the degree of M. For the derivatives of ω and ω we have Instead, let us try Z = 1 + y + y2 as generator. We have 0 1 (x)[y]/hMi = (x)[Z]/hNi, where N = Z3 − 3Z2 − 3(x2 − 1 1 − 2x Q Q Dω0 = ω0 − ω1, Dω1 = ω1, 1)Z − x4 + 2x2 − 1 is the minimal polynomial of Z. Given 2x 2x N instead of M as input, van Hoeij’s algorithm finds the so that the previous constraint can be rewritten to following integral basis for (x)[Z]/hNi: Q 1 a0ω0 + a1ω1 ≡ − 2 b0u 3ω0 + ω1) − 2b1uω1 mod v.  Z2 (x2 + 2)Z 1  1,Z, − − . (9) Plugging in a0, a1 and u and comparing coefficients of ωi x(x − 1)(x + 1) x(x − 1)(x + 1) x leads to the linear system 2 3 The lowest order annihilating operator of Z is L = 9x D + 41x − 11 2 − 6x 2 − 2x b  2 = 0 mod v 9xD − D. It has the right order and our Mathematica im- 11x − 1 0 4 − 8x b  2 1 1 plementation returns the integral basis 1, xD, xD + 3 D . 1 5 We can express its derivatives as polynomials in Z, using which has the solution b0 = 2 (4x+11), b1 = 2 (2x−1). Next we find that −2Z2 + 2(2x2 + 1)Z D · Z = ,  b ω + b ω 0 c ω + c ω 3x(x − 1)(x + 1) f − 0 0 1 1 = 0 0 1 1 vm−1 uvm−1 and obtain the following integral basis for (x)[Z]/hNi: Q for c0 = 0, c1 = 0. Consequently, we have found that  2 2 2 2 2  −2Z + 2(2x + 1)Z 8(−Z + (x + 2)Z + x − 1) Z (11 + 4x)ω + 5(2x − 1)ω 5 2x + 3 Z, , . f = 0 1 = y0 − y. 3(x − 1)(x + 1) 9x(x − 1)(x + 1) 8(1 − x)2x2 x − 1 (x − 1)x Applying a change of basis with the unimodular matrix The same answer could have been found using an algorithm 8 −12 9x of Abramov and van Hoeij [1], using a different approach. 1 8 0 0  8 0 0 −9 9. REFERENCES [1] Sergei A. Abramov and Mark van Hoeij. Integration of gives the integral basis (9) computed by Maple. solutions of linear functional equations. Integral transforms and Special Functions, 9:3–12, 1999. One of the features of integral bases for algebraic function [2] Manuel Bronstein. The lazy Hermite reduction. fields is that they allow an extension of the classical Hermite Technical Report 3562, INRIA, 1998. reduction for integration of rational functions to the case of algebraic functions. This was observed by Trager [10]. [3] Manuel Bronstein. Symbolic integration tutorial. In order to make this work, Trager requires that both the ISSAC’98, 1998. integral basis as well as the integrand should be “normal at [4] William H. Burge and Stephen M. Watt. Infinite infinity”. This corresponds to the condition in the rational structures in scratchpad II. In Proceedings of the case that the rational function to be integrated must not European Conference on Computer Algebra, have a polynomial part. Trager shows that normality of EUROCAL ’87, pages 138–148, London, UK, 1989. the integrand can always be achieved by applying a suitable [5] Henri Cohen. A Course in Computational Algebraic change of variables, and he gives an algorithm that turns an . Springer, 1993. arbitrary integral basis into one that is normal at infinity. [6] Theo de Jong. An algorithm for computing the After that, the Hermite reduction process looks very similar integral closure. Journal of Symbolic Computation, to the rational case. We give here an example for a non- 26(3):273–277, 1998. algebraic D-finite function. [7] David J. Ford. On the Computation of the Maximal Order in a . PhD thesis, Ohio State 2 2 Example 22. Let L = (2x+1)√ −(4x +1)D+2(2x−1)xD ; University, 1978. its solutions are exp(x) and x, but we will not use this in- [8] Edward L. Ince. Ordinary Differential Equations. formation. Let us just write y for a solution of L. An inte- Dover, 1926. gral basis of O is given by {1, 1 (2xD − 1)}. Let ω := y L 2x−1 0 [9] Irena Swanson and Craig Huneke. Integral closure of 1 and ω1 := 2x−1 (2xD − 1) · y and consider the function ideals, rings, and modules, volume 336 of London a ω + a ω Mathematical Society Lecture Note Series. Cambridge f = 0 0 1 1 uvm University Press, 2006. [10] Barry M. Trager. Integration of algebraic functions. 2 3 2 where a0 = 4x + 37x − 11, a1 = −28x + 40x − x − 1, PhD thesis, Massachusetts Institute of Technology, u = 4, v = (x − 1)x, m = 2. 1984. Hermite reduction consists in finding b0, b1, c0, c1 ∈ Q[x] [11] Joris van der Hoeven. Relax, but don’t be too lazy. with Journal of Symbolic Computation, 34(6):479–542, 0 a0ω0 + a1ω1  b0ω0 + b1ω1  c0ω0 + c1ω1 2002. = + . uvm vm−1 uvm−1 [12] Mark van Hoeij. An algorithm for computing an After working out the differentiation, multiplying by uvm, integral basis in an algebraic function field. Journal of and taking the whole equation mod v we are left with the Symbolic Computation, 18(4):353–363, 1994.