Generating Functions (original) (raw)

Last Updated : 3 Jun, 2026

A generating function is a way to represent a sequence of numbers using a power series. In this series, the coefficients of powers of x represent the terms of the sequence. Generating functions make it easier to solve problems related to sequences, counting, and recurrence relations.

The general form of a generating function is shown below,

s_no_2

Basic Prerequisites

Before learning generating functions, we need to understand some basic combinatorics concepts.

**1. Permutation: An arrangement of objects where the order matters. It tells us how many different ways we can arrange k objects from n distinct objects.

Number of ways to arrange k objects from n objects: {}^{n}P_{k} = \frac{n!}{(n-k)!}

**2. Combination: A selection of objects where the order does not matter. It tells us how many ways we can choose k objects from n distinct objects.

Number of ways to choose k objects from n objects: {}^{n}C_{k} = \frac{n!}{k!(n-k)!}

Important Generating Functions

The following table shows some important generating functions and their corresponding sequences. These standard results are frequently used to solve combinatorial and recurrence relation problems.

s_no_

Types of Generating Functions

1. Ordinary Generating Function (OGF)

A generating function in which the coefficients of powers of x represent the terms of a sequence. It is mainly used in counting problems and combinatorics.

**Formula: G(x)=\sum_{n=0}^{\infty} a_n x^n

2. Exponential Generating Function (EGF)

A generating function where each term of the sequence is divided by n!. It is commonly used in permutation and arrangement problems where order matters.

**Formula: G(x)=\sum_{n=0}^{\infty} a_n \frac{x^n}{n!}

3. Dirichlet Generating Function (DGF)

A generating function used mainly in number theory, where the terms are divided by ns, with s being a complex variable.

**Formula: G(s)=\sum_{n=1}^{\infty} \frac{a_n}{n^s}

4. Probability Generating Function (PGF)

A generating function used in probability theory to represent the probability distribution of a discrete random variable.

**Formula: G(x)=\sum_{n=0}^{\infty} P(X=n)x^n

Solved Examples

**Example 1: Find the generating function for the sequence {1, 1, 1, 1, …}.

**Solution:

The generating function is

G(x) = 1 + x + x² + x³ + …

This is an infinite geometric series with common ratio x.

Using the formula,

1 + x + x² + x³ + … = 1 / (1 − x)

Therefore, G(x) = 1 / (1 − x)

Example 2: Find the generating function for the sequence {0, 1, 2, 3, …}.

**Solution:

The generating function is

G(x) = 0 + x + 2x² + 3x³ + …

Using the standard generating function formula,

x + 2x² + 3x³ + … = x / (1 − x)²

Therefore, G(x) = x / (1 − x)²

Example 3: Find the generating function for the sequence {1, 2, 4, 8, …}.

**Solution:

The generating function is

G(x) = 1 + 2x + 4x² + 8x³ + …

This is a geometric series with common ratio 2x.

Using the formula,

1 + 2x + 4x² + … = 1 / (1 − 2x)

Therefore, G(x) = 1 / (1 − 2x)

**Example 4: Find the generating function for the sequence {ⁿC₀, ⁿC₁, ⁿC₂, … , ⁿCₙ}.

**Solution:

The generating function is

G(x) = ⁿC₀ + ⁿC₁x + ⁿC₂x² + … + ⁿCₙxⁿ

Using the Binomial Theorem,

(1 + x)ⁿ = ⁿC₀ + ⁿC₁x + ⁿC₂x² + … + ⁿCₙxⁿ

Therefore, G(x) = (1 + x)ⁿ

Practice Problems