Report On Recursion
Report On Recursion
Report on,
Gouri.N.Huddar I 45 2GI20EE009
Page 1 of 12
Contents:
1. Introduction to Discrete Mathematics
2. Fibonacci Problem
3. Recurrence Relations
4. Generating Functions
Page 2 of 12
What is Discrete Mathematics?
Discrete mathematics is the study of mathematical structures that are
countable or otherwise distinct and separable.
Examples of structures that are discrete are combinations, graphs,
and logical statements. Discrete structures can be finite or infinite.
Discrete mathematics is in contrast to continuous mathematics, which
deals with structures which can range in value over the real numbers , or
have some non-separable quality.
Everyday Applications of Discrete Mathematics
Computers
The software and files are both stored as huge strings of 1s and 0s. Binary
math is discrete mathematics.
Google Maps
It uses discrete mathematics to determine fastest driving routes and times
Cryptography
Encryption and decryption are part of cryptography, which is part of
discrete mathematics. For example, secure internet shopping uses public-
key cryptography
Digital image processing
It uses discrete mathematics to merge images or apply filters
Example:
Tower of Hanoi
The objective of the puzzle is to move entire stack to another rod
obeying the following rules :
• Only one disk may move at a time.
• Each move consists of taking upper disk from one of the rods & sliding it
onto another rod, on top of the other disks that may already be present on
that rod.
• No disk may be placed on top of a smaller disk.
Page 3 of 12
Step 1 − Move n-1 disks from source to aux
Step 2 − Move nth disk from source to dest
Step 3 − Move n-1 disks from aux to dest
Total Number of moves needed to solve for | | given ‘N’ disks : 2n – 1 |
Fibonacci Problem:
A farmer raises rabbits. Each rabbit gives birth when 2 months old and
then each month there after.
Question: How many rabbits will the farmer have after n months? Try it
on small numbers.
Fn ... the number of rabbits after n month. Each rabbit alive the n-1th
month remains nth month. Each rabbit alive the n − 2th month adds one
more rabbit to nth month.
F1 = 1
F2 = 1
Fn+1 = Fn + Fn−1 if n ≥ 2
This formula is an example of a recurrence formula (as opposite to an
explicit formula).
Recurrence formulas are often easy to obtain (and easy to code). Often
we extend the sequence by starting,
F0 = 0,
F1 = 0,
F2 = 1 Fn+1 = Fn + Fn−1 if n ≥ 1
Page 4 of 12
Sequence of Fibonacci numbers 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,
233, . .
For that reason, Fibonacci numbers have been studied in detail. Some
basic identities: F0 + F1 + F2 + · · · + Fn = Fn+2 − 1 F1 + F3 + F5 + · · ·
+ F2n−1 = F2n F0 − F1 + F2 − F3 + · · · − F2n−1 + F2n = F2n−1 − 1
Fn−1Fn+1 − F 2 n = (−1)n
Recurrence relations:
A recurrence relation is an equation that recursively defines a sequence where
the next term is a function of the previous terms (Expressing Fn as some
combination of Fi with i<n).
Example − Fibonacci series − Fn=Fn−1+Fn−2Fn, Tower of Hanoi − Fn=2Fn−1
Page 5 of 12
=a1+(n-1)*3.
So,
an =2+(n-1)*3
Thus, an = rn is solution of (1) if r satisfies quadratic equation (2). This equation
is called characteristic equation for relation (1).
Various Cases
1. Real and Distinct roots
2. Complex roots
3. Repeated Real Roots
Procedure to solve:
Given equation
Change the given equation a n into r n
Divide by the lowest valueof r
Quadric equation
Find the two roots r1 , r2
Solve
Page 6 of 12
as general solution of (1) where A and B are arbitrary real constants.
Example:
an =5a n−1−6 an−2 where a 0=1 a1=1
= r n −5 r n−1+6 r n−2=0
= r1 =3 r2 =2
= an = A(r1)n + B(r2)n
= n=0, n=1,
= A+B=1 3A+2B=1
= Solving we get A=-1 B=-2
= an = -1(3)n + 2(2)n
Case 2: When Roots are Real & Equal
If the two roots k1, k2 of equation are real and equal, with k as common value
then, we take
an = (A + Bn)kn
as general solution of (1) where A and B are arbitrary real constants.
Case 3: When Roots are Complex
If the two roots k1 and k2 of equation are complex then, k1 and k2 are complex
conjugate of each other i.e k1 = p + iq and k2 = p – iq and we take
Generating Function:
Page 7 of 12
Working with a continuous function is sometimes much easier than working
with a sequence. For example, in the analysis of functions, calculus is very
useful. However, the discrete nature of sequences prevents us from using
calculus on sequences. A generating function is a continuous function
associated with a given sequence. For this reason, generating functions are very
useful in analyzing discrete problems involving sequences of numbers or
sequences of functions.
Definition
Let a 0 , a 1, a 2, a 3….. ∞ be a sequence of real numbers denoted as {a n}
Then a series in power of x, such that
G(x)= a 0+ a1 x +a 2 x 2+ a3 x3 ….. ∞
∞
G(x)=∑ an x n , is called a generating function of series {a n}
n=0
Example:
1) If we have a sequence with a n=n+1 Then the generating function for this
sequence is,
∞
G(x)= ∑ (n+1) x n
n=0
Page 8 of 12
Solution:
Let a n=3, 7, 11, 15….. ∞
We know that,
G(x)= a 0+ a1 x +a 2 x 2+ a3 x3 ….. ∞
a 0=3, a 1=7 , a 2=15,…..
3 4x
G(x)= 1−x + 2
(1−x)
Page 9 of 12
Page 10 of 12
Solving Recurrence Relation Using
Generating function:
Generating function can be used to solve recurrence relation
Procedure :
Translate a recurrence relation for the terms of a sequence into an equation
involving generating function
This equation can be solved to find a closed form of the generating function
From this closed form, the coefficients of the power series for the generating
function can be found solving the original recurrence relation
Solve the recurrence relation a k =3 ak −1for k=1,2,3.. and given a 0=2
Solution:
Let G(x) be the generating function for the sequence {a k}
∞
i.e. G(x)= ∑ ak x k
k=0
∞ ∞
xG(x)= ∑ ak x = ∑ ak−1 x k
k+1
k=0 k =1
∞
G(x) – 3xG(x) = a 0+ ¿ ∑ ¿ ¿ ) x k
k=0
(1 – 3x)G(x) = 2
2
G(x)= 1−3 x
∞
G(x)=2 ∑ 3k x k
k=0
Hence a k= 2 ⋅3k
Page 11 of 12
Applications of Generating function
Generating functions are used in a wide area from statistics to mechanics,
from combinations to cryptology, especially in topics involving
sequences.
They help us
to find the explicit formula for the general term of a sequence
to find recurrence relations
to compute averages and some other statistical properties
to prove some mathematical identities
Page 12 of 12