Knuth: Volume 1: Fundamental Algorithms
Chapter 1: Basic Concepts: Generating Functions
You absolutely, positively must read the preceding chapters to follow Knuth here. There are a number of subtle steps that he moves through quite fast, about as quickly as he moves through the other material, except he's now integrating his method of presenting all 8 prior sections, including both explicit and passing references to prior material.
As with the binomial coefficients...
Knuth AOCP Section 1.2.9 Exercise 1
Exercise 1. What is the generating function for ?
For this problem, don't be fooled by the complexity of the preceding section - it's back to the basics. This sequence of numbers looks a lot like, oh, I dunno, two sequences of numbers added together. Specifically,
2 4 8 16 32 3 9 27 81 243
If we can find the generating function for 2^n, and find the generating function for 3^n, we can use the addition property of generating functions to combine them.
To find the generating function for :
Now subtracting the first and last quantities gives:
which yields the generating function for :
Repeating the process for gives:
Now to get the overall generating function for we add these two functions together and combine into a single rational expression:
Now for the cool part. If we do a Taylor Series expansion of , we can compute simply by obtaining the coefficient of the Taylor Series polynomial. While this may seem like a pointless mathematical trick for a function like , the real utility of the method comes when we apply this approach to much more general functions.
If we evaluate the 500th term of the Taylor Series expansion, which we can denote , we get:
which, in case you did not already notice, is
The Art of Computer Programmingnotes from reading Donald Knuth's Art of Computer Programming
Part of the 2017 CS Study Plan.
Volume 2: Seminumerical Algorithms
Volume 3: Sorting and Searching
Flags · Template:AOCPFlag · e