Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Number System and Arithmetic
  • Algebra
  • Set Theory
  • Probability
  • Statistics
  • Geometry
  • Calculus
  • Logarithms
  • Mensuration
  • Matrices
  • Trigonometry
  • Mathematics
Open In App
Next Article:
Mathematics | Sequence, Series and Summations
Next article icon

Mathematics | Generating Functions – Set 2

Last Updated : 29 May, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

Prerequisite – Generating Functions-Introduction and Prerequisites 
In Set 1 we came to know basics about Generating Functions. Now we will discuss more details on Generating Functions and its applications. 

Exponential Generating Functions – 
Let [Tex]h_0, h_1, h_2, ………, h_n, …… [/Tex]e a sequence. Then its exponential generating function, denoted by [Tex]g^e(x) [/Tex]is given by, 

[Tex]g^e(x) =\sum_{n=0}^{+\infty} \frac{x^n}{n!} h_n [/Tex]

Example 1:- Let {1, 1, 1…….} be a sequence . The generating function of the sequence is 
[Tex]g^e(x) = \sum_{n=0}^{+\infty} \frac{x^n}{n!} [/Tex]( Here [Tex]h_n [/Tex]=1 for all n ) 
Example 2:- Let [Tex]perm{n}{k} [/Tex]be number of k permutation in an n- element set. Then the exponential generating function for the sequence [Tex]^nP_0, ^nP_1, ……., ^nP_n [/Tex]is 

[Tex]g^e(x) =\sum_{k=0}^{n} \frac{x^n}{n!} ^nP_k = \sum_{k=0}^{n} \frac{x^k}{k!} \frac{n!}{(n-k)!} = \sum_{k=0}^{n} \frac{n!}{k!(n-k)!} x_k = \sum_{k=0}^{n} \^nC_k x_k =(1+x)^n [/Tex]

Exponential Generating Function is used to determine number of n-permutation of a set containing repetitive elements. We will see examples later on. 

Using Generating Functions to Solve Recurrence Relations – 
Linear homogeneous recurrence relations can be solved using generating function .We will take an example here to illustrate . 

Example :- Solve the linear homogeneous recurrence equation [Tex]h_n=5h_{n-1}+6h_{n-2} [/Tex]. 
Given [Tex]h_0 [/Tex]=1 and [Tex]h_1=-2 [/Tex]. 

We use generating function to solve this problem. Let g(x) be the generating function of the sequence [Tex]h_0, h_1, h_2, ……, h_n, …. [/Tex]. 
Hence g(x)=[Tex]h_0+h_1 x + h_2 x^2 +……..+ h_n x^n+…. [/Tex]
So we get the following equations. 
g(x)=[Tex]h_0+h_1 x + h_2 x^2 +……..+ h_n x^n+…. [/Tex]

-5xg(x)= [Tex]-h_0x+h_1 x^2 + h_2 x^3 +……..+ h_n x^n+1+…. [/Tex]

[Tex]6x^2g(x) [/Tex]=[Tex]h_0 x^2+h_1 x^3 + h_2 x^4 +……..+ h_n x^n+2+…. [/Tex]



Adding these 3 quantities we obtain 
[Tex](1+5-6x^2)g(x)=h_0 + (h_1-5h_0)x +(h_2-5h_1+6h_0)+……. +(h_n-5h_{n-1}+6h_{n-2})x^n+….. [/Tex]

Now [Tex]h_n-5h_{n-1}+6h_{n-2} [/Tex]=0 for all n>1. So, 

[Tex](1+5x-6x^2)g(x)=h_0 + (h_1-5h_0)x = (1-7x) [/Tex]


Or g(x)=[Tex]\frac{(1-7x)}{(1+5-6x^2)} [/Tex]

Now [Tex](1+5x-6x^2) [/Tex]=(1-2x)(1-3x) 

So, g(x)=[Tex]\frac{(1-7x)}{(1-2x)(1-3x)} [/Tex]

It is easy to see that [Tex]\frac{(1-7x)}{(1-2x)(1-3x)}=\frac{5}{(1-2x)}-\frac{4}{(1-3x)} [/Tex]

Now [Tex]\frac{1}{(1-2x)}=1 + 2x+2^2 x^2 +2^3 x^3+…. +2^n x^n+…… [/Tex]
And [Tex]\frac{1}{(1-3x)}=1 + 3x+3^2 x^2 +3^3 x^3+…. +3^n x^n+…… [/Tex]

So g(x)=[Tex]5(1 + 2x+2^2 x^2 +2^3 x^3+…. +2^n x^n+……)-4(1 + 3x+3^2 x^2 +3^3 x^3+…. +3^n x^n+……) [/Tex]

Since this is the generating function for the sequence [Tex]h_0, h_1, ……h_n [/Tex]We observe that [Tex]h_n=5*2^n-4*3^n [/Tex]

Thus we can solve recurrence equations using generating functions. 

Proving Identities via Generating Functions – 
Various identities also can also be proved using generating functions.Here we illustrate one of them. 

Example: Prove that : [Tex]^nC_r=^{(n-1)}C_r+^{(n-1)}C_{r-1} [/Tex]
Here we use the generating function of the sequence [Tex]^nC_0, ^nC_1, ……^nC_r…. [/Tex]i.e [Tex](1+x)^n [/Tex]. 
Now, [Tex](1+x)^n=(1+x)^{n-1}(1+x)=(1+x)^{n-1}+x(1+x)^{n-1} [/Tex]
For LHS the term containing[Tex]x^n [/Tex]is [Tex]^nC_r [/Tex].For RHS the term containing[Tex]x^n [/Tex]is [Tex]^{(n-1)}C_r+^{(n-1)}C_{r-1} [/Tex]. So [Tex]^nC_r=^{(n-1)}C_r+^{(n-1)}C_{r-1} [/Tex](proved) 

Links of Various examples are given below regarding generating functions. 
 

  1. GATE CS 2018 | Question 18
  2. GATE-CS-2017 (Set 2) | Question 52


 


Next Article
Mathematics | Sequence, Series and Summations

T

tufan_gupta2000
Improve
Article Tags :
  • DSA
  • Engineering Mathematics
  • GATE CS
  • Mathematics

Similar Reads

  • 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
  • Inclusion-Exclusion and its various Applications
    In the field of Combinatorics, it is a counting method used to compute the cardinality of the union set. According to basic Inclusion-Exclusion principle: For 2 finite sets [Tex]A_1 [/Tex]and [Tex]A_2 [/Tex], which are subsets of Universal set, then [Tex](A_1-A_2), (A_2-A_1) [/Tex]and [Tex](A_1\bigc
    7 min read
  • Properties of Power Set
    The power set of a set A, denoted as P(A), is the collection of all subsets of A, including: The empty set {}All single-element subsets {a}All possible combinations of elements from A, up to the entire set A itself.For example, if A={1,2}, the power set P(A) is {{},{1},{2},{1,2}}. Properties of Powe
    4 min read
  • Partial Orders and Lattices
    Partial orders and lattices are important concepts in discrete mathematics and are widely used in computer science, especially in data structures, database theory, and the theory of computation. A partial order is a binary relation that describes a set of elements that are, in a sense, ordered, but
    4 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
  • 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
  • Discrete Mathematics | Representing Relations
    Prerequisite - Introduction and types of Relations Relations are represented using ordered pairs, matrix and digraphs: Ordered Pairs - In this set of ordered pairs of x and y are used to represent relation. In this corresponding values of x and y are represented using parenthesis. Example: {(1, 1),
    2 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
  • 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
  • Number of possible Equivalence Relations on a finite set
    An equivalence relation is defined as a relation that is Reflexive, Symmetric, and Transitive. Before we explore how to calculate the number of possible equivalence relations on a set ∣A∣ = n, let’s first look at an example of an equivalence relation and identify its equivalence classes. Example of
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences