0% found this document useful (0 votes)
106 views66 pages

3.4 Mathematical Induction and Recursion PDF

The document discusses mathematical induction, recursion, and their relationship. It provides examples of using induction to prove properties of recursively defined sequences, like the sum of the first n integers and the Fibonacci sequence. Recursion in computing is introduced, with examples like recursively defined functions in Java and the Tower of Hanoi puzzle. The principle of mathematical induction is shown to lend itself naturally to the definition and proof of recursive sets and programs.

Uploaded by

sheikh sayeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views66 pages

3.4 Mathematical Induction and Recursion PDF

The document discusses mathematical induction, recursion, and their relationship. It provides examples of using induction to prove properties of recursively defined sequences, like the sum of the first n integers and the Fibonacci sequence. Recursion in computing is introduced, with examples like recursively defined functions in Java and the Tower of Hanoi puzzle. The principle of mathematical induction is shown to lend itself naturally to the definition and proof of recursive sets and programs.

Uploaded by

sheikh sayeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Mathematical Induction

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

We require a formal proof technique for Z+ rather than a geometric proof.


6
We Begin With
The Well-Ordering Principle

mZ+ nZ+ (m  n)
Every nonempty subset of Z+ contains a smallest element.

7
We Begin With
The Well-Ordering Principle

mZ+ nZ+ (m  n)
Every nonempty subset of Z+ contains a smallest element.

This is equivalent to PMI


(The Principle of Mathematical Induction)

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

P{P(1)  kZ+[P(k)  P(k+1)]}  nZ+P(n)

10
The Principle of Mathematical Induction

P{P(1)  kZ+[P(k)  P(k+1)]}  nZ+P(n)

ALGORITHM (viewed as three steps):


1. Verify P(1) is true – BASIS STEP (BS)
2. Assume nP(n) – INDUCTIVE HYPOTHESIS (IH)
3. Verify P(k)  P(k+1) kZ+ - INDUCTIVE STEP (IS)

11
The Principle of Mathematical Induction

THIS IS REPEATED APPLICATIONS OF MODUS PONENS

P(1) BS
P(k)  P(k+1) kZ+ IS
P(n) nZ+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

Classic example – the Factorial Function:

36
Recursively Defined Methods in Java

37
Recursively Defined Methods in Java

Read Maryam’s Recursion PDF

38
Recursively Defined Methods in Java

39
Recursively Defined Methods in Java

40
Recursively Defined Methods in Java

41
Recursively Defined Methods in Java

Every call to the method creates a new set of local


variables (Stack Frame)! 42
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

The process requires an initial condition:

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).

This is the discrete description of exponential growth/decay.


47
Recursively Defined Sequences
Reproducing rabbits – The Fibonacci Sequence

48
Recursively Defined Sequences
Recall reproducing rabbits – The Fibonacci Sequence

Recursive f1=1, f2=1,


Set fn = fn-1 + fn-2
49
Recursively Defined Sequences

Fibonacci numbers appear


throughout nature

50
Is there an Biological Basis for
Beauty?

The Golden Ratio (Fibonacci Numbers)

where is the golden ratio. 51


Recursive Sets – Tower of Hanoi

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

“Open form expression”

“Closed form expression”

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 nZ+.

• PROOF (by PMI):


– BS, n=1: H1 = 1 = 21 – 1 =1 (OK)
– IH: Assume Hn = 2n – 1 kZ+.
– IS:
Hn+1 = 2Hn + 1 Derive the (n+1)st step from the nth step.
= 2[2n – 1] + 1 Apply the IH.
= 2n+1 – 2 + 1 Basic algebra.
= 2n+1 – 1
QED

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

• Also, please read the following discussion:


https://stackoverflow.com/questions/23932519/java-recursion-example

65
END PRESENTATION

66

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy