Lesson 2
Recurrences and Sums
.
Taught
Recurrences
A recurrence defines a quantity at one value of in terms of its values at smaller ones, together with enough starting values to get the definition off the ground. Counting problems produce recurrences readily, because the natural way to attack a problem of size is often to remove one piece and be left with a problem of the same kind and smaller size. What a recurrence does not do is answer a question quickly: getting at the millionth term by following the definition means computing the first million, and the work of this chapter is to replace such a definition by a formula that can be evaluated in one step.
The Tower of Hanoi
Édouard Lucas put the following puzzle on sale in 1883. Three pegs stand in a row, and on the first of them sit discs of distinct sizes, stacked largest at the bottom and smallest on top. A move lifts the top disc off one peg and drops it onto another, and it is illegal to place a disc on top of a smaller one. The object is to move the whole stack onto a different peg.
Write for the least number of legal moves that carries a stack of discs from one peg to another. With one disc a single move does it, so . With two, the small disc goes to the spare peg, the large one to the target, and the small one on top of it: . With three the shortest solution takes seven moves,
and with four it takes fifteen. The counts so far run .
Proposition 2.1 (The Hanoi recurrence).
For every ,
and .
Discussion.
An equality between two counts is two inequalities, and each is argued differently. For we exhibit a strategy costing that many moves and appeal to being the least cost: shift the top discs to the spare peg, move the largest, shift the back on top of it. The two shifts are legal because the largest disc is out of the way in the first and sits below everything in the second, so neither is obstructed. For we argue about an arbitrary solution rather than a chosen one, and the pivot is the largest disc: it has to move at some point, and at the first moment it moves, the other discs are on one peg and not on either of the two the largest disc occupies, since none of them may sit on top of it or under it in the destination. Reaching that position costs at least , the move itself costs one, and rebuilding the stack afterwards costs at least again.
Proof.
There are no discs to move when , so .
Let . For the upper bound, carry out the following. Move the top discs from the source peg to the spare peg, which is possible in moves and remains legal with the largest disc left in place, since that disc is larger than all of them and lies at the bottom of the source peg. Move the largest disc to the target peg: one move. Move the discs from the spare peg onto the target peg, again moves, legal because they all land on the largest disc. That is moves in all, so .
For the lower bound, take any legal sequence of moves carrying the stack from the source to the target. The largest disc must move at least once. Consider the first move that lifts it. Just before that move the other discs lie neither on the peg it leaves nor on the peg it arrives at: not the first, because they are all smaller and would have to be above it; not the second, because it may not land on a smaller disc. So all of them are stacked on the remaining peg, and getting them there from the source peg took at least moves. After the largest disc has reached the target for the last time, the discs must be brought from that third peg onto it, which takes at least moves more, and the moves of the largest disc themselves account for at least one. Hence .
Closed Forms
Computing from the recurrence means computing through first. What we want instead is a function with for every , evaluable on its own. The sequence sits one below the powers of two, which is enough to make a guess.
Proposition 2.2 (Closed form for the Tower of Hanoi).
For every we have .
Discussion.
The recurrence defines from , so a claim about all is proved by induction, and the induction has exactly the shape of the recurrence: one base case at , and a step that rewrites as , replaces by the inductive hypothesis, and simplifies. Nothing has to be discovered during the proof; the formula was guessed from the first few terms, and induction only certifies it.
Proof.
For we have and .
Suppose for some . By the recurrence,
which is the claim at .
Induction certifies a formula but does not produce one, and guessing from a handful of terms is not a method. Two techniques that do produce the formula follow.
Unrolling. Apply the recurrence to itself repeatedly and watch what accumulates:
The pattern is
and one more application confirms that it reproduces itself:
which is the same expression with in place of . Since the case is the recurrence itself, the displayed identity holds for every with by induction on . Taking leaves in terms of a value we know,
Remark (The geometric sum).
The step from to is worth doing once. Writing and doubling gives , so , that is . The same trick evaluates as for any .
Substitution. Rather than solve the recurrence, change the unknown so that the recurrence becomes one we can already solve. Adding to both sides of gives
so if we set then and for . That recurrence doubles at every step, so , and therefore .
Show that in the strategy of the proof of the Hanoi recurrence every disc moves at least once, and that the smallest disc moves on every second move.
Suppose the three pegs are arranged in a row and a disc may only be moved between adjacent pegs, so that a move from the left peg to the right peg is forbidden. Let be the least number of moves needed to transfer a stack of discs from the left peg to the right peg. Find a recurrence for and solve it.
Lines in the Plane
Here is a second problem of the same shape. What is the largest number of regions into which straight lines can cut the plane?
With no lines there is one region, so . One line cuts the plane in two however it is drawn, so . Two lines do best when they are not parallel, giving . At this point invites the guess , and the guess fails at once: a third line meets the two existing ones in at most two points, which divide it into at most three pieces, and each piece splits one old region in two. So the third line adds at most three regions and , not .
Proposition 2.3 (The line recurrence).
For every ,
and .
Discussion.
Again the equality splits into two inequalities about the th line added to already drawn. For the upper bound, the new line gains exactly as many regions as the number of old regions it passes through, and it passes through one more region than the number of points at which it meets the old lines. Two distinct lines meet in at most one point, so the new line meets old lines in at most points and gains at most regions. For the lower bound we must place the new line so that both estimates are attained: not parallel to any old line, which forces it to meet each of them, and not through any existing intersection point, which keeps the meeting points distinct. Only finitely many directions and finitely many points have to be avoided, so such a line exists.
Proof.
With no lines drawn the plane is a single region, so .
Let and suppose lines have been drawn. Adding a line increases the number of regions by exactly the number of old regions that passes through, since each such region is cut into two and no other region is touched. The old lines meet in some set of points, and those points cut into one more piece than there are points, with each piece lying in one old region. Two distinct lines meet in at most one point, so meets the old lines in at most points and therefore passes through at most old regions. Hence .
For the reverse, take lines realising regions. The old lines have directions and finitely many pairwise intersection points, so we may choose parallel to none of them and passing through none of those points. Then meets every old line, in distinct points, so it passes through exactly old regions and adds new ones. Hence .
Unrolling this recurrence gives
using the sum of the first positive integers.
Prove by induction that for every .
Prove that for every , by pairing the first term with the last, the second with the second-last, and so on.
What is the largest number of regions into which lines can cut the plane if all lines are required to pass through a common point?
A zig is a bent line, made of two rays issuing from a common point. Find and solve a recurrence for the largest number of regions into which zigs can cut the plane.
Linear Recurrences
Guessing and unrolling both depend on the recurrence being simple enough to see through. A large family of recurrences can be solved by a recipe that needs no insight at all, and this section develops it.
How many ways are there to climb a staircase of steps, if each stride goes up either one step or two? For four steps there are five ways:
There is one way to climb no steps, namely to do nothing, and one way to climb one step. For any ascent begins with either a stride of one, leaving an ascent of steps, or a stride of two, leaving an ascent of ; the two cases are exclusive and exhaust the possibilities. Writing for the number of ascents of steps,
This is the Fibonacci recurrence, introduced in 1202 to model rabbit populations and unsolved in closed form for nearly six centuries. We use rather than from here on, since the argument will shortly be something other than an integer.
Definition 2.4 (Linear recurrence).
A homogeneous linear recurrence of order is one of the form
where are constants with . Values of prescribed at finitely many points are its boundary conditions. Adding a further term on the right, where is a fixed function, gives an inhomogeneous linear recurrence.
The Fibonacci recurrence has order with , and the boundary conditions .
Theorem 2.5 (Solutions form a linear space).
Let and both satisfy the homogeneous linear recurrence with coefficients . Then for all the function satisfies it too.
Discussion.
The recurrence is an identity that must hold at every , so the proof evaluates the right-hand side of the recurrence at and pushes it back to . Two facts do all the work, and both are about arithmetic rather than about recurrences: the right-hand side is a sum of terms each of which is a constant times a value of the function, so it distributes over the combination ; and the hypotheses on and let each of the two resulting sums collapse to and . Regrouping the terms is the whole argument, and it is why the solution set behaves like a plane through the origin rather than a scattered collection.
Proof.
Let . Using the definition of , then the hypotheses on and ,
Linear recurrences tend to have exponential solutions, so we look for one of the form and let the recurrence decide which will serve. Substituting into gives , and dividing by , which is legitimate since does not satisfy the boundary conditions, leaves
Its roots are
so and both satisfy the recurrence, and by the theorem above so does for every and . Two constants are exactly what two boundary conditions can pin down.
Definition 2.6 (Characteristic equation).
The characteristic equation of the homogeneous linear recurrence is
obtained by substituting and dividing by . Its coefficients are read straight off the recurrence.
Theorem 2.7 (Binet's formula).
Let satisfy and for . Then for every ,
Discussion.
The two exponentials and satisfy the recurrence because and solve the characteristic equation, and the previous theorem then makes every combination a solution as well. What remains is to choose and so that the combination also meets the two boundary conditions, and each condition is one linear equation in the two unknowns. Solving the pair is routine once one notices that and , which is what turns the answer into a single difference of powers. Since the recurrence and the two boundary conditions determine at every point, a function meeting all three is the function.
Proof.
Both and satisfy , so multiplying by shows that and satisfy the recurrence; by the previous theorem so does for any reals .
The boundary conditions require and , that is
Substituting into the second gives . Now and , so ; and then , since . Therefore
The recurrence together with the values at and determines for every , and satisfies all three, so .
Remark (Integers out of square roots).
Every value of is a whole number, yet the formula is built entirely from ; the irrational parts cancel at every . Since the second term is smaller than in absolute value at every , so is the nearest integer to throughout. For instance , and . The same estimate shows that consecutive values have ratio tending to , the golden ratio.
Example 2.8 (A recurrence of order two).
Let , and for . The characteristic equation is , that is , with roots and . So , and the boundary conditions give and , whence and . Therefore .
When the characteristic equation has a repeated root, the powers of that root alone do not supply enough independent solutions, and the missing ones carry a factor of .
Proposition 2.9 (Repeated roots).
Let be a root of multiplicity at least of the characteristic equation of a homogeneous linear recurrence. Then satisfies the recurrence.
Discussion.
Saying that is a root of multiplicity at least two means that the characteristic polynomial and its derivative both vanish at , and the factor of in the claimed solution is exactly what a derivative produces from a power. So the proof multiplies the characteristic polynomial by to obtain a polynomial whose vanishing at is the statement that solves the recurrence, differentiates it, and multiplies by ; the result, evaluated at , is precisely the statement that solves the recurrence. The hypothesis is what lets the multiplicity survive the multiplication by .
Proof.
Write for the characteristic polynomial and fix . Put
Since is a root of of multiplicity at least , it is a root of of multiplicity at least , so and . Differentiating,
and multiplying by ,
Evaluating at and using gives
which says exactly that satisfies the recurrence.
More generally, a root of multiplicity contributes the solutions , , , up to , and a recurrence of order is solved by taking a linear combination of the solutions collected in this way from all the roots. If the characteristic equation of an order-four recurrence has roots , and twice, the general solution is
and four boundary conditions give four linear equations in .
Inhomogeneous Recurrences
The Hanoi recurrence is not homogeneous: the extra is a term on the right. Such recurrences are solved in five steps.
- Delete and find the roots of the characteristic equation of what is left.
- Write down the general solution of that homogeneous recurrence, leaving its constants undetermined. This is the homogeneous solution.
- Restore and find any one function satisfying the full recurrence, ignoring the boundary conditions. This is a particular solution.
- Add the two. This is the general solution.
- Use the boundary conditions to fix the constants.
Example 2.10 (Hanoi with heavy discs).
Suppose moving a disc costs its size in seconds, so that moving the th disc takes seconds rather than one. The total time obeys
Deleting the leaves , whose characteristic equation is , so the homogeneous solution is .
For a particular solution, is a polynomial of degree one, so try . Substituting,
which holds for every exactly when and . So is a particular solution and the general solution is .
The boundary condition gives , so and
Against for the original puzzle, the heavy discs cost roughly twice as long.
Remark (Guessing a particular solution).
Finding a particular solution is the one step that involves a guess, and the guess is usually shaped like itself.
If is constant, try ; if that fails, try , then , and so on. If is a polynomial, try a polynomial of the same degree first and then of higher degree. If is an exponential such as , try , then , and so on. A guess fails when substituting it leaves an equation with no constant solution, and raising the degree by one is then the next move.
Solve , , for . (The characteristic equation has a repeated root.)
Solve and for .
Let be a root of multiplicity at least of the characteristic equation of a homogeneous linear recurrence, with . Prove that satisfies the recurrence.
How many ways are there to climb stairs if a stride may go up one, two or three steps? Write down the recurrence, its characteristic equation, and compute the number of ways for .
Let satisfy the Fibonacci recurrence with . Prove that is the nearest integer to for every .
The Josephus Problem
Flavius Josephus, a first-century historian, was said to have been trapped in a cave with forty-one other rebels who preferred death to capture and agreed to stand in a circle and kill every third man. Josephus worked out where to stand.
The version we take is this. Number people to around a circle and go round eliminating every second person until one is left. Which number survives? Call it .
Proposition 2.11 (The Josephus recurrence).
For every ,
and .
Discussion.
One person survives trivially. For the rest, the point is that after one lap of the circle exactly the even-numbered people have gone, and what is left is a circle of half the size with the same rule about to be applied to it. So the problem of size reduces to the problem of size , and all that is needed is the dictionary between the numbering of the survivors and their original numbers. The two cases differ only in where the second lap starts. If is even the lap ends by killing person and the next to die is the second of the survivors; if is odd the lap ends by killing person , then person dies immediately, and the survivors start from person . Reading off the th survivor’s original number in each case, and , converts into .
Proof.
With one person there is nobody to eliminate, so .
Suppose with . Going round once eliminates and leaves the odd-numbered people , with the next elimination falling on the second of them. So what remains is the same problem for people, counted from , and the th of those people carries the original number . The survivor is the th of them, so its original number is .
Suppose instead with . Going round once eliminates ; the count then passes from to , which is eliminated next. That leaves the people , with the next elimination falling on the second of them. Again this is the problem for people, and the th of them carries the original number . The survivor is therefore numbered .
Tabulating the first sixteen values, grouped by powers of two, makes the pattern plain:
Each block begins at when reaches a power of two and climbs through the odd numbers. That suggests measuring from the power of two below it.
Theorem 2.12 (Closed form for the Josephus problem).
Let and write where is the largest power of two with , so that and . Then
Discussion.
The recurrence takes to , so the proof is an induction in which the inductive hypothesis is applied at a smaller value rather than at the immediate predecessor; strong induction on is what fits. Everything then turns on how the decomposition behaves under halving. If is even then is even too, since and , and halving gives with the remainder still in range. If is odd then is odd, and , again in range. In both cases the hypothesis supplies the survivor for the halved circle, and the two clauses of the recurrence turn it into ; the arithmetic works out to the same answer either way, which is why the formula has no cases in it.
Proof.
We induct on , assuming the claim for all smaller values.
If then and , and .
Let and write with ; since we have .
Suppose is even, say . Then is even, and
so the decomposition of has exponent and remainder . As , the inductive hypothesis gives , and the recurrence gives
Suppose instead is odd, say with . Then is odd, and
the upper bound because forces and hence . The inductive hypothesis gives , and the recurrence gives
Reading the Answer in Binary
The decomposition is exactly what binary notation records. Writing
with leading digit , the remainder is , so and
Since the leading digit that was dropped is a , the answer is obtained from by moving its leading digit to the end: a one-bit cyclic shift to the left.
Example 2.13 (A cyclic shift).
Take . Shifting the leading digit round to the end gives , so . Checking against the closed form, , so and .
Remark (Iterating the shift).
Applying repeatedly does not cycle back to after shifts, because always, and once a value drops it can never climb again. What happens instead is that whenever the leading digit is a it is simply dropped, so each application deletes a zero. After enough applications only the ones remain, and the value settles at
where is the number of ones in the binary representation of . For instance , and .
Proposition 2.14 (When the survivor is halfway round).
Let with . Then if and only if is odd and .
Discussion.
Substituting the closed form turns the condition into a linear equation in and , and solving it gives outright, so the only question left is for which that number is an integer lying below . The bound is immediate. Integrality is a statement about modulo , and the powers of two alternate between and there, since doubling exchanges the two; so is divisible by exactly for odd .
Proof.
By the closed form, says , that is , that is
This satisfies automatically. It is an integer exactly when . Now leaves remainder , and doubling a number that leaves remainder gives one that leaves remainder , while doubling a number that leaves remainder gives , which leaves remainder . So the remainders alternate as , and exactly when is odd.
The first few such are
These are the for which shifting the leading bit to the end has the same effect as deleting the last bit.
The Repertoire Method
Guessing worked for the Josephus recurrence because its answers were small numbers with a visible pattern. When a guess is not available, the following method manufactures one. Consider the recurrence with three undetermined constants,
of which the Josephus recurrence is the case , , . Its first few values are
Every entry is a combination of , and with coefficients depending only on , so we may write
and the task becomes finding the three functions , , . The method is to substitute values of , or functions , for which the recurrence can be solved by inspection; each substitution yields one equation relating , and , and three independent equations determine them.
Proposition 2.15 (The coefficient of ).
Let with . Then .
Discussion.
Setting and makes equal to and collapses the recurrence to with in both the even and the odd case. That recurrence doubles once per halving and never distinguishes the two cases, so it depends on only through how often can be halved, which is . The induction is the same strong induction as before, using that has exponent in its own decomposition.
Proof.
Putting and gives and
We induct on . For we have and . For write with , and put . As in the proof of the closed form for , the decomposition of has exponent , whichever parity has. Both clauses of the recurrence give , and the inductive hypothesis gives , so .
Two more substitutions finish the job, and this time we choose the function rather than the constants.
Take for every . The three clauses become , and , so this constant function is the solution for , . Substituting those values into gives
Take . The clauses become , and , so this is the solution for , , , and
Now solve. From and we get ; and then .
Theorem 2.16 (Solution of the generalised Josephus recurrence).
Let be constants and let satisfy the recurrence above. Then for with ,
Discussion.
The repertoire method produced this formula but did not prove it, since it assumed at the outset that is a combination of , and with coefficients independent of them. That assumption is easy to justify after the fact: the right-hand side is a specific function of , so it is enough to check that it satisfies the three clauses of the recurrence, and a solution of the recurrence is unique because the clauses determine from and is given. The verification is the same case split on the parity of used twice already, with the decomposition of read off as before.
Proof.
Write for . Since the clauses determine from for and fix , at most one function satisfies them; so it suffices to check that does.
At we have and .
Let , so and is even, and with . Then
which is .
Let , so and is odd, and with . Then
which is again.
Setting , , recovers , the Josephus answer.
Radix Notation
The generalised recurrence has a shorter description if the two constants added at each step are indexed by the bit that decides between them. Write and ; then the three clauses become
and is the last binary digit of . Unrolling the second clause strips one digit at a time:
The right-hand side has the shape of a binary expansion whose digits are the constants rather than and , so we write it
meaning that each entry is multiplied by the appropriate power of two and the results added. Recovering the earlier table is a matter of reading off digits: gives , and gives .
Example 2.17 (The Josephus survivor for ).
With , and , and ,
agreeing with the cyclic shift .
Nothing in the argument used the base or the multiplier separately, and separating them gives the general statement.
Theorem 2.18 (Recurrences that strip a digit).
Let and be constants, let and be constants, and let satisfy
Then for with ,
Discussion.
The second clause consumes exactly one base- digit of its argument, because writing with is the same as splitting off the last digit and leaving . So each application of the clause peels a digit and multiplies what has accumulated by , and after applications the argument has been reduced to its leading digit , which lies between and and is therefore covered by the first clause. The proof is an induction on the number of digits, and the only thing to check carefully is that the split of into really does correspond to the split of the digit string, which is where the uniqueness of base- representation is used.
Proof.
We induct on , the number of digits after the leading one.
If then with , and the first clause gives , which is the claim.
Let and write , that is
Setting and , we have with and . The second clause and the inductive hypothesis applied to , which has digits after its leading one, give
and expanding the bracket is the claim at .
Representation in a Base
The theorem above took for granted that has a base- digit string and that the string is determined by . Both facts need proof, and the tools are the floor function and the remainder.
Definition 2.19 (Floor, ceiling and remainder).
For ,
For and the remainder of on division by is
Rearranging the last definition gives the identity we shall use repeatedly: for and ,
Example 2.20 (Floors and remainders).
and . For the remainder,
Theorem 2.21 (Representation in a base).
Let with . Every with can be written as
and the digits are uniquely determined by .
Discussion.
There are two claims, and they are proved by different means.
Existence is an induction on the number of digits , and the step is division by . Given below , split it as with the last digit and what remains. The point to check is that falls in the range the inductive hypothesis covers, namely below , and it does because dividing by shrinks the bound by a factor of . The hypothesis then supplies digits for , and multiplying the whole expansion by shifts every digit up one place, leaving room at the bottom for .
Uniqueness is an argument by contradiction that needs no induction. Suppose two different digit strings give the same value, and look at the highest place where they disagree. Above the terms are equal and cancel, so the difference of the two sums is a single term , which is at least , plus lower terms, each of which is at least . Summing those lower bounds telescopes to , so the total is at least ; but the total is . The heart of it is that one unit in a place outweighs everything below it, which is what makes positional notation work at all.
Proof.
Existence. We induct on .
For the only in range is , represented by the empty sum.
Suppose every with has a representation with digits, and let . Put
We check that lies in the range covered by the hypothesis. From we get , and , so ; being an integer, . Also . So the hypothesis applies and gives digits in with . Then
where the third step reindexed the sum by and the last set for , with as chosen. Every digit lies in , and there are of them, which is the claim for .
Uniqueness. Suppose
with all digits in , and suppose the two strings are not identical. Let
and assume without loss of generality that . All terms with agree and cancel, so subtracting one sum from the other leaves
Now bound the two pieces from below. The digits are integers with , so and the first term is at least . For we have and , so and
the last step because the two sums share every term with . Adding the two bounds,
which is false. So no two distinct digit strings represent the same .
Corollary 2.22 (Radix notation).
Let . For a digit string with entries in write
Then every is for exactly one digit string with leading digit , and its length is .
Proof.
Let and put , so that and hence . The theorem applies with this and gives digits , unique for this length. The leading digit is not zero: if then , contradicting .
Conversely, suppose for some length with . Then , and also . So , which forces , and the theorem then makes the digits the ones already found.
Remark (Horner's scheme).
Evaluating by computing each power and multiplying costs about multiplications. Nesting the expression,
evaluates it from the inside out with multiplications and additions, and never forms a power of explicitly. This is Horner’s scheme, and the same nesting evaluates any polynomial at any point.
Compute two ways, from the closed form and from the cyclic shift, and check that they agree.
Show that if and only if for some .
For which does person survive? Show that person never survives, whatever may be.
Use the repertoire method to solve
Write for the number of ones in the binary representation of . Prove that repeated application of to any eventually reaches and stays there.
Let and . Show that the last digits of in base are the digits of , padded with leading zeros if need be.
Sums
A recurrence adds one term to what came before, so every recurrence of the form is a sum in disguise and every sum is such a recurrence. This chapter sets up the notation for sums, establishes the laws that let them be rearranged, and turns the correspondence with recurrences into a method that evaluates sums the previous chapter could not touch.
Sequences
A sequence of elements of a set is a function . The value is the th term and is written , and the sequence itself is written
The function and the list of its values are the same object seen two ways. Defining by is the same as writing , and the same again as writing out
A sequence in this sense is infinite, since its domain is, and it is countably infinite: the terms can be laid out in a list indexed by with no term left out.
Definition 2.24 (Countably infinite).
A set is countably infinite if there is a bijection , and we then write .
Removing finitely many elements from leaves a countably infinite set, so the index set of a sequence need not be itself; any countably infinite set of indices will do, and the terms can then be listed in the order that a bijection with supplies.
Example 2.25 (Indexing by another set).
The even numbers are countably infinite, since is a bijection . So is a sequence, with terms listed in that order.
A formula may exclude some indices of its own accord. For
the denominator vanishes at and , so the sequence is the function , and its index set is again countably infinite.
Definition 2.26 (Finite sequence).
A finite sequence of elements of is a function with finite. When is a non-empty set of natural numbers we take and call the length, writing . For the function is empty and is the empty sequence, written .
Sigma Notation
Let be a sequence of real numbers. For we write
Each appearing is a term, the expression after the is the summand, and is the index of summation, which is bound to the and has no meaning outside it.
The notation says: include exactly those terms whose index is an integer between the lower and upper limits, inclusive. That reading has a delimited form and a general form, and the two are interchangeable:
More generally, one or more conditions written under the specify which indices take part. The sum of the squares of the odd positive integers below is
whose delimited form is harder to read; and the sum of the reciprocals of the primes up to is
whose delimited form needs a function counting the primes before it can even be written down.
The general form also survives a change of index more transparently. Replacing by turns
where the substitution can be made without thought, while in delimited form the same change reads
and the limits have to be recomputed by hand.
Definition 2.28 (Summation over a property).
Let be a statement about integers which is true or false for each , and suppose only finitely many with true have . Then
If is false for every the sum is empty, and its value is .
Example 2.29 (Reading a condition).
Let be the property ” and is odd”. Then
so
Dropping the parity condition gives and . Taking the summand to be instead gives
Remark (Keeping limits simple).
Terms equal to zero do no harm, and excluding them usually costs more than it saves. In
the terms at , and all vanish, and one is tempted to write instead. That form is worse: it is harder to manipulate, and its meaning is unclear when or . Simple limits are worth more than a short list of terms.
Remark (Two conventions for empty sums).
An empty sum is , which fixes the value of when :
In particular and . With this convention the splitting rules hold without exception: for every ,
the second reading correctly at as .
Iverson Brackets
Kenneth Iverson introduced a device that removes conditions from beneath the altogether.
Definition 2.30 (Iverson bracket).
For a statement that is either true or false, write
A term multiplied by a bracket that evaluates to is taken to be even when the other factor is undefined.
With brackets, a sum over a condition becomes a sum over all integers,
since the terms failing contribute nothing. The index may then be manipulated freely, with no boundary conditions to fuss over. The reciprocals of the primes up to become
and the term at is rather than a division by zero, by the convention in the definition.
Proposition 2.31 (Laws of summation).
Let be a finite set of integers, let and be sequences of reals, and let . Then
- ;
- ;
- for every bijection .
Discussion.
Each law is a property of addition of reals lifted to a finite list of terms, so each is proved by induction on the size of , peeling off one element at a time. The first is distributivity, the second is associativity and commutativity used together to interleave two lists, and the third is commutativity alone: reordering the terms of a finite sum does not change it, and a bijection of the index set with itself is exactly a reordering. The third is the one that needs the index set to be finite, since rearranging infinitely many terms can change a sum.
Proof.
We induct on . If all three sums are empty and every claim reads .
Let be non-empty, pick and write , so that for any sequence .
For the first law, , using the inductive hypothesis and then distributivity in .
For the second, by the hypothesis, and regrouping the four terms by commutativity and associativity gives .
For the third, let be a bijection and let be arbitrary. Then restricts to a bijection , and splitting both sums so that the term is taken first reduces the claim to the same statement on a set with one fewer element.
The laws above all concern a single index set. Two different index sets combine as well.
Proposition 2.32 (Combining index sets).
Let and be finite sets of integers. Then
Discussion.
Counting elements suggests the shape of the answer, since : an element of both sets is counted twice on each side. Iverson brackets turn that count into a proof, because they replace membership by a number that can be added. The identity to establish is then for each single , which is checked by looking at the four possible cases; summing it over all and using the law for sums of sequences gives the claim.
Proof.
Fix an integer and compare the two sides of
If lies in both sets, both sides are . If it lies in exactly one, both sides are , the right-hand side because the intersection bracket is and the union bracket is . If it lies in neither, both sides are .
Multiplying by and summing over all integers , the second law of summation gives
and each of the four sums is the corresponding sum over its index set.
Show that and for all statements and , and use the first of these to write
as a sum over all integers with no condition beneath the sign.
Geometric Sums
Definition 2.33 (Geometric sequence).
A sequence of reals is geometric with ratio if for every , equivalently if for every .
Proposition 2.34 (Geometric sum).
Let and . Then
Discussion.
Multiplying the sum by shifts every term one place along, so the product and the original share all their terms but two: the original has where the product has nothing, and the product has where the original has nothing. Subtracting therefore cancels everything in the middle and leaves those two terms, which is a linear equation for the sum. The hypothesis is what allows the division at the end, and it is needed: at every term is and the sum is .
Proof.
Write . By the first law of summation,
Every term of with exponent between and appears in as well, so subtracting leaves only the extremes:
Since we may divide by .
With and ,
Starting the sum at removes the term , so
which is what one expects: halving repeatedly closes all but the last gap.
Sums and Recurrences
Writing and splitting off the last term gives , so a sum is a recurrence and the methods of the previous chapter apply to it. The correspondence runs both ways, and this section uses it in each direction.
Proposition 2.36 (A sum is a recurrence).
Let be a sequence of reals and put . Then is the unique function with
and conversely any function satisfying those two conditions is given by that sum.
Discussion.
Both halves come from the splitting rule for sums, which is where the convention that an empty sum is earns its place: it makes come out as with no separate argument. For the forward direction, split the last term off the sum defining . For the converse, the two conditions determine the value at every from the value below it, so at most one function satisfies them, and the sum has just been shown to be one.
Proof.
At the sum has the single term , so . For , splitting off the term at gives
Conversely, suppose satisfies and for . Then , and if then . By induction .
Used from left to right, this turns a sum into a recurrence to be solved by the techniques already available. The repertoire method of the previous chapter applies without change, and the recurrence to feed it is the general first-order one with a linear term.
Theorem 2.37 (A linear sum-recurrence).
Let and let satisfy
Then
Discussion.
Computing , and shows every value to be a combination whose coefficients do not depend on the three constants, so the repertoire method applies: choose functions that satisfy the recurrence for some values of , and read off one equation in , , from each. The constant function forces and gives outright; the function forces , and gives ; and the function forces , , which involves and together and so needs the previous two results to finish. Three substitutions give three equations, and the system is triangular.
Proof.
Write , which the first few values show to be the right shape, and determine the coefficients by substitution. Each substitution takes a function , asks which make it satisfy the recurrence, and then reads the displayed identity at those values.
Take . Then forces , and the recurrence reads , that is for every , which forces . Substituting gives
Take . Then forces , and the recurrence reads , that is for every , which forces and . Substituting gives
Take . Then , and the recurrence reads , that is
for every , which forces and . Substituting gives
Assembling, . Finally this function does satisfy the recurrence, as substituting it into confirms, and the recurrence with its boundary condition has only one solution.
Example 2.38 (Summing an arithmetic progression).
Let and . By the correspondence above, and , which is the recurrence of the theorem with , and . Hence
The same answer comes out of the summation laws directly: splitting the summand and pulling out the constants,
since a sum of copies of is . The repertoire method earns its keep on recurrences that are not sums of anything recognisable.
The Summation Factor
Used from right to left, the correspondence turns a recurrence into a sum. A recurrence of the form is immediately a sum, so the problem is to bring a given recurrence into that shape, and multiplying through by a well-chosen factor does it.
Theorem 2.39 (Summation factor).
Let , , be sequences of reals with and for every , and let satisfy
with given. Put and
Then for every , and
Discussion.
The obstruction to reading the recurrence as a sum is that and carry different coefficients. Multiplying the whole equation by a factor removes the obstruction provided the new coefficient of , namely , equals the coefficient that had at the previous step, namely ; that condition is a recurrence for itself, and unrolling it gives the stated product. With the factor in hand, satisfies , which the previous proposition evaluates as a sum. Dividing by at the end is legitimate because both factors are non-zero, which is exactly what the hypotheses on and guarantee.
Proof.
For , the definition of gives
with the case reading .
Multiply the recurrence by and set . For ,
and at the recurrence gives . So satisfies a sum-recurrence started at , and unrolling it gives
Since and , dividing by gives the stated formula.
Example 2.40 (The Tower of Hanoi again).
The recurrence has , and , so a summation factor is , which satisfies . Multiplying through,
so obeys and . That is a geometric sum,
and multiplying back by gives .
Remark (Where the factor comes from).
The condition is itself a recurrence, , and unrolling it from produces the product in the theorem. Any non-zero constant multiple of that product serves equally well, since multiplying every by the same constant leaves the condition and the final formula unchanged; in the Hanoi example the product gives and we used . The method needs every and every to be non-zero, and fails otherwise.
Definition 2.41 (Harmonic numbers).
For the th harmonic number is
so that . The name comes from music: the th harmonic of a vibrating string is the tone produced by a string times as long.
Harmonic numbers have no closed form in the sense of this chapter, and they are what a summation factor produces as soon as the coefficients of a recurrence vary with .
Example 2.42 (A recurrence with variable coefficients).
The Hanoi recurrence had constant and , so the factor was a constant power. Consider instead
with , and . The summation factor is
which agrees with . Then and , while , so the theorem gives
The remaining sum is a harmonic number in disguise. Shifting the index by one,
where the middle step dropped the term at and added the one at . Therefore
and checking at gives , which the recurrence confirms.
Use a summation factor to solve and for .
Prove that for every , and deduce that can be made as large as we please by taking large enough.
Exercises on Recurrences
Compute for the Tower of Hanoi for from the recurrence, and check each against .
Suppose a fourth peg is added to the Tower of Hanoi. Give a strategy for discs using the extra peg, count its moves, and compare the count with for .
Solve each recurrence by unrolling, then confirm the answer by induction.
- and for ;
- and for ;
- and for , as far as a sum in closed form allows.
Solve , for by the substitution , choosing so that the recurrence for has no constant term.
What is the largest number of regions into which circles can cut the plane? Find the recurrence and solve it.
What is the largest number of pieces into which planes can cut three-dimensional space? Argue that the answer satisfies , where is the count for lines in the plane, and solve.
For each recurrence, write down the characteristic equation, find its roots, and give the solution meeting the stated boundary conditions.
- , , ;
- , , ;
- , , , .
Solve and for .
Let satisfy the Fibonacci recurrence with . Prove that .
Compute for and check that the values run through the odd numbers below and then restart at .
Suppose the circle is counted in the other direction, so that the first person eliminated is the one before the leader rather than after. Work out the survivor for and find a recurrence.
Use the repertoire method on , , , taking and as two of the substitutions.
Convert to base , base and base , and check each answer by Horner’s scheme.
Let and . Show that and have the same number of base- digits unless is a power of , and use this to count how many numbers have exactly digits in base .
Show that when and otherwise, and that for every .
Exercises on Sums
Some of the regions cut out by lines in the plane are bounded and the rest are not. What is the largest possible number of bounded regions?
Let , with the Josephus survivor. The recurrence for gives and
for every . It therefore looks possible to prove for all by induction. Compute , and , and say exactly what is wrong with the argument.
Let and define , and
assuming and are such that no denominator ever vanishes. Compute and prove that for every .
Evaluate
as a function of and , taking care over the values of for which the sum is empty.
Prove the rule for summation by parts: for every ,
Use only the distributive, associative and commutative laws of summation together with a shift of the index.
Find a closed form for
Use a summation factor to solve
and check your answer at and .
Evaluate by writing the recurrence it satisfies and solving it, and check the answer for .
Show that , first by unrolling the corresponding recurrence and then by writing and cancelling.
Let and be finite sets of integers with . Deduce from the law for combining index sets that , and give an example showing the hypothesis is needed.
Write each of the following as a sum with the index running from , using Iverson brackets where a condition is needed.
- ;
- ;
- the sum of over those between and that are perfect squares.
Check Yourself
Fresh questions on the whole chapter — none of them is worked out above. Do each on paper first; the box only tells you whether you got there.
Answers are checked in your browser, as often as you like. Nothing is sent anywhere and
nothing is kept but your own work. A formula may be written with the symbols themselves or
with ~ & | -> <-> ^, and \and, \or, \to expand as you type.
How many moves does the Tower of Hanoi need for five discs?
What is the largest number of regions four lines can cut the plane into?
In how many ways can a staircase of five steps be climbed, one or two steps at a time?
What are the roots of the characteristic equation of ?
A root of multiplicity of the characteristic equation contributes which solutions?
To find a particular solution of , what should be tried first?
What is ?
What is ?
For which does the Josephus problem leave the last person standing, that is ?
What is in base ten?
What is ?
What is ?
How many binary digits does have?
Unrolling from , what is ?
What is ?
What is the value of ?
What is ?
What is ?
What is the harmonic number ?
Which summation factor turns into a sum?