Gosper’s Algorithm By Zachary Vogel Binomial Coefficients • Binomial Coefficients n n! k k ! n k ! • The Binomial Theorem n nk k (a b) a b k 0 k n k Pascal’s Triangle • Base identity for Pascal’s Triangle n n 1 n 1 k k 1 k n n with 1 n 0 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 Binomial Identities • Parallel Summation identity n r k r n 1 k n 1 k 0 • Negation identity n n 1 k m 1 ( 1) ( 1) k m 1 k m Binomial Identities • There are volumes of identities with binomial coefficients. • Here is one taken from a book: • Nanjundiah’s identity m x y n x y x k x y k k 0 n k m n m n n Visual of Parallel Summation r k r n 1 k k 0 n 1 n 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 n=0 Visual of Parallel Summation r k r n 1 k k 0 n 1 n 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 n=1 Visual of Parallel Summation r k r n 1 k k 0 n 1 n 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 n=2 Visual of Parallel Summation r k r n 1 k k 0 n 1 n 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 n=3 Hypergeometrics • How to find some order in all these identities with binomial coefficients? • Hypergeometric notation can be used to standardize identities. Notation k ! k ( k 1)( k 2)...(1) n n(n 1)(n 2)...(n k 1) k k n n! (n k 1) k ! n k ! k! k Hypergeometric Series k a1 , a2 ...am a1k a2k ...am zk F | z k k k b , b ... b b b ... b k n 1 2 1 2 n k! Special Cases • Exponential series 1 F | z 1 1k z k k 1 k! k k zk ez k! • Geometric series k k k k 1,1 11 z k !z F | z k k! 1 k! k k 1 1 z 1 z k k Hypergeometric Terms • General Form of a hypergeometric term k a1 , a2 ...am a1k a2k ...am zk F | z k k k b , b ... b b b ... b n 1 2 k 1 2 n k! 1,1 1k1k z k k !zk k F | z z k! 1k k ! 1 k n k 1,1 n (n k 1) k F | 1 1 k! k k Successive Terms • If you take the ratio of successive terms of a hypergeometric series, the ratio is a rational polynomial of k. • If the ratio of successive terms form a rational function of k, then the series is hypergeometric up to a constant multiple. Gosper’s Algorithm Overview • Takes a hypergeometric term and sums it indefinitely • Example n k m 1 n 1 k 1 1 m 1 k m Gosper’s Algorithm Overview • The algorithm determines if the sum is a multiple of another hypergeometric term t (k ) cT (k ) C –OR – • It determines that the sum cannot be put in this form. Gosper’s Algorithm Step 1 • We will assume that some such T(k) exists. • If we get an impossible situation, then no such T(k) exists. • The first step is to work out the term ratio of the summand t(k) Term Ratio • Write the term ratio for t(k) t (k 1) p(k 1) q(k ) t (k ) p(k ) r (k 1) • where initially p(k) = 1 • We will pull out some factors of q and r into p. Gosper’s Algorithm Step 1 • We require that q(k) and r(k) must have no factors (k ) \ q(k ) and (k ) \ r (k ) • such that N Z Gosper’s Algorithm Step 1 • For if N Z • then divide out the factors from q(k) and r(k) and absorb those terms into p(k) as follows q(k ) q(k ) (k ) r (k 1) r (k 1) (k 1) p(k ) p(k )(k 1) N 1 • p(k+1)/p(k) telescopes nicely. p(k 1) (k )(k 1)...(k 2) k p(k ) (k 1)(k 2)...(k 1) k 1 Gosper’s Algorithm Step 2 r (k ) s (k )t (k ) T (k ) p(k ) • Cleverly set • s(k) is some unknown function which will be the focus of the remainder of the algorithm • If we can determine what s(k) is, we can determine the final summation T(k). Gosper’s Algorithm Step 2 • By applying • we get t (k ) T (k 1) T (k ) p(k ) q(k ) s(k 1) r (k ) s (k ) • We look to solve for s(k). Unknown function s(k) • In order to determine T(k) we must solve for s(k). This requires a few steps – Determine that s(k) is a rational function of k – Determine that s(k) is a polynomial in k – Determine a bound on the degree of s(k) s(k) is a rational function of k • By substitution r (k ) s (k ) T (k ) (T (k 1) T (k )) p(k ) • and T (k 1) T (k ) p(k ) T (k ) r (k ) s (k ) • With the left hand side a rational function of k, and p(k) and r(k) are polynomials, s(k) must be a rational function of k s(k) is a polynomial • Knowing s(k) is a rational function of k, we can write it as the quotient of polynomials s(k ) f (k ) g (k ) • such that f(k) and g(k) have no common factor • we will also assume that g(k) has a root, then find a contradiction any polynomial without a root is just a constant, so s(k) will, itself, be a polynomial • s(k) is a polynomial • Suppose that g(a) = g(b) = 0, and b-a is a nonnegative integer. (In particular, we might have a = b). • Since f (k 1) f (k ) p(k ) q(k ) r (k ) g (k 1) g (k ) • We have p(k ) g (k ) g (k 1) q(k ) f (k 1) g (k ) r (k ) f (k ) g (k 1) s(k) is a polynomial • Substitute a=k+1, and separately b = k, we get: 0 r (a 1) f (a) g (a 1) q(b) f (b) g (b 1) • Since f and g have no common root, 0 r (a 1) g (a 1) q(b) g (b 1) • So either g(a-1)=0, or g(b+1)=0, or both r(a-1) = q(b) = 0. • The last choice is impossible by construction. s(k) is a polynomial • We now know that g(b+1) or g(a-1) is a root • By repeating this argument with a-1 and b, or a and b+1, we get infinitely many roots for g(k). • Therefore, g(k) has no root, thus is a constant. So s(k) is, itself a polynomial. s (k ) d k d d 1k d 1 ... 0 Bounding degree of s(k) • If we know a bound to the degree d of s(k), then we can solve it by a system of d+1 linear equations, as given by the equation: p(k ) q(k ) s(k 1) r (k ) s (k ) Bounding degree of s(k) • By manipulating our previous equations, it can be seen that 2 p(k ) Q(k )[ s(k 1) s(k )] R(k )[ s(k 1) s(k )] • With R(k ) q(k ) r (k ) k d ' ... Q(k ) q(k ) r (k ) ' k d '1 ... We also Know deg[ s (k )] d deg[ s (k 1) s (k )] d deg[ s(k 1) s(k )] d 1 change to ≤ Bounding degree of s(k) • Now if deg[Q(k )] deg[ R(k )] Then the degree of the RHS will be deg[Q( k )] d Therefore, d deg[ P(k )] deg[Q(k )] Otherwise, one of two options will occur i) 2 ' d 0: d deg[ p(k )] deg[ R(k )] 1 ii) 2 ' d 0: d 2 ' deg[ p(k )] deg[ R(k )] 1 remove RHS Solving s(k) • Knowing the degree of s(k), solve p(k ) q(k ) s(k 1) r (k ) s (k ) • Then simply plug the known s(k) into r (k ) s(k )t (k ) T (k ) p(k ) Example of Gosper’s Algorithm • To provide an example of Gosper’s algorithm at work we will attempt to solve the negation identity n n 1 k m 1 ( 1) ( 1) k m k m 1 • To begin we set our t(k) to the summand n k t (k ) (1) k Negation Identity • Now by setting up a term ratio we will arrive at values for r(k), q(k) and p(k): p(k ) 1 r (k ) k q(k ) k n • This satisfies the conditions on r(k) and q(k), so long as n is non-negative. Negation Identity • The next step is to determine s(k). • We can bound the degree by calculating R(k) and Q(k) Q(k ) n R ( k ) 2k n Negation Identity • Since deg(R(k)) > deg(Q(k)), we have two options: d=0 or d=n. We will try d = 0 first. • So 1 (k n) 0 k 0 1 0 s(k ) n Solution to negation identity • Now we know our s(k) = -1/n, so we plug in to get T(k): 1 n k T (k ) k (1) n k k n T (k ) (1) k 1 n k n 1 k 1 T (k ) (1) k 1 Solution to negation identity • So Gosper’s algorithm gives the identity n n 1 k m 1 ( 1) ( 1) k m 1 k m
© Copyright 2026 Paperzz