The reper­toire method

The reper­toire method is a method of find­ing closed-form so­lu­tions to re­cur­rence re­la­tions and sums of a se­ries. The method is in­tro­duced in Chapter 1 of ConMath but most read­ers at first seem to strug­gle with it. Throughout the book, es­pe­cially Chapters 1 and 2, the reper­toire method demon­strates its abil­ity to solve many sums and re­cur­rences. However, I hon­estly ad­mit that it is quite dif­fi­cult to ap­ply and fully un­der­stand how it works. In this note, I try to fig­ure the way to ef­fec­tively ap­ply the method for solv­ing re­cur­rences.

Definition

In essence, the main goal of the method is to find co­ef­fi­cients for a lin­ear com­bi­na­tion of a set of re­cur­rences. This method works very well on lin­ear re­cur­rences, in the sense that the so­lu­tions can be ex­pressed as a sum of co­ef­fi­cients mul­ti­plied by func­tions of n. Therefore, if we have to find a closed-form of a lin­ear re­cur­rence, this is worth try­ing.

The method is not de­scribed clearly in ConMath be­cause the au­thors al­ways come up with a set of re­cur­rences and get their co­ef­fi­cients but they do not men­tion how they fig­ure it out. Regarding this as­pect, Sedgewick’s book pro­vides ac­ces­si­ble clar­i­fi­ca­tion and sys­tem­atic ex­am­ples. Therefore, I use the pro­ce­dure in Sedgewick’s book as a recipe for the reper­toire method:

  1. Relax the re­cur­rence by adding an ex­tra func­tion term.
  2. Substitute known func­tions into the re­cur­rence to de­rive iden­ti­ties sim­i­lar to the re­cur­rence.
  3. Take lin­ear com­bi­na­tions of such iden­ti­ties to de­rive an equa­tion iden­ti­cal to the re­cur­rence.

At first glance, it is quite ab­stract. However, some ex­am­ples car­ried out in the book il­lus­trate how we ma­nip­u­late the steps. Suppose that we have re­cur­rence an=an1+stuff. First we gen­er­al­ize the iden­tity by re­plac­ing stuff with f(n), i.e., an=an1+f(n). We eas­ily ob­tain f(n)=anan1. The next step is to build a table of in­gre­di­ents from which we can con­struct f(n). Finally, we de­ter­mine co­ef­fi­cients of each com­po­nent so that they sat­isfy f(n) and the ba­sis of the re­cur­rence.

For more de­tails and ex­pla­na­tions, I strongly rec­om­mend read­ing Markus Scheuer’s an­swer. Of course, ConMath (Chapter 1, 2, 6) is a good ma­te­r­ial for prac­tic­ing the method for un­der­stand­ing pur­poses. Section 2.5 from Sedgewick’s book sum­ma­rizes some ap­proaches to find­ing the closed-form, in­clud­ing the reper­toire method. Ex­am­ples in the book are rec­om­mended read­ing.

The best way to fully un­der­stand the method is to work through ex­am­ples.

Examples

Closed-form of sums

We can eas­ily con­vert the sum of a se­quence into a lin­ear re­cur­rence. Let’s be­gin with the first ex­am­ple, which only con­tains the term n3.

$ S_{n} = \sum_{k=0}^n k^3$

This sum can be seen as:

$ a_{0} = 0 a_{n} = a_{n-1} + n^3$

Next, we build a table of an and anan1.

an anan1
1 0
n 1
n2 2n1
n3 3n23n+1
n4 4n36n2+4n1

How can I fill an? Since we want f(n) to ob­tain n3 and we ob­serve that f(n)=anan1 de­pends on the de­gree of n in an and hence we come up with some sim­ple se­quences, i.e., com­put­ing anan1. Turns out f(n) has a smaller de­gree of n than an by ex­actly 1. f(n) ob­tain­ing n3 means that an has to ob­tain n4. The sim­plest form we can come up with is n3=α(4n36n2+4n1). So α=14, we need to elim­i­nate n2, n, and con­stants. In the sec­ond at­tempt, we add n3 and n2 into the lin­ear com­bi­na­tion:

α(4n36n2+4n1)+β(3n23n+1)+λ(2n1)=n3{6α+3β=04α3β+2λ=0α+βλ=0

The so­lu­tion is $(\alpha, \beta, \lambda) =({1\over 4}, {1\over 2}, {1\over 4}) $ and hence an=αn3+βn2+λn=14n2(n+1)2. Also, since a0=0, it is the fi­nal so­lu­tion.

Let’s try an­other ex­am­ple, this time we use an ex­er­cise in ConMath:

Sn=k=0k(1)kk2
an anan1
(1)nn2 (1)n(2n22n+1)
(1)n 2(1)n
(1)nn (1)n(2n1)

The so­lu­tion is Sn=12(1)nn(n+1) since we just add the first term and the last term to­gether and then di­vide by 2, we get f(n). When I first saw the sum, I could not think of any se­quences which help me find f(n). After playing with some se­quences, I re­al­ized that as­sign­ing an=f(n)=(1)nn2 actually lets other pat­terns be dis­cov­ered.

Linear Recurrences

a0=7an=an1+2n2+7n>0

Based on the table we built in pre­vi­ous ex­am­ples, we can con­struct a lin­ear com­bi­na­tion for the re­cur­rence:

α(3n23n+1)+β(2n1)+λ1=2n2+7{3α=23α+2β=0αβ+λ=7

The so­lu­tion is (α,β,λ)=(23,1,223). However, at this time a0=07, we have to add the con­stant 7 to the fi­nal form. The closed-form is an=23n3+n2+223n+7.

Exercise 1.16 (ConMath)

g(1)=αg(2n+j)=3g(n)+γn+βj=0,1;n1

Related Materials

After hours search­ing on the Internet, I found some use­ful links which ac­tu­ally help me un­der­stand the method:

  • Wakatta’s post
  • Math stack­ex­change an­swer: this one is damn good.
  • Pindancing’s post
  • Sedgewick, Robert, and Philippe Flajolet. An in­tro­duc­tion to the analy­sis of al­go­rithms. Pearson Education India, 1996. [IMO, the ex­pla­na­tion in this book is much bet­ter than in ConMath.]
  • Graham, Ronald L., et al. Concrete math­e­mat­ics: a foun­da­tion for com­puter sci­ence.” Com­put­ers in Physics 3.5 (1989): 106 – 107.