Lec08-Induction and Recursion
Lec08-Induction and Recursion
Mathematics
1. Principles of Counting
2. Logic
3. Rules of Inference
4. Proof Methods
5. Set Theory
6. Relations
7. Functions
8. Induction and Recursion
9. Number Theory
10. Probability
11. Graph Theory
12. Graph Theory and Applications
13. Trees
14. Trees and Applications
Outline
1. Mathematical Induction
2. Principle of Mathematical Induction
3. Proving by Mathematical Induction
4. Proving Inequalities
5. Recursive Definitions and Structural Induction
6. Recursively Defined Functions
7. Difference Between Recursion and Induction
Can we conclude that we can reach every rung?
1. Mathematical Induction
Suppose we have an infinite ladder and we want to know whether we can reach
every step on this ladder.
• From (1), we can reach the first rung. Then by applying (2), we can reach the
second rung. Applying (2) again, the third rung. And so on.
• We can apply (2) any number of times to reach any particular rung, no matter
how high up.
• This example motivates proof by mathematical induction.
1. Mathematical Induction
But can we conclude that we are able to reach every rung of this infinite
ladder? The answer is yes, something we can verify using an important proof
technique called mathematical induction.
“We can show that P (n) is true for every positive integer n, where P (n) is
the statement that we can reach the nth rung of the ladder. “
1. Mathematical Induction Base Case → Inductive Hypothesis→ Conclusion
Induction is the branch of mathematics that is used to prove a result, or a formula, or a statement, or a
theorem. It is used to establish the validity of a theorem or result.
1) Base Step: It helps us to prove that the given statement is true for some initial value.
2) Inductive Step: It states that if the theorem is true for the nth term, then the statement is true for
(n+1)th term.
Example: The assertion is that the nth Fibonacci number is at most 2n.
• Mathematical induction can be used to prove statements that assert that P (n) is true for all positive
integers n, where P (n) is a propositional function.
• A proof by mathematical induction has two parts, a basis step, where we show that P (1) is true, and
an inductive step, where we show that for all positive integers k, if P (k) is true, then P (k + 1) is
true.
PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n,
where P (n) is a propositional function, we complete two steps:
BASIS STEP: We verify that P (1) is true.
INDUCTIVE STEP: We show that the conditional statement P (k) → P (k + 1) is true for all positive
integers k.
2. Principle of Mathematical Induction
• In a proof by mathematical induction it is not assumed that P (k) is true for all positive integers! It is
only shown that if it is assumed that P (k) is true, then P (k + 1) is also true.
• When we use mathematical induction to prove a theorem, we first show that P (1) is true. Then we
know that P(2) is true, because P(1) implies P(2). Further, we know that P(3) is true, because P(2)
implies P(3). Continuing along these lines, we see that P(n) is true for every positive integer n.
Let P (n) be the proposition that the
sum of the first n positive integers,
1 + 2 + · · · n = n (n + 1)/2.
3. Prove by Mathematical Induction
Basis Step: We need to prove P(1) is true. 1(1 + 1)/2 = 1. • This last equation shows that P (k + 1)
Inductive Step: Assume true for P(k). is true under the assumption that P (k)
The inductive hypothesis is is true. This completes the inductive
step.
• We have completed the basis step and
the inductive step, so by mathematical
induction we know that P (n) is true for
Under this assumption, it must be shown that P (k + 1) is true, all positive integers n. That is, we have
proven that 1+2+ · · · +n = n (n + 1)/2
for all positive integers n.
3. Prove by Mathematical Induction
Example:
Use mathematical induction to prove that n3 − n is divisible by 3, for every positive integer n.
Let P(n) be the proposition that n3 − n is divisible by 3.
Basis Step: P(1) is true since 13 − 1 = 0, which is divisible by 3.
Inductive Step: Assume P(k) holds, i.e., k3 − k is divisible by 3, for an arbitrary positive integer k. To
show that P(k + 1) follows:
(k + 1)3 − (k + 1) = (k3 + 3k2 + 3k + 1) − (k + 1)
= (k3 − k) + 3(k2 + k)
By the inductive hypothesis, the first term (k3 − k) is divisible by 3 and the second term is divisible by 3
since it is an integer multiplied by 3.
Example: Conjecture and prove correct a formula for the sum of the first n positive odd integers. Then prove
your conjecture.
We have: 1= 1, 1 + 3 = 4, 1 + 3 + 5 = 9, 1 + 3 + 5 + 7 = 16, 1 + 3 + 5 + 7 + 9 = 25.
1 + 3 + 5 + ∙∙∙+ (2n − 1) = n2
We can conjecture that the sum of the first n positive odd integers is n2,
Inductive Hypothesis: 1 + 3 + 5 + ∙∙∙ + (2k − 1) = k2
Mathematical induction can be used to prove a variety of inequalities that hold for all positive integers
greater than a particular positive integer.
Example:
Use mathematical induction to prove that n < 2n for all positive integers n.
Example:
Use mathematical induction to prove that 2n < n!, for every integer n ≥ 4.
Note that here the basis step is P(4), since P(0), P(1), P(2), and P(3) are all false.
5. Recursive Definitions and Structural Induction
• Sometimes it is difficult to define an object explicitly. It may be easy to define this object in terms of
itself. This process is called recursion.
• We can use recursion to define sequences, functions, and sets.
a0 = 1 an+1 = 2an
Definition:
A recursive or inductive definition of a function consists of two steps.
Basis Step: Specify the value of the function at zero.
Recursive Step: Give a rule for finding its value at an integer from its values at smaller integers.
A function f(n) is the same as a sequence a0, a1, … , where ai, where f ( i ) = ai.
6. Recursively Defined Functions
Example:
The first part of the definition is
Suppose that f is defined recursively by:
f(0) = 3, f(n + 1) = 2f(n) + 3
Find f(1), f(2), f(3), f(4).
The second part is
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
6. Recursively Defined Functions
Example : Example :
The Fibonacci numbers are Give a recursive definition of the sequence {an} n = 1, 2, 3, … if an = 5n
defined as follows: a1 = 5
f0 = 0 a2 = 52 = 5.5
f1 = 1 a3 = 53 = 52.5
fn = fn−1 + fn−2 a4 = 54 = 53.5
Find f2, f3 , f4 , f5 . a1 = 5
f2 = f1 + f0 = 1 + 0 = 1 an+1 = 5an , . n⩾1
f3 = f2 + f1 = 1 + 1 = 2
f4 = f3 + f2 = 2 + 1 = 3
f5 = f4 + f3 = 3 + 2 = 5
7. Difference Between Recursion and Induction
Recursion Induction
Recursion is the process in which a function is called again
1. Induction is the way of proving a mathematical statement.
and again until some base condition is met.
3. It starts from nth term till the base case. It starts from the initial till (n+1)th term.
We backtrack at each step to replace the previous values We just prove that the statement is true for n = 1. Then we
5.
with the answers using the function. assume that n = k is true. Then we prove for n = k+1.