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.

*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.

Now let’s use some results from the extended Binomial Theorem. You may read about Binomial theorem here.

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:

For example: Try finding the coefficient of

*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 of real numbers is the infinite series:

The pattern is simple, the k^{th} term in the sequence is coefficient of x^{i} in the generating function.

**For Example :**

*Note: the notation is used to represent the coefficient of x ^{n} 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

*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:

**Now consider this Example:**

What sequence is represented by the following series :

By now you must have got this, the coefficient of a_{0} = 1, a_{1} = 0, a_{2} = 4, a_{3} = 0, a_{4} = 1, a_{5} = 1/999, a_{6} = 100.

So sequence is:

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 6^{th} [Chapter 2.4, 6.4]

## Recommended Posts:

- Introduction to Mojette transform
- Mathematics | Generating Functions - Set 2
- Discrete Mathematics | Hasse Diagrams
- Discrete Mathematics | Representing Relations
- Discrete Mathematics | Types of Recurrence Relations - Set 2
- Mathematics | Indefinite Integrals
- Digital Electronics | BCD Adder
- Converting Context Free Grammar to Chomsky Normal Form
- Mathematics | Combinatorics Basics
- Mathematics | Algebraic Structure
- GATE Cut-offs needed to get into IITs, NITs, etc
- Mathematics | Introduction and types of Relations
- Mathematics | Classes (Injective, surjective, Bijective) of Functions
- Mathematics | Set Operations (Set theory)
- Mathematics | Introduction of Set theory

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.