Discrete Maths | Generating Functions-Introduction and Prerequisites

Prerequisite – Combinatorics Basics, Generalized PnC Set 1, Set 2

Definition : Generating functions are used to represent sequences efficiently by coding the terms of a sequence as coefficients of powers of a variable (say) \big x in a formal power series.

Now with the formal definition done we can take a minute to discuss why should we learn this concept.

This concept can be applied to solve many problems in mathematics. There is a huge chunk of mathematics dealing with just generating functions.

  • It can be used to solve various kinds of Counting problems easily.
  • It can be used to solve recurrence relations by translating the relation in terms of sequence to a problem about functions.
  • It can be used to prove combinatorial identities.

In simple words generating functions can be used to translate problems about sequences to problems about functions which are comparatively easy to solve using maneuvers.
From the perspective of GATE CS examination, problems from this topic is asked almost every year and the problems can easily be solved just by knowing the basics. So if you want to gain an edge it’s recommended to learn this concept.

Some basic prerequisites…

Before we start let’s go through some basic Combinatorics formula.

 %\documentclass{article} %\usepackage{amsmath}  \newcommand*{\Perm}[2]{{}^{#1}\!P_{#2}}% \newcommand*{\Comb}[2]{{}^{#1}C_{#2}}%  \begin{document}  \Huge $\Perm{n}{k}=\frac{n!}{(n-k)!}$   $\binom nk=\Comb{n}{k}=\frac{n!}{k!(n-k)!}$   \end{document}
Now let’s use some results from the extended Binomial Theorem. You may read about Binomial theorem here.

   %\documentclass{article} %\usepackage{amsmath} \newcommand*{\Perm}[2]{{}^{#1}\!P_{#2}}% \newcommand*{\Comb}[2]{{}^{#1}C_{#2}}%  \begin{document}  \huge $\binom {-n}k=(-1)^r\frac{(n+k-1)!}{k!(n-1)!}=(-1)^r\binom{n+k-1}k$    \end{document}

The above formula implies choosing -n elements from r elements. Now wait, it sounds absurd right? How can you choose negative quantity of elements from some positive set. Well, mathematically it makes sense, moreover it’s in accordance with the extended Binomial Theorem. We may also choose a fraction of elements from a set.

We use this formula to extract coefficient in such series:

  %\documentclass{article} %\usepackage{mathtools}   \begin{document}\bigg  \(\frac{1} {(x+a)^n}\)=(-1)^r\sum_{n=0}^{\infty} \binom{-n}{r}.x^r.a^{-n-k}=(-1)^r\sum_{n=0}^{\infty}\binom{n+r-1}{r}.x^r.a^{-n-k}  \end{document}

For example: Try finding the coefficient of

 %\documentclass{article} %\usepackage{mathtools}   \begin{document}\Large  [x^6]x^3.\(\frac{1} {(1-x)}\)   \end{document}

The above formula will come handy later on, so please try to remember this. I will try to add problems related to counting which will make the concept more clear on the usage of this.

Formally, a generating function is a power series. We look at an infinite sequence as a single function which encodes the series. The generating function for the sequence   $g_0, g_1, g_2, g_3.... of real numbers is the infinite series:
   %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \huge  \func G(x) = g_0+{g_1}x+{g_2}x..... = \sum_{k=0}^\infty g_k x^k.  \end{document}

The pattern is simple, the kth term in the sequence is coefficient of xi in the generating function.

For Example :  $[x^9] \func f(x) = a_9.$

Note: the notation  $[x^n] \func f(x)$  is used to represent the coefficient of xn in the function f(x).

Some Important sequences and their results…

If you want to know more about the derivation of the given sequences you may refer here

  %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \Large  \(\frac{1} {(1-x)}\) = 1 + x + x^2 + x^3.... \longleftrightarrow [1, 1, 1, 1...\normalsize\infty]  \end{document}

  %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \Large  \(\frac{1} {(1+x)}\)=1-x+x^2-x^3.... \longleftrightarrow [1, -1, 1, -1....\normalsize\infty]  \end{document}

   %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \Large  \(\frac{1} {(1-ax)}\) = 1 - ax + {a^2}x^2 - {a^3}x^3.... \longleftrightarrow [1, a, a^2, a^3....\normalsize\infty]   \end{document}

   %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \huge  %\(\frac{1} {(1-ax)}\) = 1 - ax + {a^2}x^2 - {a^3}x^3.... \longleftrightarrow [1, a, a^2, a^...\infty] \(\frac{1} {(1-ax)}\) = 1 + x^2 + x^4.... \longleftrightarrow [1, 0, 1, 0...\normalsize\infty]  \end{document}

Note that all the above series is infinite. There is one peculiar result of finite series which will be very handy so it’s recommended to remember these results to solve problems quickly.

An important result:

   %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \LARGE  %\(\frac{1} {(1-ax)}\) = 1 - ax + {a^2}x^2 - {a^3}x^3.... \longleftrightarrow [1, a, a^2, a^.....]  1+x+x^2+x^3+....+x^n = \(\frac{1 + x^{n+1}} {(1-x)}\) \end{document}

Now consider this Example:
What sequence is represented by the following series :
 %\documentclass{article} %\usepackage{amsmath}  \begin{document}  \Large  1 + 4x^2 + x^4 + \frac{x^5}{999} + 100x^6 + \cdots\text{?} \end{document}

By now you must have got this, the coefficient of a0 = 1, a1 = 0, a2 = 4, a3 = 0, a4 = 1, a5 = 1/999, a6 = 100.
So sequence is:
   \Large $ [1, 0, 4, 0, 1, \(\frac{1} {999}\), 100, ....] $

So, with this done, from the next post we may start with some interesting Counting Problems and solve them with this approach. We will also see some previous GATE problems.
Next we’ll see some problems based on counting and some problems based on coefficient extraction.


Kenneth H Rosen: Discrete Mathematics and Its Applications 6th [Chapter 2.4, 6.4]

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Recommended Posts:

5 Average Difficulty : 5/5.0
Based on 1 vote(s)