In this post we shall talk about Generating Functions, firstly about the Fundamental Theorem of Exponential Generating Functions -giving a different approach than that given in Generatingfunctionology -, and then we will talk about some sample problems that can be solved by the use of Generating Functions.
Given a sequence:
it’s corresponding egf (exponential generating function) is:  = \sum\limits_{n \geq 0} {a_n \cdot \tfrac{{x^n }}{{n!}}})
Exponential generating functions have some interesting properties:
1. If
and
are the e.g.f. of
and
respectively, then
is the e.g.f. of 
2. If
is the e.g.f. of
then
is the e.g.f. of
, where
The proofs are left to the reader.
The second property clearly relates differential equations with difference equations, for instance, if a sequence
satisfies
for all natural numbers n, then its e.g.f. ,
, satisfies : =F'(x)+F(x))
As a prelude to the Fundamental Theorem of E.G.F.’s, we will find a recurrence relation to the number of labeled connected graphs of n vertices (the vertices are labeled 1 through n ):
Property: If
is the number of connected labeled graphs on n vertices, then 
Proof
Imagine we had n vertices labeled 1 through n+1, how many graphs can we create then ?
Clearly the answer is
, since for every pair of vertices, the edge may or may not exist.
Now let’s count it in a different way. Consider the vertex labeled n+1, this vertex must belong to some connected component. How many graphs are there such that the connected component to which n+1 belongs has k+1 vertices? – Well, the answer goes as follows, first we have to choose k numbers from {1..n} to be the labels of the rest of the vertices of the connected component, that can be done in:
ways. Now, given our k+1 vertices, we have
possible connected graphs
and further, there are
possible labeled graphs for the vertices outside the connected component of n+1. Hence we have
graphs in which the component in which the vertex labeled n+1 contains k+1 vertices! now sum over all the possible values of k and we are done! 
Now, let’s dig deeper and generalise the previous proof. Suppose we have a set of connected structures that have an associated label set, let
be the number of labeled connected structures with label set {1,…,n} ( say they have to be of size n ) and define
to be the number of possible combinations of the previous structures such that their label sets for a partition of {1,…,n} , then we have:
Theorem: 
The proof is left to the reader since it turns out to be analogous to that of the connected labeled graphs.
Corollary: Let
and
be the exponential generating functions of
and
respectively, then =\exp(D(x)))
Proof
The theorem above translates into:
by the properties about the generating functions we saw above. Solving this differential equation yields the result 
Now let’s see an application of this result:
Application: Every permutation can be written uniquely as a composition of disjoint cycles .
Proof
First, it’s clear that if a permutation can be written as a composition of disjoint cycles, this must be unique up to the order of the compositions. So it remains to prove that every permutation can be seen as a composition of disjoint cycles.
The number labeled cyclic permutations ( with label set {1, …, n} ) turns out to be
(for n>0). This corresponds to
in the theorem above. Hence  = \sum\limits_{n = 1}^\infty {\tfrac{{\left( {n - 1} \right)!}}{{n!}}\cdot x^n } = \log \left( {\tfrac{1}{{1 - x}}} \right))
Thus:
that is 
Now what is
? Yes!, it’s the number of permutations of {1, …, n} that can be written as a composition of disjoint cycles. 
Let’s generalise even further what we have done so far, let
be the number of combinations of k connected structures such that there label sets form a partition of {1,…,n}. Then we have:
Fundamental Theorem of E.G.F.’s : }}{{n!}} \cdot x^n \cdot y^k } = \mathcal{H}\left( {x,y} \right) = \exp \left( {y \cdot D\left( x \right)} \right))
Proof
Note that:
( the coefficient of
in
).
We shall see that:
, the rest of the proof after that is fairly simple.
Think it this way, suppose we had k boxes, first we distribute our n labels -or numbered balls- into those k boxes in such a way that we have
balls in the first box and so on… This can be done in
ways
Now in box number i we have
possible connected structures to build. Hence, after distributing the balls, we can build the connected structures in the boxes in
ways.
Hence we have
ways of doing that with the balls, and considering all the possible distributions of the balls we have:
ways.
But note that the difference between this and
is that now we do care about the order of the k structures! 
Practice: Define
to be the number of permutations of {1,…,n} made out of exactly k dijsoint cycles , then show that
and conclude:  \cdot y^k } = \left( {y + n - 1} \right) \cdot ... \cdot y)
Up to this point, all you’ve read in this entry was written in 2009. One year later – almost- I am resuming writing it!
Problem (IMO 2008 ~ problem 5) :
Let
and
be positive integers with
and
an even number. Let
lamps labelled
be given, each of which can be either on or off. Initially all the lamps are off.
We consider sequences of steps: at each step one of the lamps is switched (from on to off or from off to on). Let
be the number of such sequences consisting of k steps and resulting in the state where lamps 1 through
are all on, and lamps
through
are all off.
Let
be the number of such sequences consisting of
steps, resulting in the state where lamps 1 through
are all on, and lamps
through
are all off, but where none of the lamps
through
is ever switched on.
Determine the ratio
.
Solution
First observe that a lamp will end up on if and only if it is switched an odd number of times. So the lamps that we want to be off will be switched an even number of times while the others, an odd number of times.
Now, in our sequence we care about the order but not about the relative order of 2 switches of the same lamp -because they are indistinguishible, this immediately implies that we will use exponential generating functions.
Let
be the e.g.f of the number of sequences in which we may switch the lamps from n+1 to 2n. (labeled by number of switches)
Then:
here each factor correspons to a lamp, note that in the first n lamps we only consider odd powers (hence sinh( x) ) while in the rest we consider even powers (hence cosh(x )).
Thus: %20=%20\left(%20\sinh(x)%20\cdot%20\cosh(x)%20\right)^n%20=%20\left(\frac{\sinh(2x)}{2}\right)^n)
Now consider
to be the e.g.f. for the case in which we never switch on a lamp from n+1 through 2n, then clearly
.
Hence
and so
thus we have:
when
is even – because we necessarily have
greater than 0.