§ Gosper's algorithm
- Given a hypergeometric function a(n), gosper's algorithm finds the function S(k)=∑i=0kf(k), iff S is hypergeometric.
- Suppose S(k)/S(k−1) is a rational function of k.
- Then f(k)/f(k−1)=(S(k)−S(k−1))/(S(k−1)−S(k−2), which equals (S(k)/S(k−1)−1)/(1−S(k−2)/S(k−1)) which is also a rational function.
- Thus, we want to expression f(k)/f(k−1)=q(k)/r(k).
- However, we give ourselves a "fudge factor" of the form f(k)/f(k−1)=p(k)/p(k−1)⋅q(k)/r(k).
§ Step 1: p, q, r decomposition
- We try to impose a condition on q(k),r(k) that we impose using p(k), which states: ∀a,b,(k+a)∥q(k)∧(k+b)∥r(k)⟹a<b.
- For example, if we have (x−100)/(x−1), then a=−100 is less than b=1, which satisfies the condition.
- We claim that this is always possible to achieve:
p = 1
q = (a1+k)(a2+k)..(am+k)
r = (b1+k)(b2+k)...(bn+k)
while exists a, b such that q % (k + a) = 0 and r % (k + b) = 0:
N = a - b
if N < 0: break
q = q / (k + a); r = r / (k + b);
fudge = falling_factorial(k + a, N)
p = p * t
§ Step 2: The secret function s(k)
- We assume that f(k)=S(k)−S(k−1).
- We now write S(k)=q(k+1)/p(k)⋅s(k)f(k) for some secret function s(k) to be found.
§ s(k) is a rational function iff S(k) is
- substituting in the above eqn, we get:
s(k)=q(k)p(k)fracS(k)f(k)=q(k)p(k)(S(k)−S(k−1)S(k)=q(k)p(k)(1−(S(k−1)/S(k))1
- This tells us that s(k) is a rational function whenever S(k) is.
§ Recurrence of s(k)
Substituting S(k)=q(k+1)/p(k)⋅s(k)f(k) into f(k)=S(k)−S(k−1), we get:
f(k)f(k)p(k)f(k)…p(k)=q(k+1)s(k)−r(k)s(k−1)=p(k)q(k+1)s(k)f(k)−p(k−1)q(k)s(k−1)f(k−1)=f(k)p(k)p(k)q(k+1)s(k)f(k)−f(k)p(k)p(k−1)q(k)s(k−1)f(k−1)
- TODO: What does this recurrence mean for GP?
§ Step 3: s(k) is polynomial iff S(k) is a rational function
- We already know that s(k) is a rational function.
- For contradiction, assume s(k)=u(k)/v(k) where v(k)=1, gcd(u(k),v(k))=1 for contradiction.
- let N be the largest natural such that (k+β) and (k+β+N) both occur as factors for v(k) ( β∈C). See that N always exists because N=0 exists.
- Substituting into the definition of p(k) in terms of q(k),r(k),s(k), we get:
p(k)p(k)p(k)v(k)v(k−1)=q(k+1)s(k)−r(k)s(k−1)=q(k+1)u(k)/v(k)−r(k)u(k−1)/v(k−1)=q(k+1)u(k)v(k−1)−r(k)u(k−1)v(k)
- We know that v can be made zero if its argument equals β, and beta+N, so we perform the followig assignments:
- First set k−1=−β (so v(k−1)=0):
p(k)v(k)(v(k−1)∼0)00=q(k+1)u(k)(v(k−1)∼0)−r(k)u(k−1)v(k)=−r(k)u(k−1)v(k)=r(−β+1)u(−β)v(−β+1)
- Next set k=−β−N (so v(k)=0):
p(k)(v(k)∼0)v(k−1)00=q(k+1)u(k)v(k−1)−r(k)u(k−1)(v(k)∼0)=q(k+1)u(k)v(k−1)=q(−β−N+1)u(−β−N)v(−β−N−1)
- Now, we must have that u(−beta)=0, and u(−β−N)=0, since (u,v) have no common factors.
- Also, v(−β+1)=0 and v(−β−N−1)=0, because v(k) would otherwise have a factor of k+β+N+1 or k+β−1, which contradicts the maximality of N (??? what does this even mean?)
- Thus, we must have r(−β+1)=0=q(−β−N+1).
- But this contradicts condition (3).
- Hence, s(k) is a polynomial.
- WTF is this proof? I see no moral of the story.
§ Step 4: finding s(k) given p,q,r
§ References