Download presentation
Presentation is loading. Please wait.
Published byAshlee Payne Modified over 9 years ago
1
INDUCTION AND RECURSION
2
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. Expressed as a rule of inference, this proof technique can be stated as
3
Example
4
This last equation shows that P (k + 1) is true under the assumption that P(k) 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 all positive integers n. That is, we have proven that 1 + 2 +... + n = n(n + 1 )/2 for all positive integers n.
5
Example
8
Recursion
9
Recursively Defined Functions Simplest case: One way to define a function f:N S (for any set S) or series a n =f(n) is to: Define f(0). For n>0, define f(n) in terms of f(0),…,f(n − 1).
10
Another Example Suppose we define f(n) for all n N recursively by: Let f(0)=3 For all n N, let f(n+1)=2f(n)+3 What are the values of the following? 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
11
Recursive definition of Factorial Give a recursive definition of the factorial function F(n) : n! Base case: F(0) : 1 Recursive part: F(n) : n F(n-1). F(1)=1 F(2)=2 F(3)=6
12
The Fibonacci Series The Fibonacci series f n 0 is a famous series defined by: f 0 : 0, f 1 : 1, f n 2 : f n − 1 + f n − 2 0 11 23 58 13
13
Example Give a recursive definition of a n, where a is a nonzero real number and n is a nonnegative integer.
14
Example
15
Recursive algorithm Factorial Algorithm procedure factorial( n: nonnegative integer) if n = 0 then factorial(n) : = 1 else factorial(n) := n ·factorial(n - 1 )
16
Example Algorithm to calculate a n procedure power( a : nonzero real number, n : nonnegative integer ) if n = 0 then power(a, n) : = 1 else power(a, n) := a · power(a, n - 1)
17
Example GCD 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)
18
THANK YOU
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.