ArticleslgStudy

computer science

Gosper's algorithm

Gosper's algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Gosper's algorithm rather than just read about it. In short: In mathematics, Gosper's algorithm, due to Bill Gosper, is a procedure for finding sums of hypergeometric terms that are themselves hypergeometric terms. That is: suppose one has a(1) + ... + a(n) = S(n) − S(0), where S(n) is a hypergeometric term (i.e., S(n + 1)/S(n) is a rational function of n); then necessarily a(n) is itself a hypergeometric term, and given the formula for a(n) Gosper's algorithm finds that for…

Key takeaways

  • Gosper's algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Gosper's algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Gosper's algorithm from memory before moving on to harder problems.

Reference excerpt

In mathematics, Gosper's algorithm, due to Bill Gosper, is a procedure for finding sums of hypergeometric terms that are themselves hypergeometric terms. That is: suppose one has a(1) + ... + a(n) = S(n) − S(0), where S(n) is a hypergeometric term (i.e., S(n + 1)/S(n) is a rational function of n); then necessarily a(n) is itself a hypergeometric term, and given the formula for a(n) Gosper's algorithm finds that for S(n).

Outline of the algorithm Step 1: Find a polynomial p such that, writing b(n) = a(n)/p(n), the ratio b(n)/b(n − 1) has the form q(n)/r(n) where q and r are polynomials and no q(n) has a nontrivial factor with r(n + j) for j = 0, 1, 2, ... . (This is always possible, whether or not the series is summable in closed form.) Step 2: Find a polynomial ƒ such that S(n) = q(n + 1)/p(n) ƒ(n) a(n). If the series is summable in closed form then clearly a rational function ƒ with this property exists; in fact it must always be a polynomial, and an upper bound on its degree can be found. Determining ƒ (or finding that there is no such ƒ) is then a matter of solving a system of linear equations.

Relationship to Wilf–Zeilberger pairs Gosper's algorithm can be used to discover Wilf–Zeilberger pairs, where they exist. Suppose that F(n + 1, k) − F(n, k) = G(n, k + 1) − G(n, k) where F is known but G is not. Then feed a(k) := F(n + 1, k) − F(n, k) into Gosper's algorithm. (Treat this as a function of k whose coefficients happen to be functions of n rather than numbers; everything in the algorithm works in this setting.) If it successfully finds S(k) with S(k) − S(k − 1) = a(k), then we are done: this is the required G. If not, there is no such G.

Definite versus indefinite summation Gosper's algorithm finds (where possible) a hypergeometric closed form for the indefinite sum of hypergeometric terms. It can happen that there is no such closed form, but that the sum over all n, or some particular set of values of n, has a closed form. This question is only meaningful when the coefficients are themselves functions of some other variable. So, suppose a(n,k) is a hypergeometric term in both n and k: that is, a(n, k)/a(n − 1,k) and a(n, k)/a(n, k − 1) are rational functions of n and k. Then Zeilberger's algorithm and Petkovšek's algorithm may be used to find closed forms for the sum over k of a(n, k).

History Bill Gosper discovered this algorithm in the 1970s while working on the Macsyma computer algebra system at SAIL and MIT.

Notes

References Gosper, Jr., Ralph William "Bill" (January 1978) [1977-09-26]. "Decision procedure for indefinite hypergeometric summation" (PDF). Proceedings of the National Academy of Sciences of the United States of America. Mathematics. 75 (1). Xerox, Palo Alto Research Center, Palo Alto, California, USA: 40–42. Bibcode:1978PNAS...75...40G. doi:10.1073/pnas.75.1.40. PMC 411178. PMID 16592483. Archived (PDF) from the original on 2019-04-12. Retrieved 2020-01-10. algorithm / binomial coefficient identities / closed form / symbolic computation / linear recurrences

Worked examples

Example 1 — a first encounter with Gosper's algorithm

Start with the simplest possible case. Write down what Gosper's algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Gosper's algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Gosper's algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Gosper's algorithm

In research
Gosper's algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Gosper's algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Gosper's algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer algebra, Hypergeometric functions, so understanding it makes those chapters shorter.
In everyday life
Look for Gosper's algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Gosper's algorithm” →

How to study Gosper's algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Gosper's algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Gosper's algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Gosper's algorithm in simple terms?

In mathematics, Gosper's algorithm, due to Bill Gosper, is a procedure for finding sums of hypergeometric terms that are themselves hypergeometric terms. That is: suppose one has a(1) + ... + a(n) = S(n) − S(0), where S(n) is a hypergeometric term (i.e., S(n + 1)/S(n) is a rational function of n)…

Why does Gosper's algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Gosper's algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Gosper's algorithm.

Tags

  • Computer algebra
  • Hypergeometric functions

Keep exploring