3.4 Mathematical Induction and Recursion PDF
3.4 Mathematical Induction and Recursion PDF
and Recursion
COMP 251
1
Goals
• To define the Principle of Mathematical
Induction.
• To provide examples of it’s application to N
and Z+.
• To demonstrate the relationship between the
Principle of Mathematical Induction and
recursive sets.
• To introduce recursion from a mathematical
perspective.
2
Textbook
3
Consider the Sum of n Positive Integers
4
Consider the Sum of n Positive Integers
A Geometric Proof
5
Consider the Sum of n Positive Integers
mZ+ nZ+ (m n)
Every nonempty subset of Z+ contains a smallest element.
7
We Begin With
The Well-Ordering Principle
mZ+ nZ+ (m n)
Every nonempty subset of Z+ contains a smallest element.
8
The Principle of Mathematical Induction
Basic idea:
• Two steps
1. The first domino falls.
2. When any domino falls, the next one will fall too.
9
The Principle of Mathematical Induction
10
The Principle of Mathematical Induction
11
The Principle of Mathematical Induction
P(1) BS
P(k) P(k+1) kZ+ IS
P(n) nZ+P(n)
P(1)
P(1) P(2)
P(2)
P(2) P(3)
P(3)
…
12
The Sum of the First n Integers
13
The Sum of the First n Integers
14
The Sum of the First n Integers
15
The Sum of the First n Integers
16
Sum of Even Positive Integers
17
Sum of Even Positive Integers
18
Sum of Even Positive Integers
19
Sum of Even Positive Integers
QED
20
Sum of Squares
21
Sum of Squares
22
Sum of Squares
23
Sum of Squares
24
Geometric Series
25
Geometric Series
26
Geometric Series
27
Geometric Series
28
Factorial vs. Exponential Dominance
29
Factorial vs. Exponential Dominance
30
Factorial vs. Exponential Dominance
31
Factorial vs. Exponential Dominance
32
Factorial vs. Exponential Dominance
33
Recursion
34
Definition
• Recursion occurs when a thing is defined in
terms of itself or of its type.
• Recursion in computing science is a method
where the solution to a problem depends on
solutions to smaller instances of the same
problem (as opposed to iteration) itself or of
its type.
35
Recursively Defined Functions
36
Recursively Defined Methods in Java
37
Recursively Defined Methods in Java
38
Recursively Defined Methods in Java
39
Recursively Defined Methods in Java
40
Recursively Defined Methods in Java
41
Recursively Defined Methods in Java
43
Iteratively Defined Factorial
44
45
46
Recursively Defined Sequences
Consider a physical process in which a given population, x, doubles over a
particular time, t:
xt+1 = kxt
x0 = a 0
This is known as a recursive set (a relation that is defined in terms of
smaller units of itself and requiring a condition to get it started).
48
Recursively Defined Sequences
Recall reproducing rabbits – The Fibonacci Sequence
50
Is there an Biological Basis for
Beauty?
The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:
• Only one disk may be moved at a time.
• Each move consists of taking the upper disk from one of the rods and 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.
52
Recursive Sets – Tower of Hanoi
53
Recursive Sets – Tower of Hanoi
54
Recursive Sets – Tower of Hanoi
55
Recursive Sets – Tower of Hanoi
Hn-1 + 1
2Hn-1 + 1
Hn-1
56
Recursive Sets – Tower of Hanoi
57
Recursive Sets – Tower of Hanoi
Require Proof
58
Recursive Sets – Tower of Hanoi
• The minimum number Hn of moves required to transfer a tower of n disks satisfies
the open form expression, Hn = 2Hn-1 + 1 n>1 with H1 = 1 (one move for the case
of one disk).
• We want to prove the closed form expression, Hn = 2n – 1 nZ+.
59
How Many Moves For 64 Disks?
The objective of the puzzle is to move the entire stack to another rod, obeying the following rules:
• Only one disk may be moved at a time.
• Each move consists of taking the upper disk from one of the rods and 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.
60
How Many Moves For 64 Disks?
61
Recursion
• We see how the Principle of Mathematical
Induction lends itself naturally to recursion
(initial condition/base step and recursive
step/inductive step).
62
Recursion
• We see how the Principle of Mathematical
Induction lends itself naturally to recursion
(initial condition/base step and recursive
step/inductive step).
• Some computer programs are recursive in
nature and, hence, can be proven correct
using the PMI.
63
Recursion
• We see how the Principle of Mathematical
Induction lends itself naturally to recursion
(initial condition/base step and recursive
step/inductive step).
• Some computer programs are recursive in
nature and, hence, can be proven correct
using the PMI.
• You are responsible for Maryam’s PDF.
64
Stackoverflow
65
END PRESENTATION
66