SlideShare a Scribd company logo
1 of 18
1
Recursive Definitions
Recursion is a principle closely related to
mathematical induction.
In a recursive definition, an object is defined in
terms of itself.
We can recursively define sequences, functions
and sets.
2
Recursively Defined Sequences
Example:
The sequence {an} of powers of 2 is given by
an = 2n for n = 0, 1, 2, … .
The same sequence can also be defined
recursively:
a0 = 1
an+1 = 2an for n = 0, 1, 2, …
Obviously, induction and recursion are similar
principles.
3
Recursively Defined Functions
We can use the following method to define a
function with the natural numbers as its domain:
1. Specify the value of the function at zero.
2. Give a rule for finding its value at any integer
from its values at smaller integers.
Such a definition is called recursive or inductive
definition.
4
Recursively Defined Functions
Example:
f(0) = 3
f(n + 1) = 2f(n) + 3
f(0) = 3
f(1) = 2f(0) + 3 = 23 + 3 = 9
f(2) = 2f(1) + 3 = 29 + 3 = 21
f(3) = 2f(2) + 3 = 221 + 3 = 45
f(4) = 2f(3) + 3 = 245 + 3 = 93
5
Recursively Defined Functions
How can we recursively define the factorial
function f(n) = n! ?
f(0) = 1
f(n + 1) = (n + 1)f(n)
f(0) = 1
f(1) = 1f(0) = 11 = 1
f(2) = 2f(1) = 21 = 2
f(3) = 3f(2) = 32 = 6
f(4) = 4f(3) = 46 = 24
6
Recursively Defined Functions
A famous example: The Fibonacci numbers
f(0) = 0, f(1) = 1
f(n) = f(n – 1) + f(n - 2)
f(0) = 0
f(1) = 1
f(2) = f(1) + f(0) = 1 + 0 = 1
f(3) = f(2) + f(1) = 1 + 1 = 2
f(4) = f(3) + f(2) = 2 + 1 = 3
f(5) = f(4) + f(3) = 3 + 2 = 5
f(6) = f(5) + f(4) = 5 + 3 = 8
7
Recursively Defined Sets
If we want to recursively define a set, we need to
provide two things:
• an initial set of elements,
• rules for the construction of additional
elements from elements in the set.
Example: Let S be recursively defined by:
3  S
(x + y)  S if (x  S) and (y  S)
S is the set of positive integers divisible by 3.
8
Recursively Defined Sets
Proof:
Let A be the set of all positive integers divisible by 3.
To show that A = S, we must show that
A  S and S  A.
Part I: To prove that A  S, we must show that
every positive integer divisible by 3 is in S.
We will use mathematical induction to show this.
9
Recursively Defined Sets
Let P(n) be the statement “3n belongs to S”.
Basis step: P(1) is true, because 3 is in S.
Inductive step: To show:
If P(n) is true, then P(n + 1) is true.
Assume 3n is in S. Since 3n is in S and 3 is in S, it
follows from the recursive definition of S that
3n + 3 = 3(n + 1) is also in S.
Conclusion of Part I: A  S.
10
Recursively Defined Sets
Part II: To show: S  A.
Basis step: To show:
All initial elements of S are in A. 3 is in A. True.
Inductive step: To show:
(x + y) is in A whenever x and y are in A.
If x and y are both in A, it follows that 3 | x and 3 | y.
As we already know, it follows that 3 | (x + y).
Conclusion of Part II: S  A.
Overall conclusion: A = S.
11
Recursively Defined Sets
Another example:
The well-formed formulas of variables, numerals
and operators from {+, -, *, /, ^} are defined by:
x is a well-formed formula if x is a numeral or
variable.
(f + g), (f – g), (f * g), (f / g), (f ^ g) are well-formed
formulas if f and g are.
12
Recursively Defined Sets
With this definition, we can construct formulas such
as:
(x – y)
((z / 3) – y)
((z / 3) – (6 + 5))
((z / (2 * 4)) – (6 + 5))
13
Recursive Algorithms
An algorithm is called recursive if it solves a problem
by reducing it to an instance of the same problem with
smaller input.
Example I: Recursive Euclidean Algorithm
procedure gcd(a, b: nonnegative integers with a < b)
if a = 0 then gcd(a, b) := b
else gcd(a, b) := gcd(b mod a, a)
14
Recursive Algorithms
Example II: Recursive Fibonacci Algorithm
procedure fibo(n: nonnegative integer)
if n = 0 then fibo(0) := 0
else if n = 1 then fibo(1) := 1
else fibo(n) := fibo(n – 1) + fibo(n – 2)
15
Recursive Algorithms
Recursive Fibonacci Evaluation:
f(4)
f(3)
f(2)
f(1) f(0)
f(1)
f(2)
f(1) f(0)
16
Recursive Algorithms
procedure iterative_fibo(n: nonnegative integer)
if n = 0 then y := 0
else
begin
x := 0
y := 1
for i := 1 to n-1
begin
z := x + y
x : = y
y := z
end
end {y is the n-th Fibonacci number}
17
Recursive Algorithms
For every recursive algorithm, there is an equivalent
iterative algorithm.
Recursive algorithms are often shorter, more
elegant, and easier to understand than their
iterative counterparts.
However, iterative algorithms are usually more
efficient in their use of space and time.
October 3, 2013
Applied Discrete Mathematics
Week 5: Mathematical Reasoning 18

More Related Content

Similar to Recursive Definitions in Discrete Mathmatcs.pptx

Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxgbikorno
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxgbikorno
 
Fourier 3
Fourier 3Fourier 3
Fourier 3nugon
 
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huliCRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huliharshmacduacin
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms IiSri Prasanna
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fittingAmeen San
 
Chapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.sChapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.svidyabhoge1
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Aladdinew
 
Module 2 exponential functions
Module 2   exponential functionsModule 2   exponential functions
Module 2 exponential functionsdionesioable
 
Maths chapter wise Important questions
Maths chapter wise Important questionsMaths chapter wise Important questions
Maths chapter wise Important questionsSrikanth KS
 
Maths important questions for 2018
Maths important questions for 2018Maths important questions for 2018
Maths important questions for 2018KarunaGupta1982
 
Maths imp questions for 2018
Maths imp questions for 2018Maths imp questions for 2018
Maths imp questions for 2018KarunaGupta1982
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdfRajuSingh806014
 

Similar to Recursive Definitions in Discrete Mathmatcs.pptx (20)

Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptx
 
Mathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptxMathematical Reasoning in Discrete Mathmatics.pptx
Mathematical Reasoning in Discrete Mathmatics.pptx
 
Fourier 3
Fourier 3Fourier 3
Fourier 3
 
maths ppt.pdf
maths ppt.pdfmaths ppt.pdf
maths ppt.pdf
 
maths ppt.pdf
maths ppt.pdfmaths ppt.pdf
maths ppt.pdf
 
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huliCRYPTOGRAPHY AND NUMBER THEORY, he ha huli
CRYPTOGRAPHY AND NUMBER THEORY, he ha huli
 
Probability theory
Probability theoryProbability theory
Probability theory
 
file_5.pptx
file_5.pptxfile_5.pptx
file_5.pptx
 
01_Sets.pdf
01_Sets.pdf01_Sets.pdf
01_Sets.pdf
 
Analysis Of Algorithms Ii
Analysis Of Algorithms IiAnalysis Of Algorithms Ii
Analysis Of Algorithms Ii
 
Per4 induction
Per4 inductionPer4 induction
Per4 induction
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fitting
 
Chapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.sChapter1.integer s.y.b.c.s
Chapter1.integer s.y.b.c.s
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
 
Module 2 exponential functions
Module 2   exponential functionsModule 2   exponential functions
Module 2 exponential functions
 
L16
L16L16
L16
 
Maths chapter wise Important questions
Maths chapter wise Important questionsMaths chapter wise Important questions
Maths chapter wise Important questions
 
Maths important questions for 2018
Maths important questions for 2018Maths important questions for 2018
Maths important questions for 2018
 
Maths imp questions for 2018
Maths imp questions for 2018Maths imp questions for 2018
Maths imp questions for 2018
 
01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf01. Functions-Theory & Solved Examples Module-4.pdf
01. Functions-Theory & Solved Examples Module-4.pdf
 

Recently uploaded

Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCEPRINCE C P
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...anilsa9823
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)Areesha Ahmad
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfSumit Kumar yadav
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencySheetal Arora
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsAArockiyaNisha
 

Recently uploaded (20)

Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCESTERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
STERILITY TESTING OF PHARMACEUTICALS ppt by DR.C.P.PRINCE
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
Lucknow 💋 Russian Call Girls Lucknow Finest Escorts Service 8923113531 Availa...
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls AgencyHire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
Hire 💕 9907093804 Hooghly Call Girls Service Call Girls Agency
 
Natural Polymer Based Nanomaterials
Natural Polymer Based NanomaterialsNatural Polymer Based Nanomaterials
Natural Polymer Based Nanomaterials
 

Recursive Definitions in Discrete Mathmatcs.pptx

  • 1. 1 Recursive Definitions Recursion is a principle closely related to mathematical induction. In a recursive definition, an object is defined in terms of itself. We can recursively define sequences, functions and sets.
  • 2. 2 Recursively Defined Sequences Example: The sequence {an} of powers of 2 is given by an = 2n for n = 0, 1, 2, … . The same sequence can also be defined recursively: a0 = 1 an+1 = 2an for n = 0, 1, 2, … Obviously, induction and recursion are similar principles.
  • 3. 3 Recursively Defined Functions We can use the following method to define a function with the natural numbers as its domain: 1. Specify the value of the function at zero. 2. Give a rule for finding its value at any integer from its values at smaller integers. Such a definition is called recursive or inductive definition.
  • 4. 4 Recursively Defined Functions Example: f(0) = 3 f(n + 1) = 2f(n) + 3 f(0) = 3 f(1) = 2f(0) + 3 = 23 + 3 = 9 f(2) = 2f(1) + 3 = 29 + 3 = 21 f(3) = 2f(2) + 3 = 221 + 3 = 45 f(4) = 2f(3) + 3 = 245 + 3 = 93
  • 5. 5 Recursively Defined Functions How can we recursively define the factorial function f(n) = n! ? f(0) = 1 f(n + 1) = (n + 1)f(n) f(0) = 1 f(1) = 1f(0) = 11 = 1 f(2) = 2f(1) = 21 = 2 f(3) = 3f(2) = 32 = 6 f(4) = 4f(3) = 46 = 24
  • 6. 6 Recursively Defined Functions A famous example: The Fibonacci numbers f(0) = 0, f(1) = 1 f(n) = f(n – 1) + f(n - 2) f(0) = 0 f(1) = 1 f(2) = f(1) + f(0) = 1 + 0 = 1 f(3) = f(2) + f(1) = 1 + 1 = 2 f(4) = f(3) + f(2) = 2 + 1 = 3 f(5) = f(4) + f(3) = 3 + 2 = 5 f(6) = f(5) + f(4) = 5 + 3 = 8
  • 7. 7 Recursively Defined Sets If we want to recursively define a set, we need to provide two things: • an initial set of elements, • rules for the construction of additional elements from elements in the set. Example: Let S be recursively defined by: 3  S (x + y)  S if (x  S) and (y  S) S is the set of positive integers divisible by 3.
  • 8. 8 Recursively Defined Sets Proof: Let A be the set of all positive integers divisible by 3. To show that A = S, we must show that A  S and S  A. Part I: To prove that A  S, we must show that every positive integer divisible by 3 is in S. We will use mathematical induction to show this.
  • 9. 9 Recursively Defined Sets Let P(n) be the statement “3n belongs to S”. Basis step: P(1) is true, because 3 is in S. Inductive step: To show: If P(n) is true, then P(n + 1) is true. Assume 3n is in S. Since 3n is in S and 3 is in S, it follows from the recursive definition of S that 3n + 3 = 3(n + 1) is also in S. Conclusion of Part I: A  S.
  • 10. 10 Recursively Defined Sets Part II: To show: S  A. Basis step: To show: All initial elements of S are in A. 3 is in A. True. Inductive step: To show: (x + y) is in A whenever x and y are in A. If x and y are both in A, it follows that 3 | x and 3 | y. As we already know, it follows that 3 | (x + y). Conclusion of Part II: S  A. Overall conclusion: A = S.
  • 11. 11 Recursively Defined Sets Another example: The well-formed formulas of variables, numerals and operators from {+, -, *, /, ^} are defined by: x is a well-formed formula if x is a numeral or variable. (f + g), (f – g), (f * g), (f / g), (f ^ g) are well-formed formulas if f and g are.
  • 12. 12 Recursively Defined Sets With this definition, we can construct formulas such as: (x – y) ((z / 3) – y) ((z / 3) – (6 + 5)) ((z / (2 * 4)) – (6 + 5))
  • 13. 13 Recursive Algorithms An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input. Example I: Recursive Euclidean Algorithm procedure gcd(a, b: nonnegative integers with a < b) if a = 0 then gcd(a, b) := b else gcd(a, b) := gcd(b mod a, a)
  • 14. 14 Recursive Algorithms Example II: Recursive Fibonacci Algorithm procedure fibo(n: nonnegative integer) if n = 0 then fibo(0) := 0 else if n = 1 then fibo(1) := 1 else fibo(n) := fibo(n – 1) + fibo(n – 2)
  • 15. 15 Recursive Algorithms Recursive Fibonacci Evaluation: f(4) f(3) f(2) f(1) f(0) f(1) f(2) f(1) f(0)
  • 16. 16 Recursive Algorithms procedure iterative_fibo(n: nonnegative integer) if n = 0 then y := 0 else begin x := 0 y := 1 for i := 1 to n-1 begin z := x + y x : = y y := z end end {y is the n-th Fibonacci number}
  • 17. 17 Recursive Algorithms For every recursive algorithm, there is an equivalent iterative algorithm. Recursive algorithms are often shorter, more elegant, and easier to understand than their iterative counterparts. However, iterative algorithms are usually more efficient in their use of space and time.
  • 18. October 3, 2013 Applied Discrete Mathematics Week 5: Mathematical Reasoning 18