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) \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.
Some basic prerequisites...
Before we start let's go through some basic Combinatorics formulas.
%\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}
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.
$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^{2}..... = \sum_{k=0}^\infty g_k x^k. \end{document}
[g_{0},g_{1},g_{2},g_{3}...]\leftrightarrow g_{0} + g_{1}x+g_{2}x^{2}+g_{3}x^{3}....
Note: we’ll indicate the correspondence between a sequence and its generating function with a double-sided arrow.
Some Important sequences and their results...
\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}
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} \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}
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}
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.
\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) \\
\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}..
Addition:
Adding generating functions corresponds to adding the two sequences term by term.
\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)
\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}}
Right Shifting:
\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)
\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}
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.
\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)
\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}}
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+2x2+3x3+⋯ 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+4x2+8x3+⋯ Using the formula for an infinite geometric series with ratio 2x2x: G(x)=11−2x1
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
Engineering Mathematics Tutorials Engineering mathematics is a vital component of the engineering discipline, offering the analytical tools and techniques necessary for solving complex problems across various fields. Whether you're designing a bridge, optimizing a manufacturing process, or developing algorithms for computer systems,
3 min read
Linear Algebra
MatricesMatrices are key concepts in mathematics, widely used in solving equations and problems in fields like physics and computer science. A matrix is simply a grid of numbers, and a determinant is a value calculated from a square matrix.Example: \begin{bmatrix} 6 & 9 \\ 5 & -4 \\ \end{bmatrix}_{2
3 min read
Row Echelon FormRow Echelon Form (REF) of a matrix simplifies solving systems of linear equations, understanding linear transformations, and working with matrix equations. A matrix is in Row Echelon form if it has the following properties:Zero Rows at the Bottom: If there are any rows that are completely filled wit
4 min read
Eigenvalues and EigenvectorsEigenvalues and eigenvectors are fundamental concepts in linear algebra, used in various applications such as matrix diagonalization, stability analysis and data analysis (e.g., PCA). They are associated with a square matrix and provide insights into its properties.Eigen value and Eigen vectorTable
10 min read
System of Linear EquationsA system of linear equations is a set of two or more linear equations involving the same variables. Each equation represents a straight line or a plane and the solution to the system is the set of values for the variables that satisfy all equations simultaneously.Here is simple example of system of
5 min read
Matrix DiagonalizationMatrix diagonalization is the process of reducing a square matrix into its diagonal form using a similarity transformation. This process is useful because diagonal matrices are easier to work with, especially when raising them to integer powers.Not all matrices are diagonalizable. A matrix is diagon
8 min read
LU DecompositionLU decomposition or factorization of a matrix is the factorization of a given square matrix into two triangular matrices, one upper triangular matrix and one lower triangular matrix, such that the product of these two matrices gives the original matrix. It is a fundamental technique in linear algebr
6 min read
Finding Inverse of a Square Matrix using Cayley Hamilton Theorem in MATLABMatrix is the set of numbers arranged in rows & columns in order to form a Rectangular array. Here, those numbers are called the entries or elements of that matrix. A Rectangular array of (m*n) numbers in the form of 'm' horizontal lines (rows) & 'n' vertical lines (called columns), is calle
4 min read
Sequence & Series
Calculus
Limits, Continuity and DifferentiabilityLimits, Continuity, and Differentiation are fundamental concepts in calculus. They are essential for analyzing and understanding function behavior and are crucial for solving real-world problems in physics, engineering, and economics.Table of ContentLimitsKey Characteristics of LimitsExample of Limi
10 min read
Cauchy's Mean Value TheoremCauchy's Mean Value theorem provides a relation between the change of two functions over a fixed interval with their derivative. It is a special case of Lagrange Mean Value Theorem. Cauchy's Mean Value theorem is also called the Extended Mean Value Theorem or the Second Mean Value Theorem.According
7 min read
Taylor SeriesA Taylor series represents a function as an infinite sum of terms, calculated from the values of its derivatives at a single point.Taylor series is a powerful mathematical tool used to approximate complex functions with an infinite sum of terms derived from the function's derivatives at a single poi
8 min read
Inverse functions and composition of functionsInverse Functions - In mathematics a function, a, is said to be an inverse of another, b, if given the output of b a returns the input value given to b. Additionally, this must hold true for every element in the domain co-domain(range) of b. In other words, assuming x and y are constants, if b(x) =
3 min read
Definite Integral | Definition, Formula & How to CalculateA definite integral is an integral that calculates a fixed value for the area under a curve between two specified limits. The resulting value represents the sum of all infinitesimal quantities within these boundaries. i.e. if we integrate any function within a fixed interval it is called a Definite
8 min read
Application of Derivative - Maxima and MinimaDerivatives have many applications, like finding rate of change, approximation, maxima/minima and tangent. In this section, we focus on their use in finding maxima and minima.Note: If f(x) is a continuous function, then for every continuous function on a closed interval has a maximum and a minimum v
6 min read
Probability & Statistics
Mean, Variance and Standard DeviationMean, Variance and Standard Deviation are fundamental concepts in statistics and engineering mathematics, essential for analyzing and interpreting data. These measures provide insights into data's central tendency, dispersion, and spread, which are crucial for making informed decisions in various en
10 min read
Conditional ProbabilityConditional probability defines the probability of an event occurring based on a given condition or prior knowledge of another event. It is the likelihood of an event occurring, given that another event has already occurred. In probability, this is denoted as A given B, expressed as P(A | B), indica
12 min read
Bayes' TheoremBayes' Theorem is a mathematical formula used to determine the conditional probability of an event based on prior knowledge and new evidence. It adjusts probabilities when new information comes in and helps make better decisions in uncertain situations.Bayes' Theorem helps us update probabilities ba
13 min read
Probability Distribution - Function, Formula, TableA probability distribution is a mathematical function or rule that describes how the probabilities of different outcomes are assigned to the possible values of a random variable. It provides a way of modeling the likelihood of each outcome in a random experiment.While a Frequency Distribution shows
13 min read
Covariance and CorrelationCovariance and correlation are the two key concepts in Statistics that help us analyze the relationship between two variables. Covariance measures how two variables change together, indicating whether they move in the same or opposite directions. Relationship between Independent and dependent variab
6 min read
Practice Questions