DiscreteMaths Unit4 Notes
DiscreteMaths Unit4 Notes
When the term generating function is used without qualification, it is usually taken to meanan ordinary generating
function.
If an is the probability mass function of a discrete random variable, then its ordinarygenerating function is called a
probability-generating function.
The ordinary generating function can be generalized to arrays with multiple indices. For example, the ordinary generating
function of a two-dimensional array am, n (where n and m are natural numbers) is
Example:
Function of Sequences: Generating functions giving the first few powers of the nonnegative integers are given
in the following table
There are many beautiful generating functions for special functions in number theory. A fewparticularly nice
examples are
n ≥ 1, the n-the term of a sequence A = {ar}∞r=0 to one or more of the terms a0,a1,….,an-1.
Definition. Suppose n and k are nonnegative integers. A recurrence relation of the form c0 (n)an+ c1(n)an-1 +
…. + Ck (n)an-k = f(n) for n ≥ k, where c0(n), c1(n),…., ck(n), and f(n) are functions of n is said to be a linear
recurrence relation. If c0(n) and ck(n) are not identically zero, then it is said to be a linear recurrence relation
degree k. If c0(n), c1(n),…., ck(n) are constants, then the recurrence relation is known as a linear relation with
constant coefficients. If f(n) is identically zero, then the recurrence relation is said to be homogeneous;
otherwise, itis inhomogeneous.
There are no general techniques that will enable one to solve all recurrence relations. There are techniques that
will enable us to solve linear recurrence relations with constant coefficients.
SOLVING RECURRENCE RELATIONS BY SUSTITUTION AND
GENERATING FUNCTIONS
We shall consider four methods of solving recurrence relations in this and the next twosections:
• Substitution (also called iteration),
• Generating functions,
Ex: Let ak = 5ak-1 - 6ak-2. Find the general solution.The relation has characteristic
equation:
x 2 = 5x - 6,
So x 2 - 5x + 6 = 0 hence (x - 2) (x - 3) = 0
Implying either (x - 2) = 0 or (x - 3) = 0thus x = 2,3
General Solution is an = C (2n) + D (3n ).
What is a Recurrence Relation?
A recurrence relation is an equation that defines a sequence based on its preceding terms. In simpler terms, it’s a way to
express each term in a sequence as a function of previous terms. Recurrence relations are especially useful in computer
engineering for analyzing recursive algorithms, understanding complex calculations, and solving problems that involve
repetitive structures.
Why are Recurrence Relations Important for Computer Engineering?
Computer engineering students encounter recurrence relations when analyzing the time complexity of recursive algorithms,
such as those in data structures (like trees and heaps), divide-and-conquer algorithms (e.g., mergesort), and other scenarios
where a problem is broken into smaller, similar sub-problems.
Understanding recurrence relations helps students:
•Analyze and predict performance: Recurrence relations reveal how an algorithm’s runtime grows as input size increases.
•Optimize recursive algorithms: By solving recurrence relations, students can determine whether their algorithms are efficient
and, if not, find ways to improve them.
•Model real-world systems: Recurrence relations can represent iterative processes in systems, such as resource allocation or
network behavior, allowing for predictions and optimizations.
Types of Recurrence Relations
1.Linear Recurrence Relations: Each term is a linear combination of previous terms. These are common in algorithmic
analysis.
1. Example: T(n)=2T(n−1)+1 (often seen in recursive algorithms where each step splits the problem in two)
2.Non-Linear Recurrence Relations: Involves terms that are multiplied or squared, creating non-linear combinations.
1. Example: T(n)=T(n−1)⋅T(n−2)
3. Homogeneous vs. Non-Homogeneous Recurrence Relations:
1. Homogeneous: Every term depends only on previous terms without any additional constant.
1. Example: T(n)=2T(n−1)
2. Non-Homogeneous: Includes an additional function or constant.
1. Example: T(n)=2T(n−1)+n
2.Data Structures: Recurrences define the operations on trees, heaps, and other recursive structures. For example, inserting
into a binary search tree (BST) on average has recurrence:
T(n)=T(n/2)+1 which, through the characteristic equation, gives a time complexity of O(logn).
3. Dynamic Programming: Many dynamic programming problems are defined by recurrence relations, where an optimal
solution for a problem depends on solutions to subproblems. For example, the Fibonacci sequence is defined by:
F(n)=F(n−1)+F(n−2) which has applications in areas like sequence analysis, optimization, and modeling in computer
engineering.
Summary
For computer engineering students, mastering recurrence relations is critical because it allows them to understand and
optimize recursive processes. The ability to analyze and solve these relations leads to a better grasp of algorithm efficiency,
computational complexity, and efficient system design—key skills for developing robust and scalable software systems.
Find the recurrence relation : s(n) = a^n
To find a recurrence relation for the sequence s(n) = a^n , let’s analyze how each term relates to the previous one.
Step 1: Express s(n) in Terms of s(n−1)
We know that:
s(n) = a^n Since s(n-1) = a^{n-1}, we can rewrite s(n) in terms of s(n-1):
s(n)=a⋅s(n−1)
Step 2: Formulate the Recurrence Relation
The recurrence relation for s(n) is therefore:
s(n)=a⋅s(n−1)
Step 3: Specify the Initial Condition
To completely define the recurrence, we need an initial condition. Typically, we start with:
s(0)= a^0 = 1
Final Recurrence Relation
The recurrence relation for the sequence s(n)= a^n is:
s(n)=a⋅s(n−1),with s(0)=1
Now let's explore the sum of the terms of the sequence s(n)=a^n from n=0 to some arbitrary value n=k.
Given:
s(n) = a^n we want to find: n=0∑ks(n)=0∑ka^n
r^2 - 5r + 6 = 0
Step 2: Solve the Characteristic Equation
Now, we factor the quadratic equation:
r^2 - 5r + 6 = (r - 2)(r - 3) = 0
This gives the roots:
r=2andr=3
Step 3: Write the General Solution
Since we have two distinct roots r=2 and r=3 , the general solution to the recurrence relation is:
a(n)=C1⋅2^n + C2. 3^n where C1 ,C2 are constants determined by initial conditions.
Final Solution
The general solution to the recurrence relation a(n)−5a(n−1)+6a(n−2)=0 is:
a(n)=C1⋅2^n + C2.3^n
To fully determine C1 and C2, we would need specific initial values, such as a(0) and a(1).
1. Define Recurrence Relation. Give an example. [2] CO4 BTL2
2. List and define the types of generating functions. [2] CO4 BTL2
i) ar=3^r +4^(r+1)
ii) ar=5
4. Explain in brief the homogeneous recurrence relation with [2] CO4 BTL5
example
5. Explain in brief the non-homogeneous recurrence relation with example [2] CO4 BTL5
i) ar=3^r
ii) ar=5(2)^r
9. Define homogeneous solution and particular solution. Write the [2] CO4 BTL2
particular solution of a constant.
10. Write the particular solution if [2] CO4 BTL2
i) root and b value is same
ii) root and b value is different
11. a). Write the homogeneous solution when nature of roots is [3] CO4 BTL2
i) real and distinct ii) real and repeated iii) distinct complex
b). Determine the discrete numeric function for 7z^2 ÷(1-2z)(1+3z) [3] CO4 BTL5
c). Solve the difference equation by boundary conditions. ar -5 ar-1 + 6 ar-2 [6] CO4 BTL6
1. Solve the Homogeneous Equation: Consider the homogeneous part of the equation: a_n^{(h)} = 2a_{n-1}^{(h)} +
3a_{n-2}^{(h)}.
2. Assuming a solution of the form a_n^{(h)} = r^n, the characteristic equation is: r^2 = 2r + 3, which simplifies to: r^2 -
2r - 3 = 0.
3. Solving this quadratic equation: r = (2 ± sqrt(4 + 12)) / 2 = (2 ± 4) / 2, yields roots: r_1 = 3 and r_2 = -1.
4. Therefore, the general solution to the homogeneous equation is: a_n^{(h)} = C_1(3^n) + C_2((-1)^n).
5. Find a Particular Solution: For the nonhomogeneous equation, we seek a particular solution a_n^{(p)}. Since the
nonhomogeneous term is 5^n, and 5 is not a root of the characteristic equation, we try: a_n^{(p)} = A * 5^n.
Substituting into the equation: A * 5^n = 2A * 5^{n-1} + 3A * 5^{n-2} + 5^n.
1. Dividing through by 5^n: A = (2A/5) + (3A/25) + 1.
2. Solving for A: A = 13A/25 + 1, A(1 - 13/25) = 1, A = 25/12.
3. Thus, the particular solution is: a_n^{(p)} = (25/12) * 5^n.
4. Form the General Solution: The general solution is the sum of the homogeneous and particular solutions: a_n =
a_n^{(h)} + a_n^{(p)} = C_1(3^n) + C_2((-1)^n) + (25/12) * 5^n.
6. Apply Initial Conditions to Find Constants: Using a_0 = -2: -2 = C_1 + C_2 + (25/12), C_1 + C_2 = -49/12. Using a_1 = 1:
1 = 3C_1 - C_2 + (125/12), 3C_1 - C_2 = -113/12. 5. Solve for C_1 and C_2: Adding the two equations: (C_1 + C_2) +
(3C_1 - C_2) = -49/12 - 113/12, 4C_1 = -162/12, C_1 = -27/8. Substituting back: C_2 = -49/12 - C_1 = -49/12 + 27/8,
C_2 = -17/24.
7. 6. Final Solution: The explicit solution to the difference equation is: a_n = -(27/8) * (3^n) - (17/24) * ((-1)^n) + (25/12)
* (5^n)
Step 2: Find a Particular Solution
Solve the difference equation by boundary conditions. ar The non-homogeneous term is 2^r. We will look for a particular
solution of the form:
+6 ar-1 + 12 ar-2 +8 ar-3 = 2^r , r>=3, a0=0, a1=0 , a_r^(p) = K * 2^r
Substitute a_r^(p) into the original difference equation:
a2=2 K * 2^r + 6 * K * 2^{r-1} + 12 * K * 2^{r-2} + 8 * K * 2^{r-3} = 2^r
First, consider the associated homogeneous equation: Divide both sides by 2^r: K + 6K * (1/2) + 12K * (1/4) + 8K *
Copy code (1/8) = 1
a_r + 6 * a_{r-1} + 12 * a_{r-2} + 8 * a_{r-3} = 0 K + 3K + 3K + K = 1
Assume a solution of the form: 8K = 1 ; K = 1/8
a_r = λ^r Therefore, the particular solution is: a_r^(p) = (1/8) * 2^r
Substitute into the homogeneous equation: λ^r + 6 * λ^{r-1} + Step 3: Form the General Solution
12 * λ^{r-2} + 8 * λ^{r-3} = 0 Combine the homogeneous and particular solutions:
Divide both sides by λ^{r-3}: λ^3 + 6λ^2 + 12λ + 8 = 0 a_r = a_r^(h) + a_r^(p)
This is the characteristic equation: a_r = (-2)^r * (C1 + C2 * r + C3 * r^2) + (1/8) * 2^r
λ^3 + 6λ^2 + 12λ + 8 = 0 Since (-2)^r = (-1)^r * 2^r, we can write:
Finding Roots: a_r = 2^r * [ (-1)^r * (C1 + C2 * r + C3 * r^2) + (1/8) ]
(λ + 2)(λ^2 + 4λ + 4) = 0 Step 4: Apply Initial Conditions
Factor the quadratic: (λ + 2)^3 = 0 Use the initial conditions to solve for C1, C2, and C3.
General Solution to the Homogeneous Equation: C1 = -1/8 C2 = 1/4 C3 = 0 Therefore, the solution is: a_r = 2^r *
Since λ = -2 is a root of multiplicity 3, the general solution is: [ (-1)^r * ( (-1/8) + (1/4) * r ) + (1/8) ]
a_r^(h) = (-2)^r * (C1 + C2 * r + C3 * r^2) Simplify the expression if desired.
where C1, C2, and C3 are constants. Answer:
The solution to the difference equation is: a_r = 2^r * [ (-1)^r *
( (1/4) * r - (1/8) ) + (1/8) ]
Determine the discrete numeric function for (2 + 3z – 6z^2 )÷(1-2z)
Let G(z) = (2+3z-6z^2)/(1-2z) = 3z + 2 / (1 - 2z)