* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Hypergeometric Solutions of Linear Recurrences with Polynomial
Linear algebra wikipedia , lookup
Cubic function wikipedia , lookup
Quadratic equation wikipedia , lookup
Field (mathematics) wikipedia , lookup
Basis (linear algebra) wikipedia , lookup
History of algebra wikipedia , lookup
Gröbner basis wikipedia , lookup
Horner's method wikipedia , lookup
Quartic function wikipedia , lookup
System of linear equations wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
Polynomial ring wikipedia , lookup
Polynomial greatest common divisor wikipedia , lookup
Eisenstein's criterion wikipedia , lookup
Factorization wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
J. Symbolic Computation (1992) 14, 243-264 Hypergeometric Solutions of Linear Recurrences with Polynomial Coefficients MARKO PETKOVSEK Department of Mathematics, University of Ljubljana, Slovenia We describe algorithm Hyper which can be used to find all hypergeometric solutions of linear recurrences with polynomial coefficients . 1 . Introduction Let K be a field of characteristic zero . We assume that K is computable, meaning that the elements of K can be finitely represented and that there exist algorithms for carrying out the field operations . Let K N denote the ring of all sequences over K, with addition and multiplication defined term-wise . Following Stanley (1980) we identify two sequences if they agree from some point on . Formally, we are working in the quotient ring SK := K N /J where J is the ideal of sequences with at most finitely many non-zero terms . Hence all equalities of the form L(n) = R(n) are to be interpreted as valid for all large enough n . Accordingly, a sequence is considered non-zero if and only if it has infinitely many non-zero terms . A sequence a E SK will be called polynomial (respectively rational) a polynomial f (x) E K[x] (respectively a rational function f (x) E K(x)) such that a(n) = f (n) for all large enough n E IN . A non-zero sequence a E SK is a hypergeometric term (or simply hypergeometric) over K if there is a rational function r(x) E K(x) such that a(n + 1) = r(n)a(n) for all large enough n E IN . Two hypergeometric terms are similar if their ratio is rational . We will denote the sets of polynomial, rational, and hypergeometric sequences over K by PK , RK, and 1(K, respectively. By L(HK) we will denote the linear subspace spanned by ?{K in the K-linear space SK. DEFINITION 1 .1 . over K if there is Since two polynomials which agree on infinitely many arguments are identical, the polynomial defining a polynomial sequence is unique, and we will not distinguish ber tween the two . The same goes for rational functions and sequences . In fact, PK is a ring isomorphic to K[x] and RK is a field isomorphic to K(x) . It is easy to see that ?{K is a multiplicative group . For any field F, let F* denote its multiplicative group . Then f : 7{K RK * defined by f : h(n) ' h(n+ 1)/h(n) is an epimorphism which induces an 0747-7171/92/080243+22 $08 .00/0 © 1992 Academic Press Limited 244 M . Petkovgek isomorphism between ?1K/K* and RK Obviously, similarity is a congruence relation in 7{K induced by the normal subgroup R K * . EXAMPLE 1 .1 . Let a(n) = 0, b(n) = 1, c(n) = n 2 -1, d(n) = 2", e(n) = 2n-1, f(n) = n! . Then sequences a, b, c are polynomial over K, sequences b, c, d, f are hypergeometric over K, and sequences a, e belong to G(NK) but are not hypergeometric over K . Let S denote the shift operator in the ring K'N, defined by Sa(n) = a(n + 1) . There is a unique endomorphism E of SK such that E(a + J) = Sa + J, for every a E K N . It is easy to see that E is in fact an automorphism of SK, and thus (SK, E) is an inversive difference ring, according to the definition in Cohn (1965) . Let d be a positive integer and ro(n), r i (n), . . ., rd(n) sequences from RK such that rd # 0 . Then L :_ Ed o r,E' is a linear recurrence operator with rational coef ficients over K . We will be interested in algorithms for finding hypergeometric solutions of equations of the form La = f where L is as above and f E SK . Clearly, for every linear recurrence operator with rational coefficients there exists a linear recurrence operator with polynomial coefficients having the same kernel . Furthermore, every linear recurrence operator L can be written in the form L = L o Em where Lo is an operator with non-zero trailing coefficient . Thus the affine solution space L - ' f equals E - ' Lo i f, for any f E SK . Therefore we will from now on assume that L is of the form d L :_ d pi E' (1 .1) i-o where po(n), pi(n), . . ., pd(n) are sequences from PK such that Po, Pd # 0 . The order of L as defined in (1 .1) is d, and its degree is m := maxo < i<d degpi(n) . With L as in (1 .1), the equation La = 0 (1 .2) is a homogeneous linear recurrence with polynomial coef ficients for the unknown sequence a E SK . We will also consider the corresponding non-homogeneous recurrence La = f (1 .3) where L is as in (1 .1) and f is a given sequence from SK . The order and degree of recurrences (1 .2) and (1 .3) are defined to be those of L . Abramov (1989a) gives an algorithm for finding all polynomial solutions of (1 .3) . Abramov (1989b) does the same for rational solutions . In this paper we present algorithm Hyper which can be used to find all hypergeometric solutions of (1 .3) . To give some motivation, we describe first an application of algorithm Hyper to definite hypergeometric summation . The problem of indefinite hypergeometric summation was solved by Gosper (1978) who discovered an algorithm for finding hypergeometric solutions of the non-homogeneous first-order recurrence a(n + 1) - a(n) = h(n) where h(n) is a hypergeometric term . In other words, Gosper's algorithm decides whether the indefinite sum of a hypergeometric term is hypergeometric (apart from an additive constant) . Hypergeometric Solutions of Recurrences 245 One can ask the same question about definite sums of the form a(n) = 1: F(n, k) (1 .4) k where summation ranges over all integers, and the two quotients F(n + 1, k)/F(n, k) and F(n, k + 1)/F(n, k) are rational functions of n and k. Using Bernstein's theory of holonomic functions, Zeilberger (1990) proved that every a of the form (1 .4) satisfies a recurrence of the form (1 .2) . Zeilberger (1991) gives an algorithm which constructs such a recurrence . Wilf and Zeilberger (1992) generalize this to multiple and/or q-hypergeometric sums . Since algorithm Hyper can be used to obtain a basis for the space of solutions of (1 .2) belonging to C(HK), the combination of Zeilberger's algorithm with Hyper, followed by solving a system of linear algebraic equations gives an algorithm for deciding whether (1 .4) is a linear combination of hypergeometric terms . The overview of the paper is as follows . In order to make the description of Hyper selfcontained, we start in Section 2 by deriving algorithm Poly which finds a basis for the space of polynomial solutions of (1 .2) . A similar algorithm (but expecting the recurrence to be given in terms of the difference operator A) has been developed independently by Abramov (1989a) . Section 3 describes a normal form for rational functions which plays an important role both in Gosper's algorithm and in algorithm Hyper . In Section 4 we develop algorithm Hyper which decides existence of hypergeometric solutions of (1 .2) over some extension of the coefficient field of (1 .2) . The algorithm works by constructing a finite set of auxiliary recurrences of order d such that (1 .2) has a hypergeometric solution if and only if some auxiliary recurrence has a non-zero polynomial solution . Algorithm Poly is then used on each auxiliary recurrence . In Section 5 we show how to solve recurrences (1 .2) and (1 .3) over .C(?iK) . Abramov (1989b) presents an algorithm for finding rational solutions of (1 .3) . With a simple modification, this algorithm can be used to find hypergeometric solutions of (1 .3) when f # 0 . Finally, we discuss the necessity to compute in algebraic extensions of the coefficient field of the recurrence in order to find all its hypergeometric solutions . 2 . Polynomial solutions In this section we assume that there exists an algorithm for finding integer :roots of polynomials over K . Such a field is called adequate in Abramov (1989a, b) . We follow the convention that 00 = 1 and that (k) = 0 when k < 0 or 0 < n < k . The question of existence of non-zero polynomial solutions of (1 .2) reduces to the problem of finding an upper bound N for the possible degrees of such solutions . Once we have N, we can substitute in the recurrence a generic polynomial of degree N for a(n) and solve the resulting system of linear algebraic equations . The following example shows that it is not possible to bound the degree of polynomial solutions of (1 .2) in terms of its order and degree . EXAMPLE 2 .1 . For any fixed non-negative integer k, the solutions of na(n + 1) - (n + k)a(n) = 0 are constant multiples of ( n+ k -1 ) which is a polynomial in n of degree k, while the 246 M. Petkoviek recurrence is of order and degree 1 . Similar examples can be constructed for higher-order recurrences . We consider first the second-order recurrence p(n)a(n + 2) + q(n)a(n + 1) + r(n)a(n) = 0 (2 .1) where p, q, r are polynomials . Assume that a(n) is a non-zero polynomial solution of (2 .1), of unknown degree N . Let m be the degree of (2 .1) and uonm + ulnen-1 + u2n m-2 + O(n m-3 ), P(n) = v1 n'"-1 + v2n m-2 + m-3 O(n ), q(n) = vonm + r ( n ) = won ' + wln m-1 + w2nm-2 + O(n m-3 ) . By definition of m, at least one of uo, vo, wo is non-zero . Further, let a(n) = aNn N + aN-1nN-1 + aN-2n N-2 + 0(n N-3 ) with aN # 0 . Then, by the Binomial Theorem, a(n + 1) = aN (n N + NnN-1 + (N2 I n N-2 '/ / + aN-1 (nN-1 + (N - 1)n N-2 ) + a N-2n N-2 + 0(n N-3 ) and a(n + 2) = aN (n N + 2NnN-1 + 4 N-2) (2) n + aN-1 (n N-1 + 2(N - 1)n N-2 ) + aN-2n N-2 + O(n N-3 ) . We substitute these expansions into (2 .1) and equate coefficients of like powers of n . The coefficient of nN+m yields, after cancelling aN, uo + vo + wo = 0 . (2 .2) If this condition is not fulfilled then (2 .1) has no non-zero polynomial solution . Otherwise we proceed with the coefficient of nN+m -1 , use (2 .2), cancel aN, and find that (2uo + vo)N + u1 + v1 + w1 = 0. (2 .3) If 2uo + vo # 0 then (2 .3) determines a single possible value for N, and we are done . On the other hand, if 2uo + vo = 0 then we must also have U 1 + v1 + w1 = 0 (2 .5) or else (2 .1) has no non-zero polynomial solution . If both (2 .4) and (2 .5) hold we continue with the coefficient of nN+m -2 . Here we find after using (2 .2), (2 .4), and (2 .5), and after cancelling aN , that uo N 2 +(2u 1 -uo+v1)N+u2+v2+w2=0 . (2 .6) Now u o 96 0 or else it would follow from (2 .2) and (2 .4) that u o = vo = wo = 0, contrary to our assumption . Therefore (2 .6) determines at most two possible values for N . Hypergeometric Solutions of Recurrences 247 Next we summarize this algorithm and, after giving an example, generalize it to recurrences of arbitrary order . Algorithm Poly for d = 2 INPUT : Polynomials m p(n) = m 1: u,j n m-i , i=o m 4(n) _ > vj n i=o m-2 , r(n) _ E wj n i=o with coefficients in K such that at least one of uo, v o , wo is non-zero . OUTPUT : A basis B for the space of polynomial solutions over K of (2 .1) . [1] If uo + vo + wo # O then D := 0 else if uo # wo then D := {N ; (uo - wo)N + ul + vi + wi = 0} fl IN else if u l + vi + wi :~_ 0 then V := 0 else D := {N ; uoN 2 + ( ul - uo - wi)N +U2 +V2 +W2 = 0} fl IN . [2] If D else = 0 then . B := 0 k := max D ; find a basis B for the space of polynomial solutions of (2 .1) over at most k, using the method of undetermined coefficients . [3] Return B EXAMPLE 2 .2 . K of degree and stop . The recurrence n(n + 1)a(n + 2) - 2n(n + 100)a(n + 1) + (n + 99)(n + 100)a(n) = 0 has m = 2, uo = wo = ul = 1, vo = -2, vl = -200, wl = 199, u2 = v2 = 0, and w2 = 9900 . Therefore uo + vo + wo = uo - wo = ul + vl + wl = 0, and the possible degrees are among the roots of N2 - 199N + 9900 = 0, which are N = 99 and N = 100 . In fact, there exist polynomial solutions both of degree 99 and of degree 100, e.g ., (n+") and (n+98 99 Algorithm Poly for arbitrary d INPUT : Polynomials m pi(n) = yci,jn m-j , i=o for i = 0, 1, . . ., d, with coefficients in K such that at least one of ci,o, We assume that ci,1 = 0 when j < 0 or j > m . OUTPUT : A basis B 0 < i < d, (2 .7) is non-zero . for the space of polynomial solutions over K of (1 .2). 248 M. PetkovAek [1] Initialize s :_ -1 . [2] Repeat increments by 1 ; for j = 0, 1, . . . , s compute d (2 .8) bps) i-0 until 3j E {0,1, . . ., s} such that b(' ) # 0 . [3] Let V be the set of non-negative integer roots N of the polynomial D(N) :_ 'E (Nj I b~'~ . / [4] If D = 0 then B else k := max D ; find a basis B for the space of polynomial solutions of (1 .2) over K of degree at most k, using the method of undetermined coefficients . [5] Return B and stop . We will call D(N) the degree polynomial of (1 .2) . To prove correctness of algorithm Poly we must show that the loop in step [2] eventually terminates, that the set V is finite, and that the degree of any non-zero polynomial solution of recurrence (1 .2) belongs to V . These facts are established by the following three lemmas. LEMMA 2 .1 . In algorithm Poly, s < d at all times . Assume that at some point s = so . Then b~' ) = 0 for 0 _< j < s < s o . In particular, b, 0 for 0 < s < so . If so > d this implies that PROOF . d b(')=Ei'ci,o=0, i_o for 0<s<d . Since det (i 3 )d,_ o = V(0, 1, . . . , d) is a Vandermonde determinant it follows that ci,o = 0 for i = 0, 1, . . . , d . But these are the coefficients of nm in pi (n), and by our assumption at least one of them is non-zero, a contradiction . O LEMMA 2 .2 . In algorithm Poly, V is a finite set . By Lemma 2 .1, the loop in step [2] terminates after at most d + 1 iterations. When this happens at least one of the bj(' ) is non-zero, hence the degree polynomial (2 .9) does not vanish identically and has a finite set of roots . It follows that V is finite . 0 PROOF . Hypergeometric Solutions of Recurrences 249 LEMMA 2 .3 . Let so be the final value of s in algorithm Poly . Let No a(n) _ ak where nk, aNo # 0 (2 .10) k=0 be a polynomial solution of recurrence (1 .2) . Then b' ) = 0 (2 .11) j=o(No)ao J where b~' ) is as in (2 .8). PROOF . By the Binomial Theorem, No a(n + i) _ k ak k=0 i k- 'n' . E C1) 1=0 (2 .12) We adopt the convention that ci,j = 0 and ak = 0 whenever any of i, j, k are out of bounds indicated in (2 .7) and (2 .10) . By substituting (2 .7) and (2 .12) into (1 .1) we obtain (k) t k-I m+I-j n La = > ci,J ak I i,j,k,I e each summation index Lawher ranges over all integers and the order of summation can be chosen arbitrarily. Replacing j by r = m + I - j yields = ~ n r E ak E r k I (k) 1 ~ i k-1 ci, .n+I-r . The coefficient of nr can be written as 3) (2 .13) ~ak>2 k I () b~ where j = k-I and s = k+m-r . By definition of so, we have b(' ) = 0 for 0 _< i < s < so . By our convention, this also holds when j > s since then ci,,_j = 0 . If j < 0 the binomial coefficient in (2 .13) is zero ; if j > 0 and s < so then b(') = 0 . So the inner sum in (2 .13) vanishes whenever s < so, i.e ., when k < so - m + r . On the other hand, ak == 0 for k > No, hence the terms of the outer sum in (2 .13) are zero unless so - m + r < k < No . As a consequence, (2 .13) is zero unless r < m + No - so, so degLa<m+No-so . Now replace r by t = so - m + r . Then (2 .13) can be rewritten as N N ()b ..7t+3o E o ak E k=t I 1 ) .k( If La = 0 then (2 .14) is zero for all values oft . In particular, for t = No we have ( 'o I )b(No-1 '= o) aNo 0. 1 After cancelling aN0 and replacing I by j = No - l, this turns into (2 .11) . 13 (2 .14) 250 M. Petkovtek REMARK 2.1 . To implement Poly efficiently, we note that equating (2.14) to zero for t = No, No - 1, . . . , 0 gives a system of linear equations for the unknown coefficients aN„ acro _ 1 , . . . , ao which is already in triangular form . 2.2 . We can modify Poly so that it will find a basis for the affine space of polynomial solutions of the non-homogeneous recurrence (1 .3) . Let f = f (n) = F-;_ o fin' in (1 .3) where r = deg f(n) . In the proof of Lemma 2 .3 we saw that either deg La = m + No - so, or deg La < m + No - so and (2 .11) holds. Hence either No = r + so - m, or No is a non-negative integer root of the degree polynomial (2 .9). Choosing the largest of these values as No, we find the unknown coefficients ai from REMARK N° ak E k=t k f (k-t+so) bk_I Ci = .ft+m-80 , for t=No,No-1, . . .,0, which is a triangular system of linear equations . 3. A normal form for rational functions The following lemma appears in Gosper (1978), though without mentioning properties (AC) and (BC) . 3 .1 . Let K be a field of characteristic zero and r(x) a non-zero rational function over K . Then there exists a non-zero constant Z E K and monic polynomials A(x), B(x), and C(x) over K such that ) - A(x) C(x + 1) r(x) Z (3 .1) B(x) C(x) LEMMA where (i) gcd(A(x), B(x + k)) = 1 for every non-negative integer k, (ii) gcd(B(x), C(x)) = 1, (iii) gcd(B(x), C(x + 1)) = 1 . (AB) (AC) (BC) Let r(x) = p(x)/q(x) where p, q are polynomials over K with leading coefficients a and /3, respectively . Let Z := a//3. Then r(x) # 0 implies p(x) # 0 which implies a # 0 which in turn implies Z ~ 0 . Denote by R(k) the resultant of p(x) and q(x + k) with respect to x . Let N be the largest non-negative integer root of R(k), or -1 if there is none . Construct polynomials pi(x), qi(x) for -1 < i < N inductively by PROOF . p-i(x) = P(a )) q-,(x) = q ) and for 0 < i < N, si(x) PA (x) qi(x) gcd(pi-1(x), qi-1(x + i)) Pi-i(x) si(x) qi-1(x) si(x - i) Hypergeometric Solutions of Recurrences 251 Let Then Z A(x) C(x + 1) B(z) C(x) - a pN(x) N $ s ;(x - k + 1) I3 qN(x) i=1 1 si(x - k) I(X) _ ~ x i-1 Sixx ) ~ ( `(x)t ) i( ) HN4 81( x) l1 N ap-1(x) = P(x) = r(x) . Qq-1(x) q(x) Polynomials A(x), B(x), C(x) are monic by construction . Now we verify properties (AB), (AC), and (BC) . By definition of pk, qk, and 8k, gcd(pk(x),gk(x + k)) = gcd(Pk-1(x) qk-1(x +k) ) = 1 sk(x) sk(x) for all k such that 0 < k < N . Let 0 < k < i, j < N . Then p;, pi ~ Pk and qi, qi qk, therefore gcd(p;(x),gi(x + k)) gcd(pk(x),gk(x + k)) . Hence gcd(Pi(x),gi(x + k)) = 1 . (3 .2) (AB) : Setting i = j = N in (3 .2), we see that A(x) and B(x + k) are relatively prime for all k such that 0 < k < N . By definition of N this implies that they are relatively prime for all k > 0 . (AC) : If A(x) and C(x) have a common factor then so do PN(x) and s i (x -- k), for some i and k such that 1 < k < i < N . Then pN(x) and qi_1(x + i - k) have a common factor, too, by definition of qj . But as 0 < i - k < i - 1 < N, this contradicts (3 .2) . (BC) : If B(x) and C(x + 1) have a common factor then so do qN(x) and si(x - k), for some i and k such that 0 < k < i - 1 < N - 1 . Then qN(x) and pi_i(x - k) have a common factor, too, by definition of pi . Hence qN(x + k) and pi_1(x) have a common factor . But as 0 < k < i - 1 < N, this contradicts (3 .2) . 0 Note that the proof of Lemma 3 .1 actually gives an algorithm to compute (3 .1) . This algorithm utilizes gcd and resultant computations in K[x] and K[x, k], respectively . LEMMA 3 .2 . Let K be a field of characteristic zero . Let a(x), b(x), and c(x) be polynomials over K such that gcd(a(x), c(x)) = gcd(b(x), c(x + 1)) = 1 . If r(x) = a(x) c(x + 1) - b(x)c(x) and C(x) is related to r(x) as in Lemma 3 .1, then c(x) divides C(x) . (3 .3) 252 PROOF . M . Petkoviek Use (3 .1) to rewrite (3 .3) as ZA(x)b(x)c(x)C(x + 1) = a(x)B(x)C(x)c(x + 1) . (3 .4) Let g(x) d(x) := gcd(c(x), C(x)) , (3 .5) := c(x)/g(x), (3 .6) C(x)/g(x) . (3 .7) D(x) Then gcd(d(x), D(x)) = gcd(a(x), d(x)) = gcd(d(x), d(x+l)) = 1 . Cancelling g(x)g(x+l) from (3 .4) gives ZA(x)b(x)d(x)D(x + 1) = a(x)B(x)D(x)d(x + 1) . It follows that d(x) d(x + 1) I B(x)d(x + 1), I A(x)d(x) . Using this repeatedly we obtain d(x) d(x) I ~ B(x)B(x + 1) . B(x + k -1)d(x + k), A(x - 1)A(x - 2) . . .A(x - k)d(x - k), for all k E IN . Since F has characteristic zero gcd(d(x), d(x+k)) = gcd(d(x), d(x-k)) = 1, for all large enough k. It follows that d(x) divides both B(x)B(x + 1) . B(x + k - 1) and A(x - 1)A(x - 2) . . . A(x - k) for all large enough k. But these two polynomials are relatively prime by the assumptions of the Lemma, so d(x) is constant . Hence c(x) divides C(x), by (3 .6) and (3 .5) . 0 COROLLARY 3 .1 . PROOF . Factorization (3 .1) described in Lemma 3 .1 is unique . Assume that A(x) C(x + 1) - z a(x) c(x + 1) r(x) - Z B(x) C(x) b(x) c(x) (3 .8) where A, B, C as well as a, b, c are monic polynomials satisfying properties (AB), (AC), and (BC) of Lemma 3 .1 . Then Z = z . By Lemma 3 .2, c(x) divides C(x) and vice versa . As they are both monic, c(x) = C(x) . Therefore A(x)b(z) = a(x)B(x) . By property (AB) of Lemma 3 .1, a(x) divides A(x) and vice versa, so a(x) = A(x) and b(x) = B(x) . O 4. Hypergeometric solutions Let Ko be a field of characteristic zero and K an extension field of K0 . Given a linear recurrence operator L with polynomial coefficients over K0, we seek solutions of (1 .2) which are hypergeometric over K . We will call Ko the coefficient field of the recurrence . We assume that there exist algorithms for finding integer roots of polynomials over K and for factoring polynomials over K into factors irreducible over K . As with polynomial solutions, we consider first the second-order recurrence (2 .1) . Assume that a(n) is a hypergeometric solution of (2 .1) . Then there is a rational sequence S(n) such that a(n+1) = S(n)a(n) . Substituting this into (2 .1) and cancelling a(n) gives p(n)S(n + 1)S(n) + q(n)S(n) + r(n) = 0 . Hypergeometric Solutions of Recurrences 25 3 Let S(n) = Z A(n) C(n + 1) B(n) C(n) be the normal form for S(n) described in Lemma 3 .1 . Then Z2 p(n)A(n+1)A(n)C(n+2)+Zq(n)B(n+l)A(n)C(n+1)+r(n)B(n+l)B(n)C(n) = 0 . (4 .1) The first two terms contain A(n) as a factor, so A(n) divides r(n)B(n + 1)B(n)C(n) . By properties (AB) and (AC) of the normal form, A(n) is relatively prime with C(n), B(n), and B(n + 1), so A(n) divides r(n) . Similarly we find that B(n + 1) divides p(n)A(n + 1)A(n)C(n + 2), therefore by properties (AB) and (BC) of the normal form, B(n + 1) divides p(n) . This leaves us with a finite set of candidates for A(n) and B(n), namely, the monic factors of r(n) and p(n - 1), respectively. We can cancel A(n)B(n + 1) from the coefficients of (4 .1) to obtain Z2 B(n + 1) A(n + 1)C(n + 2) + Z q (n)C(n + 1) + A(n) B(n)C(n) = 0 . (4 .2) To determine the value of Z, we consider the leading coefficient of the left-hand side in (4 .2) and find out that Z satisfies a quadratic equation with known coefficients . So given the choice of A(n) and B(n), there are at most two choices for Z . For a fixed choice of A(n), B(n), and Z, we can use algorithm Poly to determine if (4 .2) has any non-zero polynomial solution C(n) . If yes, we have found a hypergeometric solution of (2 .1) . If (4 .2) has no non-zero polynomial solution whatever the choice of A(n), B(n), and Z, then (2 .1) has no hypergeometric solution . Algorithm Hyper for d = 2 INPUT : Polynomials p(n), q(n), and r(n) over Ko ; an extension field K of K0 . OUTPUT : A hypergeometric solution of (2 .1) over K if it exists ; 0 otherwise . [1] For all monic factors A(n) of r(n) and B(n) of p(n - 1) over K do : P(n) :_ (p(n)/B(n + 1))A(n + 1) ; q(n) ; Q(n) R(n) :_ (r(n)/A(n))B(n) ; m := max{deg P, deg Q, deg R} ; let a, ,3, y be the coefficients of n' in P, Q, R, respectively ; for all non-zero Z E K such that C Z2 + ,3Z + ,y = 0 do : If the recurrence Z 2 P(n)C(n + 2) + ZQ(n)C(n + 1) + R(n)C(n) = 0 has a non-zero polynomial solution C(n) over K then S(n) := Z(A(n)/B(n))(C(n + 1)/C(n)) ; return a non-zero solution a(n) of a(n + 1) = S(n)a(n) and stop . [2] Return 0 and stop . 254 M. Petkovsek EXAMPLE 4 .1 . The recurrence (n + 4)a(n + 2) + a(n + 1) - (n + 1)a(n) = 0 appears in Bender and Orszag (1978), p . 43, Example 2 .3 .5 . The monic factors of r(n) are 1 and n + 1 and those of p(n - 1) are 1 and n + 3 . Taking A(n) = B(n) = 1 leads to Z = ±1 ; however, algorithm Poly finds no non-zero polynomial solutions of the auxiliary recurrences . If exactly one of A(n), B(n) is equal to 1, the equation for Z is either Z = 0 or contradictory. Finally, the choice A(n) = n + 1, B(n) = n + 3 leads to Z = f 1 again . For Z = 1, the auxiliary recurrence is (n + 2)C(n + 2) + C(n + 1) - (n + 3)C(n) = 0 with, up to a constant factor, unique polynomial solution C(n) = 1 . This gives S(n) _ (n + 1)/(n + 3) and 1 a(n) _ ( n + 1)(n + 2) For Z = -1, the auxiliary recurrence is (n + 2)C(n + 2) - C(n + 1) - (n + 3)C(n) = 0 with, up to a constant factor, unique polynomial solution C(n) = 2n + 3 . This gives S(n) _ -((n + 1)/(n + 3))((2n + 5)/(2n + 3)) and a (n) (n) (-1)"(2n+3) (n + 1)(n + 2) EXAMPLE 4 .2 . The number d(n) of derangements of a set with n elements satisfies the recurrence a(n) = (n - 1)a(n - 1) + (n - 1)a(n - 2) . (4 .3) Taking A(n) = B(n) = 1 yields Z = -1, but the auxiliary recurrence has no non-zero polynomial solution . The remaining choice A(n) = n + 1, B(n) = 1 leads to Z 2 - Z = 0, so Z = 1 . The auxiliary recurrence (n + 2)C(n + 2) - (n + 1)C(n + 1) - C(n) = 0 has, up to a constant factor, the only polynomial solution C(n) = 1 . Then S(n) = n + 1 and, up to a constant factor, a(n) = n! is the only hypergeometric solution of (4 .3) . Using the well-known method of reduction of order, we find another fundamental solution (which happens to be precisely the number of derangements) : d(n) = n! n (_1)k (4.4) k=O Since this is not a constant multiple of n! (although it comes very close, being equal to the integer nearest to n!/e), we have proved that (4 .4) is not a hypergeometric term . As the summand in (4 .4) does not depend on n this can also be shown by Gosper's algorithm . Hypergeometric Solutions of Recurrences EXAMPLE 4 .3 . In van der Poorten (1979), it is shown that the numbers k(k)2 ( k)' a(n) = n k 255 (4 .5) satisfy the recurrence (n + 2) 3 a(n + 2) - (2n + 3)(17n 2 + 51n + 39)a(n + 1) + (n + 1) 3 a(n) = 0 . (4 .6) Here all the coefficients are of the same degree, therefore the equation for Z will have no non-zero solution unless A(n) and B(n) are of the same degree as well . But they are both monic factors of (n + 1) 3 , so they must be equal . Then P(n) = p(n), Q(n) = q(n), R(n) = r(n), and the equation for Z is Z2 - 34Z + 1 = 0 with solutions Z = 17± 12/ . In both cases the auxiliary recurrence has no non-zero polynomial solutions, proving that (4 .6) has no hypergeometric solution . As a consequence, (4 .5) is not hypergeometric . Algorithm Hyper for arbitrary d INPUT : Polynomials pi(n) over K0, for i = 0, I__, d ; an extension field K of ho . OUTPUT : A hypergeometric solution of (1 .2) over K if it exists ; 0 otherwise . [1] For all monic factors A(n) of po(n) and B(n) of pd(n - d + 1) over K do : A(n + j) fly_ ; B(n + j), for i = 0, 1, . . . , d ; Pi (n) := pi (n) rn := maxo<i<d leg Pi (n) ; let ai be the coefficient of n' in Pi (it), for i = 0, 1, . . . , d ; 0 for all non-zero Z E K such that d aiZ' = 0 i-o E (4 .7) do : If the recurrence d Z' Pi(n)C(n + i) = 0 E i_o (4 .8) has a non-zero polynomial solution C(n) over K then S(n) := Z(A(n)/B(n))(C(n + 1)/C(n)) ; return a non-zero solution a(n) of a(n + 1) = S(n)a(n) and stop . [2] Return 0 and stop . a(n) be a non-zero solution of (1 .2) such that a(n + 1) = S(n)a(n) where S(n) is a rational sequence . Let THEOREM 4 .1 . Let S(n) = ZAB(n) (4 .9) CC(n)1) 256 M. Petkovgek be the normal form described in Lemma 3 .1 . Let Pi(n) and ai, for i = 0, 1, . . . , d, be defined as in algorithm Hyper . Then Ed o aiZi = 0, A(n) divides po(n), B(n) divides pd(n - d + 1), and C(n) satisfies (4 .8) . Conversely, if Z is an arbitrary constant, A(n) and B(n) arbitrary sequences, C(n) satisfies (4 .8) where Pi(n), for i = 0, 1, . . ., d, is defined as in algorithm Hyper, and a(n + 1) = S(n)a(n) where S(n) is as in (4 .9), then a(n) satisfies (1 .2) . PROOF . From (1 .2) and a(n + 1) = S(n)a(n) it follows that d i-1 A(n) E i=o 11 S(n J=o + j) a(n) = 0, (4 .10) C(n + i) C(n) = 0 . (4 .11) hence after cancelling a(n) and using (4 .9) we have d EA(n)Zi i=o `~-1 A(n + j) 11 B(n + j) i=o Multiplication by C(n)1J B(n + j) now gives (4 .8) . All terms of the sum in (4 .8) with i > 0 contain the factor A(n), thus A(n) divides the term with i = 0 which is Po(n)C(n) =o B(n + j) . By properties (AB) and (AC) of the normal form, it follows n, that A(n) divides po(n) . Similarly, B(n + d - 1) divides Zd pd(n)C(n + d) ~~ _ 1 A(n + j), hence by properties (AB) and (BC) of the normal form, B(n + d - 1) divides pd(n), so B(n) divides pd(n - d + 1) . Finally, a look at the leading coefficient of the left-hand side of (4 .8) shows that Ei o aiZ i = 0 . To prove the converse, we retrace the steps which led from (1 .2) through (4 .10) and (4 .11) to (4 .8), in reverse order . 0 REMARK 4 .1 . Although the worst-case time complexity of Hyper is exponential in the degree of (1 .2), a careful implementation can speed it up in several places . Here we give a few suggestions . We can reduce the degree of recurrence ( 4 .8) by cancelling the factor A(n)B(n+d-1), as we did in (4 .2) for the case d = 2 . Observe that the coefficients of equation ( 4 .7) which determines Z depend only on the difference D(A, B) = deg B(n)-deg A(n) and not on A(n) or B(n) themselves . Therefore it is advantageous to test pairs of factors A(n), B(n) in order of the value of D(A, B) . We can skip those values of D(A, B) for which (4 .7) has a single non-zero term and thus no non-zero solution . For example, this happens when degpd(n) = degpo(n) > degpo(n) for 0 < i < d, and D(A, B) # 0 . Hence in this case it suffices to test pairs A(n), B(n) of equal degree (cf. Examples 4 .1 and 4 .3) . We can skip all pairs A(n), B(n) which do not satisfy property (AB) of Lemma 3 .1 . EXAMPLE 4 .4 . The number i(n) of involutions of a set with n elements satisfies the recurrence a(n) = a(n - 1) + (n - 1)a(n - 2) . More generally, let r > 2 . The number i r (n) of permutations which contain no cycles Hypergeometric Solutions of Recurrences 257 longer than r satisfies the recurrence a(n) = + a(n - 1) + (n - 1)a(n - 2) + (n - 1)(n - 2)a(n - 3) + . . . (n - 1) . . .(n - r + 2)(n - r + 1)a(n - r) (4 .12) (see, e .g ., Wimp and Zeilberger (1985)) . In Hyper, the degrees of the coefficients of auxiliary recurrences are obtained by adding to the degree sequence of the coefficients of the original recurrence (starting with the leading coefficient) an arithmetic progression with increment D = D(A, B) . In case of (4 .12), the degree sequence is 0, 0, 1, 2r - 1 . Adding to this sequence any arithmetic progression with integer increment D will produce a sequence with a single term of maximum value (the first one if D < 0 ; the last one if D > 0), implying that (4 .7) has a single non-zero term for all choices of A(n) and B(n) . Therefore (4 .12) has no hypergeometric solution . This example shows that for any d > 2, there exist recurrences of order d without hypergeometric solutions . In particular, for r = 2 this means that the sum n! (4 .13) i(n) = E (n - 2k)! 2k k! ' (see, e .g ., Comtet (1974)), is not a hypergeometric term . 4 .5 . (Gessel el al., 1991) encountered the following sums when evaluating inversion polynomials of plane trees at q = -1 (see their paper for the relevant definitions) : EXAMPLE f(n) = 3k) 3n - 3k) kn ( k ( n-k n-1 (4 .14) 3k) (3n - 3k - 2 g (n) (4 .15) . _ Y- ( k ) ( n - k - 1 ) As shown by S .B . Ekhad using the algorithm of Zeilberger (1991), where L = M = + Lf = 0 and Mg = 0 8(n + 2)(2n + 3)E 2 - 6(36n 2 + 99n + 70)E + 81(3n + 2)(3n + 4), 16(n + 2)(2n + 3)(2n + 5)E 3 - 12(2n + 3)(54n 2 + 153n + 130)E 2 324(27n 3 + 72n 2 + 76n + 30)E - 2187n(3n + 1)(3n + 2), and E denotes the shift operator . Using Hyper on La = 0 we find that dim(KerL G( H K)) = 1 . A fundamental hypergeometric solution is x(n) _ ( 7) n (corresponding to A(n) = B(n) = C(n) = 1, Z = 27/4) . Therefore L 1 = 2(n + 2)(2n + 3)E - 3(3n + 2)(3n + 4), and From this we obtain a second fundamental solution (3k) (27) y(n) = x(n)E 3k - 1 L = L1 L : where (4 .16) L 2 = 4E - 27 . n fl 4 k 258 M . Petkovsek From f(0) = 1, f(1) = 6 we determine that f(n) = (x(n) - y(n))/2 . (4 .17) Also, f (n) satisfies the non-homogeneous first-order recurrence (3n+1) 4f(n + 1) - 27f(n) = -3 n+1 2n + 1 Using Hyper on Ma = 0 we find that dim(KerM fl L(flK)) = 2 . Two fundamental hypergeometric solutions are x(n) and 27 n u(n) = n (2n) (n (corresponding to A(n) = n, B(n) = n + 1/2, C(n) = 1, Z = 27/4) . By means of these solutions we find that M = M1 M2L2 where L2 is as in (4 .16), M1 = 2(n + 2)(2n + 3)E 3(3n + 1)(3n + 2), and M2 = 2(2n + 3)E - 27n . From this we obtain a third fundamental solution v(n) = X(n) n-1 ~ 2k(k+ ) 1 (27) k 4 From g(1) = 1, g(2) = 7, g(3) = 48 we determine that for n > 1, g(n) = (3x(n) + v(n))/27 . (4 .18) The fact that u(n) does not appear in (4 .18) hints at existence of a second-order recurrence with polynomial coefficients satisfied by g(n) . Indeed, we find that Tg = 0 where T = 8(n + 1)(2n + 3)E 2 - 6(36n 2 + 63n + 31)E + 81(3n + 1)(3n + 2) = T 1 L 2 , with T1 = 2(n + 1)(2n + 3)E - 3(3n + 1)(3n + 2), and L2 as in (4 .16) . Also, g(n) satisfies the non-homogeneous first-order recurrence (3n) 4g(n + 1) - 27g(n) = 2n + 1 Observe that (4 .17) and (4 .18) are identities which express f(n) and g(n) in terms of sums whose summand does not depend on n, in contrast to their definitions in (4 .14) and (4 .15) . We conclude that neither f(n) nor g(n) belongs to ,C(fK) . EXAMPLE 4 .6 . Consider the recurrence n(n + 1)a(n + 2) - 2n(n + k + 1)a(n + 1) + (n + k)(n + k + 1)a(n) = 0 (4 .19) over the field Q(k) where k is transcendental over Q . Since its degree polynomial D(N) = (N - k)(N - k - 1) has no integer roots, (4 .19) has no polynomial solutions . However, Hyper succeeds with Z = 1, A(n) = n + k, B(n) = n, and C(n) any linear polynomial . Thus we find two fundamental hypergeometric solutions, say, (k + 1)n -1 /(n - 1)! and (k + 2)n -2 /(n - 2)! where n-1 kn = II (k + i) =o is the rising power . If we substitute a non-negative integer value for k these solutions can Hypergeometric Solutions of Recurrences 259 be written as ( n+ k -1 ) and (nk+11), respectively . It follows that for every specific nonnegative integer k all solutions of (4 .19) are polynomial over Q ; cf . Example 2 .2 which is a special case with k = 99 . 5 . Ramifications of Hyper 5 .1 . LINEAR COMBINATIONS OF HYPERGEOMETRIC TERMS Sometimes hypergeometric terms are used to define the notion of "closed form", but this leaves out such nice sequences as 2" - 1 . The class £(HK) is larger and has more closure properties than WK, while still being acceptable as a paradigm for "closed form" . Algorithm Hyper can be modified to find a basis for the space of all those solutions of (1 .2) which belong to ,C(HK) . PROPOSITION 5 .1 . Let L be as in (1 .1), and let a be a hypergeometric term such that La # 0 . Then La is hypergeometric and similar to a . PROOF . Let r := Ea/a . Then E`a = Ei -1 (ra) _ (Ei-1r)(E`-la) _ d d (rio Or) a, so i-1 La =>2piE`a= EpirjEjr a i-o i-o i-o is a non-zero rational multiple of a. 0 PROPOSITION 5 .2 . Every sequence from C(HK) can be written as a sum of pairwise dissimilar hypergeometric terms . Since the sum of two similar hypergeometric terms is either hypergeornetric or zero, the desired representation can be achieved by grouping together similar terms . 0 PROOF . THEOREM 5 .1 . Let S be a non-empty set of hypergeometric terms . If S is linearly dependent over RK then S contains two similar hypergeometric terms . PROOF . on Let S C _ 'HK be linearly dependent over 9ZK . We prove the assertion by induction ISI . If ISS = 1 then S is not linearly dependent over RK . If SI > 1, let S' = { a1, a2, . . . , a m } be a minimal subset of S which is linearly dependent over RK . Then there exist non-zero elements r1, r2, . . ., rm E RK such that E ;"- 1 riai = 0 . Let bi := riai, for i = 1, 2, . . . , m . Then b i E WK, and I M E bi = 0 . i-1 For i = 1, 2, . . . , m, let si := Ebi/bi . Apply the resulting equations to find E to (5 .1), multiply (5 .1) by sm , then subtract m-1 (si - sm)bi = 0 . i_1 (5 .2) 260 M . Petkov§ek If Si = s m for some i then bi and b,,, are constant multiples of each other, hence ai and a m are similar . Otherwise all terms in (5 .2) are hypergeometric . By induction hypothesis there exist j and k, j # k, such that (sj - sm )bj and (Sk - s m )bk are similar . But then so are aj and a k . 0 5 .1 . Let L be a linear recurrence operator with polynomial coefficients, and E L(WK) such that La = 0 . If a = Ek-1 ai where ai are pairwise dissimilar hypergeometric terms then COROLLARY a Lai = 0, for i = 1, 2, . . ., k . By Proposition 5 .1, for each i there exists a rational sequence ri such that Lai = riai . Therefore PROOF . k 0 = La = k Lai = riai . Since the ai are pairwise dissimilar Theorem 5 .1 implies that ri = 0, for all i . 0 COROLLARY 5 .2 . Let L be a linear recurrence operator the space KerL n£(WK) has a basis in WK . with polynomial coefficients . Then Let a E .C(WK) satisfy La = 0 . By Proposition 5 .2, we can write a = Eki=1 ai where ai are pairwise dissimilar hypergeometric terms . By Corollary 5 .1, each ai satisfies Lai = 0 . It follows that hypergeometric solutions of (1 .2) span the space of solutions from £(?IK) . To obtain a basis for KerLflC(?IK), select a maximal linearly independent set of hypergeometric solutions of (1 .2) . 0 PROOF . PROPOSITION 5 .3 . Let r, h, hi, C, Ci be non-zero sequences from SK such that h(n + 1) = C(n + 1) h(n) - r(n) C(n) h,(n + 1) = r(n) C,(n + 1) hi (n) Ci (n) and C is a K-linear combination of Ci . Then PROOF . for i = 1,2, . . .,k, (5 .3) (5 .4) h is a K-linear combination of hi . From (5 .3) and (5 .4) it follows that there are constants a, ai E K and jo E IN such that n-1 h(n) = a 11 r(j) C(n) j=jo and n-1 hi(n) = ai (r()) jCi(n), j=jo for i = 1,2, . . .,k . Hypergeometric Solutions of Recurrences Let C = E ki=1 261 A Ci where Ai E K . Then k h(n) = Eai i=1 n-1 k r(j) 1 aiCi(n) = hi(n) Ea ' ai i=1 j=ja 0 Modify Hyper so that it will not stop after finding one hypergeometric solution but will rather test all possible choices of A(n), B(n), and Z . Return all hypergeometric solutions h which satisfy h(n + 1) = S(n)h(n) where S(n) - Z E~n~ C(n+) and C is a basic polynomial solution found by Poly on the corresponding auxiliary recurrence . From Theorem 4 .1, Corollary 5 .2, and Proposition 5 .3 it follows that this modified algorithm will produce a generating set for the space of solutions which belong to G(nK) . In general, this will not be a basis because the same hypergeometric solution may be obtained from several auxiliary recurrences . One can prune this set until it becomes a basis, testing for linear dependence by means of the Casoratian determinant . Another way to obtain such a basis is to find one hypergeometric solution with Hyper, then reduce the order of the recurrence, recursively find the corresponding basis for the reduced recurrence, and use Gosper's algorithm to put the antidifferences of these solutions into closed form if possible . This method will actually yield a larger class of solutions (cf. Examples 4 .2 and 4 .5) . 5 .2 . NON-HOMOGENEOUS RECURRENCES In this subsection we show how to solve (1 .3) over ,C(WK) when f # 0 . PROPOSITION 5 .4 . Up to the order of the terms, the representation of sequences from G(nK) as sums of pairwise dissimilar hypergeometric terms is unique . PROOF . Assume that a1, a2, . . . , ak and b1, b2,, . . , b,,, are pairwise dissimilar hypergeo- metric terms with k m E ai = I: b j . i=1 ( 5 .5) j=1 Using induction on k + m we prove that k = m and that each ai equals some bj . If k + m = 0 this holds trivially . Let k + m > 0 . Then by Theorem 5 .1 it follows that k > 0, m > 0, and some ai is similar to some bj . Relabel the terms so that at is similar to b,,,, and let h := ak - b,,, . If h # 0 then we can use induction hypothesis both on k-1 Em-1 Z k_ 1 ai E "`-1 bj - h, to find that k = m-1 and ai + h = = j=1 E j=1 b • and i=1 j: k - 1 = m . This contradiction shows that h = 0, so ak = b n, and i=1 ai = ;) i 1 b, . By induction hypothesis, k = m and each ai with 1 < i -< k - 1 equals some Dj with 1<j<m-1 .0 If a E G(?iK) and La = f then f E G(HK), by Proposition 5 .1 . Let a aj and k f = ~j=1 fj where aj and fj are pairwise dissimilar hypergeometric terms . Without loss of generality assume that there is an 1 < m such that Laj ~ 0 if and only if j < 1 . Then 262 M . Petkovsek by Proposition 5 .4, 1 = k and we can relabel the fj so that Laj = fj , for j = 1, 2, . . . , k . (5 .6) By Proposition 5 .1, there are non-zero rational sequences rj such that aj = rj fj , for j = 1, 2, . . ., k . Let sj := Efj/fj . With L as in (1 .1), it follows from (5 .6) that rj satisfies Lj rj = 1 , for j = 1, 2, . . . , k (5 .7) where d i-1 Lj=Epi fjE i sj i_o (1=0 E', for j=1,2, . . .,k . This gives the following algorithm for solving (1 .3) over C(7{K) : 1 . Write f = Ekj _ 1 fj where fj are pairwise dissimilar hypergeometric terms . 2 . For j = 1, 2, . . ., k, find a non-zero rational solution rj of (5 .7) using the algorithm of Abramov (1989b) . If none exists for some j then (1 .3) has no solution in £(HK) . 3 . Use Hyper to find a basis a1, a2 i . . . , a,,, for the space KerL fl G(fK) . 4 . Return E~ 1 Cjaj + L.~=1 rj fj where Cj are arbitrary constants . Note that step 2 could also be carried out by means of Hyper, since any solution of a non-homogeneous recurrence with hypergeometric right-hand side satisfies a homogeneous recurrence of one-higher order . However, we prefer Abramov's algorithm for this task in order to avoid exhaustive search for suitable monic factors of the two sentinel coefficients of the recurrence . It remains to explain how to perform step 1 . We need to group together similar hypergeometric terms, so we need to decide if a given hypergeometric term is rational . The following lemma gives an algorithm for this . LEMMA 5 .1 . Let h E 7lK and r := Eh/h . Let r(n) = Z A(n) C(n + 1) B(n) C(n) and B(n) _ a(n) c(n + 1) A(n) b(n) c(n) (5 .8) be the normal forms for r(n) and B(n)/A(n), as described in Lemma 3 .1 . Then h E RK if and only if Z = a(n) = b(n) = 1 . PROOF . If Z = a(n) = b(n) = 1 then r(n) = c(n)C(n + 1)/(c(n + 1)C(n)), so h(n) _ aC(n)/c(n) where a E K is some constant . Hence h is rational . Conversely, assume that h(n) = p(n)/q(n) where p, q are relatively prime polynomials . Let h(n + 1) __ q (n) p(n + 1) _ z A(n) C(n + 1) h(n) q(n + l) p(n) Hypergeometric Solutions of Recurrences 263 divides C(n) . Write C(n) _ as in Lemma 3 .1 . Obviously, Z = 1 . By Lemma 3 .2, where s(n) is a polynomial . Then from (5 .9) p(n) p(n)s(n) B(n) _ q(n + 1) s(n + 1) A(n) By Corollary 3 .1, q(n) normal form (5 .8) is unique . So s(n) c(n) = q(n)s(n) and a(n) - b(n) = 1 . 0 5 .3 . COMPUTING IN ALGEBRAIC EXTENSIONS Observe that all computation in algorithm Poly takes place in the coefficient field Ko of the recurrence . Therefore the basic polynomial solutions found by Poly constitute a basis for the space of polynomial solutions over any extension field K of Ko . On the other hand, algorithm Hyper used on (1 .2) requires factorization of the leading and trailing coefficients of (1 .2), as well as of polynomials encountered in (4 .7) . This factorization has to be performed in the field K over which we seek hypergeometric solutions . EXAMPLE 5 .1 . The Fibonacci recurrence a(n + 2) - a(n + 1) - a(n) = 0 (5 .10) has no hypergeometric solution over Q but it has two basic hypergeometric solutions, (i 2'15 )" and ( 1-V5-)n, over Q(/) . This is the splitting field of polynomial (4 .7) of the recurrence, namely Z 2 - Z - 1 . EXAMPLE 5 .2 . Similarly, the recurrence a(n + 2) - (2n + 1)a(n + 1) + (n 2 - 5)a(n) = 0 has no hypergeometric solution over Q while it has two basic hypergeometric solutions, . This time, Q(/) is the splitting field of the trailing (+/)"_ and (-V5-)", over Q(/) coefficient of the recurrence, n 2 - 5 . The proof of correctness of Hyper shows that if (1 .2) has a hypergeometric solution in some extension K of the coefficient field Ko, then a constant multiple of it belongs to the splitting field of the sentinel coefficients of (1 .2) and of polynomials (4 .7) . Thus computing in the algebraic closure of Ko will produce all hypergeometric solutions of recurrences over Ko . However, suppose that a is a sequence over Ko . The next theorem shows that to determine if a is hypergeometric over some extension K of Ko it is sufficient to answer this question for K = Ko . THEOREM 5 .2 . Let Ko be a field of characteristic zero and K an extension field of Ko . Let a be a sequence over Ko . If a is rational (respectively hypergeometric) over K then a is rational (respectively hypergeometric) over Ko . PROOF . Let a(n) = r(n) for n > no where r is rational over K . q are polynomials over K of respective degrees k and m, and q p(n) - a(n)q(n) = 0, for Let r = p/q where is monic . Then n = no,no + 1, . . .,no + k + m p and (5 .11) 264 M . Petkoviek is a system of linear equations over KO for the coefficients of p and q . Since (5 .11) has a non-trivial solution in K, its determinant is non-zero . It follows that (5 .11) .has a nontrivial solution in KO . The number of equations in (5 .11) exceeds the degrees of both p or q, therefore any non-trivial solution must have both p and q non-zero . So there are non-zero polynomials p' and q' over KO of respective degrees k' < k and m' < m such that (n)q(n) - p(n)q'(n) = 0, for n = no,no + 1, . . .,no + k + m . The left-hand side is a polynomial of degree not exceeding k + m which has k + m + I distinct zeros . It follows that p'q = pq', so r = p/q = p'/q' is rational over Ko . If a is hypergeometric over K then Ea/a is rational over K . By the preceding paragraph, Ea/a is rational over KO, hence a is hypergeometric over KO . 0 For example, to prove that the sequence of Fibonacci numbers is not hypergeometric over any field of characteristic zero, it suffices to show that (5 .10) has no hypergeometric solution over Q . It is interesting to observe that in recurrences arising in combinatorics the leading and trailing coefficients often factor completely over Q ; cf . Examples 4 .3, 4 .4, and 4 .5 . Acknowledgements This work is part of author's Ph .D . Thesis, Petkovsek (1990) . The author wishes to thank his advisor, Dana Scott, as well as Herb Wilf for their invaluable encouragement and support . He is also indebted to Bruce Sagan who corrected several errors in a preliminary version, and to Istvan Nemes for many fruitful discussions . References Abramov, S .A . (1989a) . Problems in computer algebra that are connected with a search for polynomial solutions of linear differential and difference equations . Moscow Univ. Comput . Math . Cybernet . no . 3, 63-68 . Transl . from Vestn. Moskov . univ . Ser . XV. Vychisl. mat. kibernet . no . 3, 56-60 . Abramov, S .A . (1989b) . Rational solutions of linear differential and difference equations with polynomial coefficients . U.S.S.R . Comput . Maths . Math. Phys . 2 9 7-12 . Transl . from Zh . vychisl. mat . mat . fiz . 29 1611-1620 . Bender, C .M ., Orszag, S .A . (1978) . Advanced Mathematical Methods for Scientists and Engineers . New York : McGraw-Hill . Cohn, R .M . (1965) . Difference Algebra . New York : Interscience Publishers . Comtet, L . (1974) . Advanced Combinatorics : The Art of Finite and Infinite Expansions . DordrechtHolland: D . Reidel Publ . Co . Transl . of Analyse Combinatoire, Tomes I et II, Presses Universitaires de Prance, Paris 1970 . Gessel, I .M ., Sagan, B .E ., Yeh, Y .-N . (1991) . Enumeration of trees by inversions . Submitted . Gosper, R .W ., Jr . (1978) . Decision procedure for indefinite hypergeometric summation . Proc . Nail. Aced . Sci. USA 75, 40-42 . Petkovsek, M . (1990) . Finding Closed-Form Solutions of Difference Equations by Symbolic Methods . Ph .D . Thesis . Pittsburgh PA : Carnegie Mellon University, CMU-CS-91-103 . van der Poorten, A . (1979) . A proof that Euler missed . . . Apery's proof of the irrationality of ((3) . Math . Intelligencer 1, 195-203 . Stanley, R .P. (1980) . Differentiably finite power series . European J. Combin . 1, 175-188 . Wilf, H .S., Zeilberger, D . (1992) . An algorithmic proof theory for hypergeometric (ordinary and "q") multisum/integral identities . To appear. Wimp, J ., Zeilberger, D . (1985) . Resurrecting the asymptotics of linear recurrences . J. Math . Anal. Appl . 111, 162-176 . Zeilberger, D . (1990) . A holonomic systems approach to special functions identities . J. Comput. Appl . Math . 32, 321-368 . Zeilberger, D . (1991) . The method of creative telescoping . J. Symb . Comput. 11, 195-204 .