- Learn
- Mathematics
- University Math
- Discrete Mathematics
- Recurrence Relations
Recurrence Relations and Generating Functions
IntermediateLesson 8 of 10 in Discrete Mathematics Course
What you will learn
- Describe a sequence by a recurrence relation and initial conditions, compute and solve simple recurrences by iteration, and build recurrences that count strings, tilings, regions and other structures.
- Compute and solve simple recurrencesRead a recurrence relation with its initial conditions, compute terms, check a proposed solution, find a closed form by iteration and prove it by induction.
- Build recurrences that countSet up a recurrence for a counting problem by splitting the objects of size n into cases built from smaller objects, find the initial conditions, and check the result on small cases.
- Compute and solve simple recurrences
- Find closed forms for linear recurrences with constant coefficients: homogeneous ones with distinct or repeated characteristic roots, and nonhomogeneous ones by adding a particular solution.
- Solve homogeneous recurrences with distinct rootsRecognize a linear homogeneous recurrence with constant coefficients, form its characteristic equation and solve it when the characteristic roots are distinct.
- Solve recurrences with repeated rootsWrite the general solution when a characteristic root is repeated, fit it to initial conditions, and combine roots of any multiplicity.
- Solve nonhomogeneous recurrencesSolve a linear recurrence with an added term F(n) by combining a particular solution with the general solution of the associated homogeneous recurrence, then fitting the initial conditions.
- Solve homogeneous recurrences with distinct roots
- Write recurrences for algorithms that split a problem into smaller copies of itself, solve them exactly for powers of the split factor, and estimate their growth with the master theorem.
- Set up and unroll divide-and-conquer recurrencesTurn a divide-and-conquer algorithm into a recurrence of the form f(n) = a f(n/b) + g(n) and solve it exactly when n is a power of b.
- Estimate growth with the master theoremApply the master theorem to recurrences of the form f(n) = a f(n/b) + c n^d, explain its three cases, and recognize recurrences it does not cover.
- Set up and unroll divide-and-conquer recurrences
- Encode sequences as generating functions, manipulate them algebraically, use them to count selections with restrictions, and use them to solve recurrences.
- Build and manipulate generating functionsWrite the generating function of a sequence, use the standard series and the extended binomial theorem, and add, multiply, shift and differentiate generating functions.
- Count selections with generating functionsModel selections and distributions with restrictions as products of generating functions, read the answer as a coefficient, and prove counting identities.
- Solve recurrences with generating functionsTurn a recurrence into an equation for its generating function, solve that equation, and recover a closed form with partial fractions.
- Build and manipulate generating functions
- Count the elements of a union of overlapping sets, and use inclusion–exclusion to count bounded solutions, primes, onto functions and derangements.
- Apply inclusion–exclusion to overlapping setsState and use inclusion–exclusion for two, three and n sets, explain why it counts each element once, and use its complement form.
- Solve classic problems with inclusion–exclusionUse inclusion–exclusion to count bounded integer solutions, primes and integers coprime to n, onto functions and derangements.
- Apply inclusion–exclusion to overlapping sets
Recurrence Relations study guide
1Model and solve recurrence rules
Recurrences describe a large object or a later stage through smaller ones. The starting values and index range are part of the model, just as much as the rule itself. You will compute terms, turn repeated substitution into a closed form, and justify that formula by induction. Then you will build rules from strings, tilings, line arrangements and parenthesizations by identifying what can be removed from an object without losing its structure.
1.1 From earlier terms to a formula
A recurrence relation describes a term using earlier terms. Initial conditions start the sequence, and the index range tells you when the rule takes over. For example, for with gives . Here the starting index is 0; the first application of the rule produces the term at index 1.
Read and check the rule
A recurrence using the previous two terms needs two starting values. For , knowing only leaves undetermined. Once both are given, compute forward in order, keeping the earlier values available.
A proposed formula must satisfy the recurrence and the initial conditions. The formula satisfies this rule because . A constant sequence also satisfies it. Initial values select one sequence from this family. By contrast, substituting gives on the right, so it fails the recurrence even if a few starting values seem promising.
A closed form gives a term directly from its index. Adding 3 at each of the first steps gives . For a geometric recurrence , each step supplies one more factor of , so . A population starting at 1000 and growing by 5% per hour has ; after 30 hours this is about 4322. The growth factor is 1.05, because the old population remains as well as the 5% increase.
Initial indices also affect a geometric closed form. If and for , reaching index takes updates from the known value. Thus , not . Count the updates from the stated starting index before choosing the exponent.
Unroll a recurrence
In the Tower of Hanoi, move the top disks to the spare peg, move the largest disk, then place the smaller stack on it. With one disk requiring one move, the count satisfies for and . A larger disk may never rest on a smaller disk. Before the largest disk's first move the smaller stack must be on the spare peg; after its last move the smaller stack must be rebuilt on top. These two smaller tasks also give the lower bound that makes the plan optimal.
Repeated substitution, called iteration, gives
After substitutions, . This geometric sum is . Thus 3 disks require 7 moves, while 64 require moves.
Prove the pattern
Matching early terms suggests a formula; induction establishes it for every allowed index. The base case is . Assume . Substitution gives , completing the step. Keep the base case aligned with the recurrence's range: a rule beginning at cannot be used to create the missing starting value at .
Key Takeaways
- Initial values and the recurrence range determine where computation begins.
- A closed form must satisfy both the recurrence and its initial conditions.
- Iteration exposes sums or products; induction proves the resulting formula.
- The optimal Hanoi count is .
1.2 Count objects by their final choice
To build a counting recurrence, define exactly what counts. Split the objects of size into cases that cover every object without overlap. Removing a final piece should leave a smaller object of the same kind. Count the smallest cases separately before trusting the rule.
Strings and tilings
Let count bit strings of length with no consecutive 0s. Strings ending in 1 come from any valid string of length . For length at least 2, strings ending in 0 must end in “10”; removing that suffix leaves any valid string of length . Thus for . The initial counts are and , from “01”, “10” and “11”. The next counts are 5, 8 and 13.
For a board tiled with dominoes, inspect the left end. One vertical domino leaves width ; two horizontal dominoes leave width . Hence for , with . The empty board has one tiling: using no dominoes. This gives and . Ordered climbs using steps of size 1 or 2 have the same final-step split.
The Fibonacci numbers satisfy , and . The tiling count is , while the bit-string count is . A shared recurrence does not force identical sequences: compare the initial values and index shifts.
Use a complement inside a case
Let count strings of decimal digits with an even number of 0s, allowing leading zeros. A final nonzero digit gives strings. A final 0 needs a prefix with an odd number of 0s. Of the prefixes, exactly have that property. Therefore for , with . It gives and . Directly, only the 18 two-digit strings with exactly one 0 are excluded from 100.
Add regions or combine two groups
For lines with no parallels and no triple intersection, the new line meets the previous lines at distinct points. These cut it into pieces, each adding one region. Thus , , so . The first counts are 1, 2, 4, 7 and 11. The position conditions ensure every new piece adds a region.
For full parenthesizations of factors, the final multiplication splits the expression into two groups. If the left side contains factors, there are choices for the two sides. Summing over the possible split positions gives , . For four factors, the final split can put one, two or three factors on the left. These cases contribute , and , giving . A fixed split permits independent choices on each side; different split positions are then added. The Catalan numbers begin and have closed form . Here the product of earlier terms makes the recurrence nonlinear.
Key Takeaways
- Define the objects, split them into disjoint complete cases, and count the smallest cases directly.
- The empty object often has count 1.
- Identical recurrence rules can produce shifted sequences with different initial values.
- A complement can count prefixes that have the opposite property.
- Catalan recurrences multiply counts for independently chosen left and right groups.
2Solve constant-coefficient recurrences
Linear recurrences with constant coefficients turn sequence problems into polynomial equations. The roots determine the building blocks of a solution, while the initial values determine their coefficients. Distinct roots, repeated roots and added terms each need a different solution form. The worked calculations show how to select that form, fit its constants, and check a later term against the original recurrence.
2.1 Use distinct characteristic roots
A linear homogeneous recurrence with constant coefficients has the form , with . “Linear” means earlier terms appear to the first power and are not multiplied together. “Homogeneous” means there is no added term depending only on . The coefficients stay fixed, and the degree is the largest lag.
| Rule | Classification |
|---|---|
| Linear homogeneous, constant coefficients, degree 5; the largest lag determines the degree. | |
| Linear homogeneous, but the coefficient changes with the index. | |
| Nonlinear, because an earlier term is squared. | |
| Linear with constant coefficients, but nonhomogeneous because of the added 1. |
Turn the rule into a polynomial
Try . Divide the substituted equation by to get the characteristic equation
The nonzero last coefficient ensures 0 is not a root. For , moving the terms to the left gives , with roots 2 and 3. Track the signs when moving terms; the minus sign on the earlier sequence term becomes a plus in this polynomial.
If the degree- equation has distinct roots, every solution is . A constant multiple or sum of solutions still satisfies the homogeneous recurrence. The initial values determine the constants.
The linearity explains why root solutions can be combined. If and each satisfy the homogeneous rule, set . Substituting gives . Fixed coefficients let the constants pass through the sum, so the combined sequence also satisfies the rule.
Fit the initial conditions
Solve for , with and . The equation gives . The initial values yield and . Adding gives , so and . Therefore . At index 2, the recurrence gives and the formula gives .
Higher degree uses the same steps. For , the polynomial factors as . From , , , solve , and . Subtracting successive equations gives and , so , and . The result is . For a monic integer polynomial, integer roots must divide its constant term. In this cubic, test . Substituting 1 gives , so divide by to obtain . Factoring that quadratic supplies the other two roots. Finding one root lowers the remaining factoring problem by one degree.
Irrational and complex roots
Fibonacci's polynomial has roots and . With and , the constants give . Indeed, gives , so the family becomes . Then gives , fixing . The irrational terms combine to give integers. Since , its contribution shrinks as the index grows.
Complex roots work too. For , the roots are and . Initial values and give , the real period-4 sequence . Use the actual starting indices when fitting constants; two initial values labeled 1 and 2 must be substituted at those indices.
Key Takeaways
- Check linearity, homogeneity, constant coefficients and degree before using characteristic roots.
- With distinct roots, use one constant times for each root.
- Fit constants at the given initial indices and check one later term.
- Characteristic roots can be irrational or complex even when sequence values are real integers.
2.2 Include powers of the index for repeated roots
A repeated characteristic root needs more than one exponential term. Writing only gives , so it contains one effective constant. A second-order recurrence generally needs two constants to meet its two initial values.
A double root
When the characteristic polynomial is , the general solution is . The independent building blocks are and . To see why the second works, the repeated-root polynomial has coefficients and . Substitution gives
This verifies the extra building block directly; the factor supplies the additional freedom.
For , , and , the polynomial is . Write . At index 0, . At index 1, , so . The closed form is . The next term checks: , and .
Trying only would force from the first value but from the second. That conflict concerns the incomplete solution form, not the consistency of the recurrence. Include the missing term before fitting the data.
Higher multiplicities and mixed roots
A root of multiplicity contributes
The polynomial stops at degree . Sum these contributions over the distinct roots. Their multiplicities add to the recurrence degree, so the solution has exactly that many independent constants.
For roots 2 of multiplicity 3, −1 of multiplicity 1, and 5 of multiplicity 2, use
There are six constants and six initial values. The simple root −1 needs no index factor; the triple root 2 needs three powers, from through . Repetition means multiplicity in the factored polynomial, not that a sequence happens to repeat its values.
The solving order is unchanged: determine the degree, factor the characteristic polynomial, record every multiplicity, write all building blocks, and then substitute the initial values. A later-term check is especially useful when the terms have similar forms. This homogeneous solution also provides the freely adjustable part when an added forcing term is present.
Key Takeaways
- A root of multiplicity contributes .
- Two copies of the same exponential collapse into one effective constant.
- The number of independent constants equals the total root multiplicity.
2.3 Add a particular solution before fitting constants
An added term changes the problem: is nonhomogeneous when is not identically zero. Dropping that term gives the associated homogeneous recurrence. Its solution supplies the adjustable constants; one particular solution supplies the response to the added term.
Separate the two parts
Every solution has the form , where is the general homogeneous solution and is any one particular solution. Subtracting two nonhomogeneous solutions cancels , leaving a homogeneous solution. This explains why one particular solution is enough.
Find , choose and solve for , add them, and only then impose the initial conditions. Fitting the homogeneous part first usually fixes the wrong constants, because the particular part also contributes to the starting values.
Choose a trial form
If , with a degree- polynomial, try with every coefficient of unknown. If is a characteristic root of multiplicity , multiply the whole trial by . A pure polynomial uses ; check whether 1 is a root before selecting its trial. A term such as does not have this form.
For , , , the homogeneous part is . Since 1 is not a root, set . Substitution gives . Matching the coefficients of gives , so . Constants give , so . Now . From , obtain . The formula gives , agreeing with .
For , roots 2 and 3 do not include 7. Try . Divide the substituted equation by to obtain , hence . The full family is .
Resolve a root collision
For , , , the trial is already homogeneous and cancels out of the left-minus-right calculation. Use . Dividing the substituted equation by gives , hence . Adding and applying yields .
A double collision needs two index powers. For , the polynomial gives trial . Move the earlier terms left and divide by to get . The expression in parentheses is 2, so . The full family is . A trial with only would still be homogeneous and cancel completely.
Likewise has root 1. Use ; coefficient matching gives . With , the answer is . For Hanoi, the constant trial satisfies , so ; adding the homogeneous part recovers . An impossible coefficient equation is a reason to check for a root collision before abandoning the method.
Key Takeaways
- Every solution is a particular solution plus the general homogeneous solution.
- For polynomial times forcing, use the same polynomial degree in the trial.
- If has characteristic multiplicity , multiply the trial by .
- Fit the initial conditions to the full sum, including the particular solution.
- An index-dependent coefficient of an earlier term is not a forcing term.
3Count work in recursive algorithms
Divide-and-conquer recurrences track algorithms that solve smaller copies of a task. A count of recursive calls, a size reduction and the work outside those calls together define the model. You will sum the work across levels to find exact costs at powers of the split factor, then use the master theorem to identify growth bounds. Keeping exact counts separate from bounds matters especially in comparison-counting examples.
3.1 Unroll equal-size recursive tasks
A divide-and-conquer algorithm solves smaller versions of the same task and combines their answers. If it solves subproblems of size and uses extra work , its recurrence is . Count the subproblems actually solved, and state the base size and its cost.
Read the algorithm into the rule
Binary search divides a sorted list into halves but continues in only one half. A model using two comparisons per stage is : here . Merge sort solves both halves. Merging items takes at most comparisons, so its worst-case count is with .
Finding both the maximum and minimum can use two half-size tasks, then compare the two maxima and the two minima. Its rule is with . The terminal size matters: a two-item list needs one comparison to find both extremes. For powers of 2 this yields , including . To see the formula, stop the recursion at size 2: there are terminal pairs, each costing one comparison. The internal levels contain tasks in all, each costing two comparisons. Their total is . Finding the maximum first and then the minimum among the remaining entries instead uses comparisons at size 8.
Karatsuba multiplication replaces four half-size products with three, plus linear extra work: . Strassen's matrix multiplication uses seven half-size products and quadratic extra work, modeled here as . The number of recursive calls and the cost outside them are different parts of each rule.
Keep each level's full cost
Assume and base size 1. After one substitution, . After substitutions,
There are calls at level , which explains the multiplier in the sum. The leaves contribute . For constant extra cost and , this is . For , sum the geometric series to get .
For merge sort, level costs . Summing for gives . Thus , and . Replacing by gives the simpler bound with the same zero base cost, not the exact comparison count.
Change the size variable
Set . Then and , a constant-coefficient recurrence in . Its solution becomes the same exact formula after substituting . Exact formulas here use powers of the split factor. Other sizes need floors or ceilings for integer subproblem sizes; an increasing cost allows growth bounds to extend between neighboring powers.
Key Takeaways
- Count recursive calls actually solved: binary search has one, merge sort has two.
- Unrolling includes both level costs and the terminal calls.
- For powers of 2, merge sort uses comparisons in the worst case.
- A change of variable turns shrinking sizes into successive indices.
- The terminal size and its cost affect an exact formula.
3.2 Compare the work across recursion levels
The master theorem gives growth bounds without evaluating every level of a divide-and-conquer recurrence. Big-O means an eventual upper bound up to a constant factor: if for all sufficiently large and some fixed . It does not give an exact count.
State and select the case
Use the polynomial-cost form for an increasing function satisfying at powers , with , integer , and . Compare with :
| Comparison | Growth bound |
|---|---|
The constant changes the amount of work without changing the case. A constant extra cost has , so the comparison uses . The logarithm base does not affect a big-O bound because changing its base multiplies it by a constant.
Explain the three outcomes
At level , there are tasks of size . Their extra work totals . If the ratio is below 1, the costs shrink and a geometric sum is bounded by a constant times the top cost. If the ratio is 1, every level costs and there are such levels. If the ratio exceeds 1, lower levels dominate; the number of leaves is .
For , compare 2 with to get . With four calls the bound becomes . With eight calls it becomes . Comparing the call count with alone would miss this distinction.
For a ratio , the internal-level sum is at most : the finite geometric sum is bounded by the corresponding infinite sum. The leaf count has a smaller exponent than , so it fits the same upper bound. When , the sum is for . Multiplying its largest scale by gives , matching the leaf scale. These sums explain why a fixed number of large bottom levels controls the growing-ratio case.
Apply and interpret the result
Merge sort's bound has equal level costs and gives . Binary search's model uses and gives . The maximum-and-minimum rule instead has , giving .
Karatsuba's three half-size products plus linear work give , about . Strassen's seven half-size products plus quadratic work give , about . The exponent uses the split factor as logarithm base; reversing it changes the answer.
Check the form before applying it
This polynomial-cost version does not cover , unequal splits such as , or shrinking by subtraction as in . The first has a nonpolynomial extra cost, the second has unequal task sizes, and the third does not divide size by a fixed factor. Unrolling can still work when this theorem does not. In the equality case, it also gives the exact power-of- formula .
Key Takeaways
- For polynomial extra cost, compare with .
- Equal level costs produce the logarithmic factor.
- Growing level costs produce the exponent .
- Check the theorem conditions before selecting a case.
- Big-O describes a growth bound; exact costs require the base condition and unrolling.
- The coefficient of the extra cost does not change the case.
4Use generating functions
A generating function places an entire sequence inside one algebraic expression. Coefficients carry the counts, and exponents keep track of size. The same algebra can combine independent choices, enforce restrictions or gather a recurrence into one equation. You will learn standard series, use products to model selections, and recover closed forms through shifts and partial fractions, with initial values entering through missing terms.
4.1 Store a sequence in a power series
The ordinary generating function of is . The exponent records the index, while its coefficient records the term. Write for coefficient extraction. Here is a placeholder in a formal power series; the coefficient calculations do not require assigning it a numerical value.
Recognize useful series
The geometric identity gives and . Replacing by −1 gives . Replacing by gives , with zero coefficients at other exponents. A finite string of six 1s has polynomial .
As numerical functions, the geometric series converge for , or in the scaled case. Formal algebra keeps these coefficient identities separate from questions about numerical convergence. Evaluating gives a weighted sum of terms; it does not select one coefficient.
Add, multiply and shift
Adding two generating functions adds coefficients at matching powers. Multiplying uses convolution:
For example, . The coefficient 2 at comes from and . It is not obtained by multiplying just the two coefficients already at index 2.
Multiplication by shifts every term places right and inserts initial zeros. Thus represents . Substitution instead multiplies the coefficient at index by . Differentiation gives ; multiplying by restores the indices, so . For , differentiation gives , whose coefficients are . Multiplying by shifts this sequence once, so represents . For example, its coefficient at is 4; the derivative alone has coefficient 5 there.
Extend the binomial theorem
For real and integer , define and . This falling-product definition works when the upper entry is negative. For instance, . The extended theorem is , numerically valid for .
For positive integer , . Substituting cancels the signs and yields
With the coefficient is . With , the coefficient at index 10 is . Keep index and coefficient distinct: the exponent 10 identifies which entry is requested, while 66 is that entry's value.
Key Takeaways
- An ordinary generating function stores sequence terms as coefficients.
- Products use convolution; multiplication by shifts indices.
- In , the coefficient at index is .
- The coefficient of in is for positive integer .
- Negative upper entries in binomial coefficients use the falling-product definition.
4.2 Turn allowed choices into factors
For an unordered selection from distinguishable kinds, make one generating-function factor per kind. Its exponents are the allowed contributions to the total. Multiplication chooses one term from every factor, adds the exponents, and records how many choices produce each total. Coefficients count the choices; the powers record their size.
Translate restrictions literally
An unlimited number of one kind gives . At least one gives ; at most one gives . At most gives . An even number gives . Include the constant 1 exactly when choosing zero is allowed.
For solutions of with , and , the product is
Factor out the minimum contributions, whose sum is 9. The product becomes . The target is now . Expand only the short numerator: . Using the standard coefficients of gives . The term with cannot contribute to because the denominator series has no negative powers.
A direct check uses the maximum total 18: total 17 is one below it, giving , and . The algebra handles the upper bounds through the numerator while the denominator counts unrestricted remaining contributions.
Remove minimums before expanding
Sharing 8 identical items among three people, with each receiving between 2 and 4, gives . Extracting now means extracting from the remaining cube. Choose a single exponent 2 in three ways, or two exponents 1 in three ways, giving 6. The removed minimums change the target exponent from 8 to 2.
With four fruit kinds and no limits, selecting six pieces gives . If the kinds have different values, put those values in the exponents: unlimited coins worth 1, 2 and 5 units give . To make total 10, use zero 5-unit coins in six ways, one in three ways, or two in one way, for 10 selections.
Decide whether order matters
A factor per kind counts how many of each kind, not their arrangement. For parts of size 1 or 2 totaling 4, the product counts three unordered selections. Ordered lists include “112”, “121” and “211” separately. For a list of length , use ; summing over gives , whose coefficient is 5. The difference is in the combinatorial model, not in whether the generating function is ordinary.
The sum over list lengths is valid as a formal series: each part has positive size, so only lengths can contribute to a target . Even though the series has infinitely many list lengths, a particular coefficient uses only finitely many of them. A zero-size part would change this reasoning by allowing arbitrarily many positions without increasing the total; it is not present in this model.
Compare coefficients to prove an identity
From , compare coefficients of . On the left it is . On the right convolution gives . For the sum is . Equality of the series forces equality of the coefficients at every index.
Key Takeaways
- Use one factor per kind, with exponents equal to its allowed contributions.
- Minimum amounts shift the target coefficient; maximum amounts make factors finite.
- Weighted kinds contribute powers matching their sizes or values.
- One factor per kind counts unordered selections; ordered lists need a different model.
- Comparing coefficients of equal series proves counting identities.
- The constant term represents choosing none of a kind.
4.3 Convert a recurrence into one algebraic equation
A generating function collects every recurrence equation into one series equation. Initial values enter through the terms missing at the beginning of each sum. After solving for the series, standard expansions recover the sequence.
Match the summation range
Let . For , , , multiply by and sum over . The left side is and the right is . Thus and .
For a second-order recurrence beginning at , the left sum is . The first shifted sum is , while the second is . To derive the first shift, put : . For the second, starts at 0, giving . Writing the changed lower limit before simplifying keeps these corrections visible.
Solve and split into standard fractions
Take , , with and . Summing gives
Collecting the terms containing yields , so .
For partial fractions, write . Clearing denominators gives . At , , so ; at , , so . Expand each geometric series to obtain . The recurrence gives , agreeing with .
Read roots in the denominator
The polynomial reverses the coefficients of . Its factors and correspond to roots 2 and 3. A repeated factor has expansion , so its coefficients contain a linear factor in the index. This is the generating-function form of repeated characteristic roots. For Fibonacci, and give after summing from 2. Thus . Its numerator has no constant term because the sequence begins at zero; the coefficient of is one.
Include an added term
For decimal strings with an even number of 0s, and . Summing the extra term gives . Hence . Solving and decomposing produces
Therefore . This method incorporates the forcing without guessing a particular solution. Before expanding any rational function, check its constant term against ; a mismatch often reveals a missing initial-term subtraction.
Key Takeaways
- Sum only over the indices where the recurrence holds.
- Shifted sums require the correct missing initial terms to be subtracted.
- Partial fractions convert rational functions into standard series.
- Factors correspond to characteristic roots .
- The generating-function equation can include forcing and initial values together.
5Count overlapping restrictions
Overlapping groups need more care than simply adding their sizes. Inclusion–exclusion corrects repeated membership by alternating counts of intersections. You will see why every included object ends up counted once, then choose useful unwanted properties for bounded distributions, divisibility, onto functions and permutations. Each application depends on describing what an intersection allows the remaining objects to do.
5.1 Correct overlap one intersection at a time
Adding set sizes overcounts objects that belong to more than one set. Inclusion–exclusion corrects each overlap, with alternating signs as the number of intersected sets increases. The union counts membership in at least one set; a complement counts membership in none.
Two and three sets
For finite sets, . An element in both sets was counted twice, so subtract it once. Disjoint sets have empty intersection and the expression reduces to the sum rule.
Among integers from 1 through 1000, there are multiples of 7 and multiples of 11. The 12 multiples of 77 occur in both groups. Thus integers are divisible by 7 or 11.
For three sets, use
An element in all three sets is added three times, then subtracted in all three pairs. Add it back once. Pair intersections include those triple members; they do not mean membership in exactly two sets.
For divisibility by 3, 5 or 7 among 1 through 1000, the single counts are 333, 200 and 142. The pair counts are 66, 47 and 28, using multiples of 15, 21 and 35. The triple count is 9. The union has members. Therefore are divisible by none of these three numbers.
Use least common multiples
A number divisible by both 4 and 6 is a multiple of 12, their least common multiple. Using the product 24 misses common multiples such as 12 and 36. For positive integers 1 through , a divisibility intersection by numbers has size . Products work for distinct primes because those primes have no shared factors.
Extend and justify the pattern
For sets, sum every nonempty intersection. An intersection of sets has sign : singles positive, pairs negative, triples positive. There are intersection terms. If an element belongs to exactly sets, its net count is
The binomial identity proves this after the index-0 term is moved across. Elements outside all sets contribute 0.
To count objects with none of several unwanted properties, start with the universe size and subtract the union. Equivalently, begin with , subtract single-property counts, add pair-property counts, and continue alternating. Label what each intersection means before doing arithmetic; a correct calculation of a union still answers the wrong question if “none” was requested.
Key Takeaways
- Add single sets, subtract pair intersections, and add triple intersections.
- Pair intersections include elements in further sets.
- Divisibility intersections use least common multiples.
- Count “none” by subtracting the union from the universe.
- The alternating binomial sum makes each included element count exactly once.
5.2 Choose the unwanted properties
Inclusion–exclusion becomes a modeling tool when each set represents a specific unwanted property. Begin with an easy total, count intersections of violations, and alternate the corrections. The main work is finding the size of each intersection.
Bounded integer solutions
Count nonnegative solutions of with upper bounds 3, 4 and 6. Without upper bounds there are . Violations begin at , and . Shifting a violating variable down by its threshold leaves totals 7, 6 or 4, so the single violation counts are , and .
For simultaneous violations, subtract both thresholds from the total. Thresholds 4 and 5 leave 2, giving ; thresholds 4 and 7 leave 0, giving . Thresholds 5 and 7 exceed 11, so that intersection is empty. The triple is empty too. The count is . A violation starts one above an allowed upper bound, and a negative remaining total contributes zero.
Sieve and coprime counts
Every composite integer at most 100 has a prime factor at most . Exclude multiples of 2, 3, 5 and 7 from integers 2 through 100. The single counts are 50, 33, 20 and 14, totaling 117. Pair intersections use divisors 6, 10, 14, 15, 21 and 35; their counts are 16, 10, 7, 6, 4 and 2, totaling 45. The triple divisors 30, 42, 70 and 105 give counts 3, 2, 1 and 0. The fourfold divisor 210 contributes zero. Inclusion–exclusion therefore gives survivors. These are primes larger than 7; restore 2, 3, 5 and 7 themselves to obtain 25 primes up to 100. Starting from 1 through 100 would also leave 1, which is not prime.
Integers coprime to share no prime factor with it. For , exclude multiples of 2, 3 and 5 from 1 through 60. The count is . Factoring the inclusion–exclusion expression gives Euler's function , with one factor per distinct prime divisor.
Onto functions
For functions from an -element domain onto an -element codomain, let the bad property be “this codomain element is missed.” Missing a specified set of outputs leaves functions, and there are such output sets. For positive , the count is . From 6 elements onto 3 it is . Subtracting only the single-output omissions would overcorrect functions missing multiple outputs.
Derangements
A derangement is a permutation with no fixed element. Fixing a specified set of elements leaves permutations. Inclusion–exclusion gives . For 4 elements, . Fixing some elements permits additional fixed elements among the rest; an intersection is not an “exactly” count.
The numbers also satisfy for , with and . Choose the destination of the last element; a swap leaves a derangement of elements, and the nonswap case corresponds to one of elements. In the nonswap case, view a permutation as arrows from each element to its assigned position. If points to and points to , deleting replaces by . Since this is not a swap, , so the replacement creates no fixed point. It gives a derangement on the other elements. Conversely, in any such derangement, insert into the unique arrow ending at the chosen . These operations undo each other, justifying the contribution for each choice of . The swap case contributes because both swapped elements are removed.
The derangement counts begin . The fraction approaches ; for , is the integer nearest to .
Key Takeaways
- For upper bound , the bad property begins at .
- Impossible simultaneous violations contribute zero.
- Sieving primes removes the small sieving primes themselves, which must be restored.
- Euler’s function excludes multiples of each distinct prime divisor.
- Onto functions exclude missed outputs; derangements exclude fixed positions.
- Fixing specified positions leaves permutations.
- Derangements can be counted by an alternating sum or their own recurrence.
Recurrence Relations examples
1Build a sequence and explain its count
12 steps
- 1IntroductionA later count depends on earlier ones
A recurrence computes later terms from earlier ones. We will solve a numerical rule by repeated substitution, then build a tiling recurrence from disjoint cases. In each task, the starting values explain which sequence the rule describes.
- 2ExplanationLocate the first update
Take for , with . Successive updates give , and . The known value is at index 0, so reaching index 3 requires three updates.
- 3ExampleSubstitute before simplifying
Unroll the same rule one step at a time:
One more substitution gives . After substitutions the earlier term is the known starting value: . The added 2s have different weights because earlier additions are multiplied again at later stages.
- 4ExampleEvaluate the geometric sum
The geometric sum is . Substitute this into the unrolled expression with to get . At index 3 it gives 53, matching the computed term; induction will verify every index.
- 5ChallengeComplete the induction step
For the proposed formula , the base case gives . Assuming the formula at index , how does the recurrence produce it at index ?
---reveal---
Substitute the hypothesis: . The recurrence and base case now establish the formula for every nonnegative index.
- 6ExplanationDefine the tilings being counted
Let count tilings of a length- strip with tiles of lengths 1 and 2, with order significant. The empty strip has one tiling, so , and . At length 2 the two tilings are “1+1” and “2”.
- 7ExampleRemove the last tile
Every nonempty tiling ends in a length-1 tile or a length-2 tile. Removing the last tile leaves a strip of length or , respectively.
In each case removal is reversible: append the specified tile to any tiling of the shorter strip. This gives exactly one original tiling for each shorter tiling, so the counts are and . The cases neither overlap nor omit any allowed ending. Thus for .
- 8ChallengeUse the empty tiling
Compute the tiling counts at lengths 2, 3 and 4 from . What would be lost at length 2 if the empty tiling had count 0?
---reveal---
The updates give , and . At length 3, the three tilings are “1+1+1”, “1+2” and “2+1”. If , the length-2 update would omit the single length-2 tile, whose removal leaves an empty strip. That error would then propagate to every later count.
- 9ConnectionThe same rule can start differently
Let count bit strings without consecutive 0s. The endings “1” and “10” give the same recurrence as the tilings, but and .
Fibonacci starts with and . Comparing initial terms gives and . Shared dependence on the previous two terms identifies a family of models; it does not erase their starting values.
- 10Key InsightA split can require multiplication
A parenthesized product ends with a multiplication of a left group and a right group. For a fixed split, choose a parenthesization of each group independently and multiply their counts. Then add across split positions.
This gives , with . Unlike the tiling rule, it contains products of earlier terms. A recurrence built from valid cases need not be linear.
- 11ChallengeTest a claimed shared solution
A learner claims that the tiling counts equal the Fibonacci numbers at the same index because both use the previous-two-terms rule. How can you settle the claim and identify the correct shift?
---reveal---
Check initial values: but , so same-index equality fails. The values and agree, and the shared recurrence propagates that agreement: .
- 12RecapMatch the rule to the sequence
Compute from the initial values, unroll the rule, and prove a resulting formula by induction. To build a counting rule, remove a final piece and justify a disjoint, complete split into smaller objects. Count the smallest cases directly, including the empty object.
2Choose the right solution form
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionThe polynomial chooses the building blocks
- 2ExplanationCheck the type before solving
- 3ExampleFind the two characteristic roots
- 4ExampleUse both initial values
- 5ChallengeKeep the given starting indices
- 6ExplanationMake repeated roots independent
- 7ExampleFit a double-root solution
- 8ChallengeRead mixed multiplicities
- 9ExplanationKeep one response to the forcing
- 10ExampleFind a particular solution with no collision
- 11ExampleDetect a collision with a root
- 12ExampleSubstitute the adjusted trial
- 13ChallengeChoose the full polynomial trial
- 14TipTreat a polynomial as base one
- 15ChallengeExplain a failed initial-value fit
- 16RecapBuild the family before fitting it
3Follow work down a recursion tree
11 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionCount tasks and work separately
- 2ExampleWrite the two-call model
- 3ExampleSum internal work and leaves
- 4ChallengeMove the base size
- 5ConnectionReplace size by its exponent
- 6ExplanationRead the level-cost ratio
- 7ExampleEqual cost on every level
- 8ExplanationShrink or grow across levels
- 9ChallengeUse the tree to check the case
- 10TipCheck the exact theorem form
- 11RecapKeep exact costs and bounds distinct
4Read counts from generating functions
16 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionLet coefficients carry the counts
- 2ExplanationEncode an entire sequence
- 3ExampleMultiply choices with matching total exponents
- 4Key InsightA shift changes the requested position
- 5ExplanationUse a binomial coefficient identity
- 6ChallengeCombine a shift and a standard series
- 7ExplanationBuild factors from allowed amounts
- 8ExampleExtract a count without full expansion
- 9ChallengeRemove the minimum before counting
- 10ConnectionKeep order in the model
- 11ExplanationWrite the missing initial terms
- 12ExampleCollect the rational expression
- 13ExampleSplit into standard series
- 14ChallengeTranslate a forcing term
- 15ChallengeRecover a selection sequence from its rule
- 16RecapUse the right meaning of each power
5Remove unwanted properties without overcorrecting
14 steps
Save this lesson to follow every Walkthrough step by step.
- 1IntroductionBegin with an easy universe
- 2ExplanationTwo properties share members
- 3Key InsightTrack an element in all three sets
- 4ChallengeFinish with the complement
- 5ExplanationCount one element with many memberships
- 6ExampleTurn an upper bound into a bad property
- 7ExampleCheck whether two violations can coexist
- 8ChallengeCount an onto assignment
- 9ExplanationAvoid fixed positions
- 10ExampleSeparate specified from exactly
- 11ConnectionRemove shared prime factors
- 12TipRestore the small sieving primes
- 13ChallengeIdentify the intersection before subtracting
- 14RecapName the property before counting it
Recurrence Relations practice questions
Set 1: Read recurrence rules and counting models10 Practice Questions
Question 1 of 10
Show answerHide answer
Question 2 of 10
Show answerHide answer
Question 3 of 10
Show answerHide answer
Question 4 of 10
Show answerHide answer
Question 5 of 10
Show answerHide answer
Question 6 of 10
Show answerHide answer
Question 7 of 10
Show answerHide answer
Question 8 of 10
Show answerHide answer
Question 9 of 10
Show answerHide answer
Question 10 of 10
Show answerHide answer
Set 2: Connect roots, coefficients and restrictions10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 3: Choose a method and justify the count10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Set 4: Solve mixed recurrence and counting problems10 Practice Questions
Save this lesson to see every answer and practice every set.
Question 1 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 2 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 3 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 4 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 5 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 6 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 7 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 8 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 9 of 10
Show answerHide answer
Save this lesson to see this answer.
Question 10 of 10
Show answerHide answer
Save this lesson to see this answer.
Stuck on your own question? Homework Help
Key Terms
A
Associated homogeneous recurrence
B
Base case
Big-O bound
C
Catalan numbers
Characteristic equation
Characteristic root
Closed form
Coefficient extraction
Complement
Constant coefficients
Convolution
Coprime integers
Counting recurrence
D
Degree of a recurrence
Derangement
Disjoint cases
Divide and conquer
E
Equality case
Euler’s function
Extended binomial coefficient
Extended binomial theorem
F
Fibonacci numbers
Fixed point
Forcing term
Formal power series
G
General solution
Geometric recurrence
H
Homogeneous recurrence
I
Inclusion–exclusion
Index shift
Induction hypothesis
Initial condition
Intersection
Iteration
L
Least common multiple
Level cost
Linear recurrence
M
Master theorem
Minimum shift
Multiplicity
N
Nonhomogeneous recurrence
Nonlinear recurrence
O
Onto function
Ordered list
Ordinary generating function
P
Partial fractions
Particular solution
R
Rational generating function
Recurrence relation
Recursion level
Repeated denominator factor
Repeated root
S
Selection factor
Shifted sum
Sieve of Eratosthenes
Subproblem
U
Undetermined coefficients
Union
Unordered selection
Unrolling
V
Violation set
About this lesson
Make your own Study Materials
Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.