Discrete Maths | Generating Functions-Introduction and Prerequisites
Last Updated :
08 Aug, 2024
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) [Tex]\big x [/Tex]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 formulas.
[Tex]%\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} [/Tex]
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.
[Tex]$g_0, g_1, g_2, g_3…. [/Tex]of real numbers is the infinite series:
[Tex]%\documentclass{article} %\usepackage{amsmath} \begin{document} \huge \func G(x) = g_0+{g_1}x+{g_2}x^{2}….. = \sum_{k=0}^\infty g_k x^k. \end{document} [/Tex]
[Tex][g_{0},g_{1},g_{2},g_{3}…]\leftrightarrow g_{0} + g_{1}x+g_{2}x^{2}+g_{3}x^{3}…. [/Tex]
Note: we’ll indicate the correspondence between a sequence and its generating function with a double-sided arrow.
Some Important sequences and their results…
[Tex]\textup{Let }G_{n}=1+x+x^{2}+x^{3}+…..+x^{n-1}+x^{n}……….\hspace{1cm} eq^{n} (1)\\ \textup{Multiplying it with x } \\ xG_{n}=x+x^{2}+x^{3}+….\hspace{1cm} eq^{n} (2) \\ \\ \textup{subtracting equation (2) with (1) we will get.. } \\ G_{n}-xG_{n} =1 \\ \\G_{n}=\frac{1}{1-x} [/Tex]
If you want to know more about the derivation of the given sequences you may refer here
[Tex]%\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} [/Tex]
[Tex]%\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} [/Tex]
[Tex]%\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} [/Tex]
[Tex]%\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^…\infty] \(\frac{1} {(1-x^{2})}\) = 1 + x^2 + x^4…. \longleftrightarrow [1, 0, 1, 0…\normalsize\infty] \end{document} [/Tex]
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:
[Tex]%\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} [/Tex]
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.
[Tex]\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) \\ [/Tex]
[Tex]\textup{Example:} \newline [1,0,1,0,1,0…]\hspace{0.25cm}\leftrightarrow \hspace{0.25cm}1+x^{2}+x^{4}+x^{6}….\hspace{0.25cm}=\frac{1}{1-x^{2}} \\ \\ \textup{Multiplying the generating function by 2 gives}\\ \\ \frac{2}{1-x^{2}}=\hspace{0.15cm}2+2x^{2}+2x^{4}+2x^{6}.. [/Tex]
Addition:
Adding generating functions corresponds to adding the two sequences term by term.
[Tex]\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) [/Tex]
[Tex]\textup{Example:} \newline [1,1,1,1,1,1,1,1….]\leftrightarrow \frac{1}{1-x} \hspace{1cm} \newline [1,-1,1,-1,1,-1….]\leftrightarrow \frac{1}{1+x} \newline \textup{Adding both equation we will get}\newline [2,0,2,0,2,0…]\leftrightarrow \frac{1}{1-x}+\frac{1}{1+x} \newline =\frac{2}{1-x^{2}} [/Tex]
Right Shifting:
[Tex]\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) [/Tex]
[Tex]\newline \textup{Example:} \newline \newline [\overbrace{\overset{\textup{k times}}{0,0,0,0,0,0} },1,1,1,1,1,1,1…]\leftrightarrow x^{k}+x^{k+1}+x^{k+2}+x^{k+3}….. \newline \hspace{20cm} =x^{k}(1+x+x^{2}+x^{3}…) \newline \hspace{20cm}=\frac{x^{k}}{x-1} [/Tex]
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.
[Tex]\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) [/Tex]
[Tex]\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}} [/Tex]
Solved Examples
Example 1: Generating Function for a Simple Sequence
Problem: Find the generating function for the sequence {1,1,1,1,…}.
Solution: G(x)=1+x+x2+x3+⋯Using the formula for an infinite geometric series: G(x)=11−x1
Example 2: Generating Function for an Arithmetic Sequence
Problem: Find the generating function for the sequence {0,1,2,3,…}.
Solution: G(x)=0+1x+2×2+3×3+⋯ Using the formula: G(x)=x(1−x)2x
Example 3: Generating Function for a Geometric Sequence
Problem: Find the generating function for the sequence {1,2,4,8,…}.
Solution: G(x)=1+2x+4×2+8×3+⋯ Using the formula for an infinite geometric series with ratio 2x2x: G(x)=11−2×1
Example 4: Sum of Binomial Coefficients
Problem: Find the generating function for the sequence {(n0),(n1),(n2),…}.
Solution: G(x)=∑k=0n(nk)xk=(1+x)n
Example 5: Generating Function for a Shifted Sequence
Problem: Find the generating function for the sequence {0,1,1,1,…}.
Solution: G(x)=x+x2+x3+⋯⋯ Using the formula: G(x)=x1−x
Practice Problems on Generating Functions
- Problem 1: Find the generating function for the sequence {1,2,3,4,…}
- Problem 2: Determine the generating function for the sequence {1,−1,1,−1,…}.
- Problem 3: Find the generating function for the sequence {1,0,1,0,1,0,…}.
- Problem 4: Derive the generating function for the sequence {1,3,5,7,…}.
- Problem 5: Determine the generating function for the sequence {1,4,9,16,…}.
- Problem 6: Find the generating function for the sequence {0,1,0,1,0,1,…}.
- Problem 7: Derive the generating function for the sequence {1,1/2,1/4,1/8,…}.
- Problem 8: Find the generating function for the sequence {1,1,0,0,1,1,0,0,…}.
- Problem 9: Determine the generating function for the sequence {1,2,1,2,1,2,….}.
- Problem 10: Derive the generating function for the sequence {1,3,6,10,15,…}.
Related Articles,
Similar Reads
Discrete Mathematics Tutorial
Discrete Mathematics is a branch of mathematics that is concerned with "discrete" mathematical structures instead of "continuous". Discrete mathematical structures include objects with distinct values like graphs, integers, logic-based statements, etc. In this tutorial, we have covered all the topic
4 min read
Mathematical Logic
Propositional Logic
Logic is the basis of all mathematical reasoning and all automated reasoning. The rules of logic specify the meaning of mathematical statements. These rules help us understand and reason with statements such as - [Tex]\exists~x~such~that~x~\neq~a^2~+~b^2,~where~\:x,~a,~b\in~Z[/Tex]Which in Simple En
10 min read
Discrete Mathematics - Applications of Propositional Logic
A proposition is an assertion, statement, or declarative sentence that can either be true or false but not both. For example, the sentence "Ram went to school." can either be true or false, but the case of both happening is not possible. So we can say, the sentence "Ram went to school." is a proposi
11 min read
Propositional Equivalences
Propositional equivalences are fundamental concepts in logic that allow us to simplify and manipulate logical statements. Understanding these equivalences is crucial in computer science, engineering, and mathematics, as they are used to design circuits, optimize algorithms, and prove theorems. This
7 min read
Predicates and Quantifiers
Predicates and Quantifiers are fundamental concepts in mathematical logic, essential for expressing statements and reasoning about the properties of objects within a domain. These concepts are widely used in computer science, engineering, and mathematics to formulate precise and logical statements.
6 min read
Mathematics | Some Theorems on Nested Quantifiers
Quantifiers are expressions that indicate the scope of the term to which they are attached, they are predicates. A predicate is a property the subject of the statement can have. For example, in the statement "the sum of x and y is greater than 5", the predicate 'Q' is- sum is greater than 5, and the
6 min read
Rules of Inference
Rules of Inference: Rules of inference are logical tools used to derive conclusions from premises. They form the foundation of logical reasoning, allowing us to build arguments, prove theorems, and solve problems in mathematics, computer science, and philosophy. Understanding these rules is crucial
10 min read
Mathematics | Introduction to Proofs
Mathematical proof is an argument we give logically to validate a mathematical statement. To validate a statement, we consider two things: A statement and Logical operators. A statement is either true or false but not both. Logical operators are AND, OR, NOT, If then, and If and only if. Coupled wit
7 min read
Sets and Relations
Set Theory
Set theory is a branch of mathematics that deals with collections of objects. These collections are called sets. A set is simply a group of distinct things, like numbers, letters, or even everyday objects, that are grouped based on some common property. A set is a well-defined collection of distinct
3 min read
Types Of Sets
In mathematics, a set is defined as a well-defined collection of distinct elements that share a common property. These elementsâ like numbers, letters, or even other sets are listed in curly brackets "{ }" and represented by capital letters. For example, a set can include days of the week. The diffe
13 min read
Irreflexive Relation on a Set
A relation is a subset of the cartesian product of a set with another set. A relation contains ordered pairs of elements of the set it is defined on. To learn more about relations refer to the article on "Relation and their types". What is Irreflexive Relation? A relation R on a set A is called irre
6 min read
Check Reflexive Relation on Set
A relation is a subset of the cartesian product of a set with another set. A relation contains ordered pairs of elements of the set it is defined on. To learn more about relations refer to the article on "Relation and their types". What is a Reflexive Relation?A relation R on a set A is called refle
7 min read
Check Transitive Relation on a Set
A relation is a subset of the cartesian product of a set with another set. A relation contains ordered pairs of elements of the set it is defined on. To learn more about relations refer to the article on "Relation and their types". What is a Transitive Relation?A relation R on a set A is called tran
9 min read
Set Operations
A set is simply a collection of distinct objects. These objects can be numbers, letters, or even peopleâanything! We denote a set using curly brackets.For example: A = {1, 2, 3} Set Operations can be defined as the operations performed on two or more sets to obtain a single set containing a combinat
11 min read
Types of Functions
Functions are defined as the relations which give a particular output for a particular input value. A function has a domain and codomain (range). f(x) usually denotes a function where x is the input of the function. In general, a function is written as y = f(x). A function is a relation between two
15 min read
Mathematics | Sequence, Series and Summations
Sequences, series, and summations are fundamental concepts of mathematical analysis and it has practical applications in science, engineering, and finance. Table of Content What is Sequence?Theorems on SequencesProperties of SequencesWhat is Series?Properties of SeriesTheorems on SeriesSummation Def
8 min read
Representation of Relation in Graphs and Matrices
Understanding how to represent relations in graphs and matrices is fundamental in engineering mathematics. These representations are not only crucial for theoretical understanding but also have significant practical applications in various fields of engineering, computer science, and data analysis.
8 min read
Relations in Mathematics
Relation in Mathematics is defined as the relationship between two sets. If we are given two sets set A and set B and set A has a relation with set B then each value of set A is related to a value of set B through some unique relation. Here, set A is called the domain of the relation, and set B is c
10 min read
Closure of Relations
Closure of Relations: In mathematics, especially in the context of set theory and algebra, the closure of relations is a crucial concept. It involves extending a given relation to include additional elements based on specific properties, such as reflexivity, symmetry, and transitivity. Understanding
7 min read
Graph Theory
Graph and its representations
A Graph is a non-linear data structure consisting of vertices and edges. The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph is composed of a set of vertices( V ) and a set of edges( E ). The graph is den
12 min read
Mathematics | Graph Theory Basics - Set 1
A Graph is just a way to show connections between things. It is set of edges and vertices where each edge is associated with unordered pair of vertices. Graph is a data structure that is defined by two components : Node or Vertex: It is a point or joint between two lines like people, cities, or webs
5 min read
Types of Graphs with Examples
A graph is a mathematical structure that represents relationships between objects by connecting a set of points. It is used to establish a pairwise relationship between elements in a given set. graphs are widely used in discrete mathematics, computer science, and network theory to represent relation
9 min read
Walks, Trails, Paths, Cycles and Circuits in Graph
Walks, trails, paths, cycles, and circuits in a graph are sequences of vertices and edges with different properties. Some allow repetition of vertices and edges, while others do not. In this article, we will explore these concepts with examples. What is Walk?A walk in a graph is a sequence of vertic
6 min read
How to find Shortest Paths from Source to all Vertices using Dijkstra's Algorithm
Given a weighted undirected graph represented as an edge list and a source vertex src, find the shortest path distances from the source vertex to all other vertices in the graph. The graph contains V vertices, numbered from 0 to V - 1. Note: The given graph does not contain any negative edge. Exampl
12 min read
Primâs Algorithm for Minimum Spanning Tree (MST)
Primâs algorithm is a Greedy algorithm like Kruskal's algorithm. This algorithm always starts with a single node and moves through several adjacent nodes, in order to explore all of the connected edges along the way. The algorithm starts with an empty spanning tree. The idea is to maintain two sets
15+ min read
Kruskalâs Minimum Spanning Tree (MST) Algorithm
A minimum spanning tree (MST) or minimum weight spanning tree for a weighted, connected, and undirected graph is a spanning tree (no cycles and connects all vertices) that has minimum weight. The weight of a spanning tree is the sum of all edges in the tree. In Kruskal's algorithm, we sort all edges
9 min read
Check whether a given graph is Bipartite or not
Given a graph with V vertices numbered from 0 to V-1 and a list of edges, determine whether the graph is bipartite or not. Note: A bipartite graph is a type of graph where the set of vertices can be divided into two disjoint sets, say U and V, such that every edge connects a vertex in U to a vertex
9 min read
Eulerian path and circuit for undirected graph
Eulerian Path is a path in a graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path that starts and ends on the same vertex.    How to Find Whether a Given Graph is Eulerian or not? The problem is same as following question. "Is it possible to draw a given graph without l
15+ min read
Group Theory
Mathematics | Graph Theory Basics - Set 1
A Graph is just a way to show connections between things. It is set of edges and vertices where each edge is associated with unordered pair of vertices. Graph is a data structure that is defined by two components : Node or Vertex: It is a point or joint between two lines like people, cities, or webs
5 min read
Homomorphism & Isomorphism of Group
We can say that  "o" is the binary operation on set G if: G is a non-empty set & G * G = { (a,b) : a , bâ G } and o : G * G --> G. Here, aob denotes the image of ordered pair (a,b) under the function/operation o. Example - "+" is called a binary operation on G (any non-empty set ) if & on
7 min read
Group Isomorphisms and Automorphisms
In the study of algebraic structures, group isomorphisms and automorphisms play a fundamental role. By defining internal symmetries inside a group (automorphisms) and when two groups have the same structure (isomorphisms), these ideas aid in our understanding of the structure and symmetry of groups.
7 min read
Group in Maths: Group Theory
Group theory is one of the most important branches of abstract algebra which is concerned with the concept of the group. A group consists of a set equipped with a binary operation that satisfies four key properties: specifically, it includes property of closure, associativity, the existence of an id
13 min read