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)
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.
Some basic prerequisites…
Before we start let’s go through some basic Combinatorics formula.
![Rendered by QuickLaTeX.com %\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}](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-0c9982554703efdddf3d0a0fcbbaf1d2_l3.png)
A generating function is a “formal” power series in the sense that we usually regard x as a placeholder rather than a number. Only in rare cases will we actually evaluate a generating function by letting x take a real number value, so we generally ignore the issue of convergence.
of real numbers is the infinite series:

![]()
Note: we’ll indicate the correspondence between a sequence and its generating function with a double-sided arrow.
Some Important sequences and their results…

If you want to know more about the derivation of the given sequences you may refer here
![]()
![]()
![]()
![]()
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:
![Rendered by QuickLaTeX.com %\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}](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-1367515f211235512cba0e0ffe2fc60a_l3.png)
- Operation on generating Functions:
- Scaling
- Addition
- Right Shift
- Differentiation
We can use these operations to get new sequences from known sequences, and new generating functions from known generating functions.
Scaling:
Multiplying a generating function by a constant scales every term in the associated sequence by the same constant.
![Rendered by QuickLaTeX.com \textup{Scaling Rule} \newline[f_{0},f_{1},f_{2},f_{3}...]\leftrightarrow F(x) \newline [cf_{0},cf_{1},cf_{2},cf_{3}...]\leftrightarrow cF(x) \\](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-1572f0cd4de0f6555a142b551c513bef_l3.png)
Addition:
Adding generating functions corresponds to adding the two sequences term by term.
![Rendered by QuickLaTeX.com \newline[f_{0},f_{1},f_{2},f_{3},f_{4}..]\leftrightarrow F(x) \newline [g_{0},g_{1},g_{2},g_{3},g_{4}..]\leftrightarrow G(x)\newline \textup{Then}\newline [f_{0}+g_{0},f_{1}+g_{1},f_{2}+g_{2},f_{3}+g_{3},...]\leftrightarrow F(x)+G(x)](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-bd099e88810b9d9e5889e5c4532ebdd5_l3.png)
Right Shifting:
![Rendered by QuickLaTeX.com \textup{Right Shifting Rule} \newline \textup{if}\hspace{0.25cm} [f_{0},f_{1},f_{2},f_{3}...]\leftrightarrow F(x) \newline \textup{then}\hspace{0.25cm} [\overbrace{\overset{\textup{k times}}{0,0,0,0,0,0} },f_{0},f_{1},f_{1}...]\leftrightarrow x^{k}F(x)](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-b8d2c9c72b1e9ef8962e7ea2ea99b3a7_l3.png)
Differentiation:
In general, differentiating a generating function has two effects on the corresponding sequence: each term is multiplied by its index and the entire sequence is shifted left one place.
![Rendered by QuickLaTeX.com \textup{Derivative Rule:} \newline [f_{0},f_{1},f_{2},f_{3}...] \leftrightarrow F(x) \newline [f_{1},2f_{2},3f_{3},4f_{4}...] \leftrightarrow F{}'(x)](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-eb998398b111c89b2c640b24246bdb3c_l3.png)
![Rendered by QuickLaTeX.com \newline \textup{Example:} \newline 1+x+x^{2}+x^{3}+x^{4}+x^{5}... = \frac{1}{1-x} \newline \frac{\mathrm{d} }{\mathrm{d} x}(1+x+x^{2}+x^{3}+x^{4}...)=\frac{\mathrm{d} }{\mathrm{d} x}(\frac{1}{1-x}) \newline 1+2x+3x^{2}+4x^{3}....=\frac{1}{(1-x)^{^{2}}} \newline [1,2,3,4...]=\frac{1}{(1-x)^{2}}](https://web.archive.org/web/20190820135105im_/https://www.geeksforgeeks.org/wp-content/ql-cache/quicklatex.com-e80c2957bac621142d7cc7f54646e13f_l3.png)
Example:
What sequence is represented by the following series :
![]()
SolutionBy 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:
![]()
From the perspective of GATE CS examination, problems from this topic are asked almost every year and the problems can easily be solved just by knowing the basics.
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.
REFERENCES:
Kenneth H Rosen: Discrete Mathematics and Its Applications 6th [Chapter 2.4, 6.4]
Recommended Posts:
- Mathematics | Generating Functions - Set 2
- PDNF and PCNF in Discrete Mathematics
- Last Minute Notes – Discrete Mathematics
- Discrete Mathematics | Representing Relations
- Discrete Mathematics | Hasse Diagrams
- Theory of Computation | Generating regular expression from finite automata
- Discrete Mathematics | Types of Recurrence Relations - Set 2
- Advantages of cracking GATE from Indian Perspective
- Different Classes of CPU Registers
- OSI, TCP/IP and Hybrid models
- Last Minute Notes Computer Organization
- Local Broadcast and Loopback Address
- Difference between Posteriori and Priori analysis
- Cascadeless in DBMS
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : VaibhavRai3




