Date post: | 12-Jan-2016 |
Category: |
Documents |
Upload: | ashlee-payne |
View: | 217 times |
Download: | 0 times |
INDUCTION AND RECURSION
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
Example
Example
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.
Example
Recursion
Recursively Defined Functions Simplest case: One way to define a
function f:NS (for any set S) or series an=f(n) is to: Define f(0). For n>0, define f(n) in terms of f(0),
…,f(n−1).
Another Example
Suppose we define f(n) for all nN recursively by:
Let f(0)=3For all nN, 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
Recursive definition of Factorial
Give a recursive definition of the factorial function F(n) : n!
Base case: F(0) : 1Recursive part: F(n) : n F(n-1).
F(1)=1 F(2)=2 F(3)=6
The Fibonacci Series
The Fibonacci series fn0 is a famous series defined by:
f0 : 0, f1 : 1, fn2 : fn−1 + fn−2
0
1 1
2 3
5 8
13
Example
Give a recursive definition of an, where a is a nonzero real number and n is a nonnegative integer.
Example
Recursive algorithm
Factorial Algorithmprocedure factorial( n: nonnegative integer)if n = 0
then factorial(n) : = 1else
factorial(n) := n ·factorial(n - 1 )
Example
Algorithm to calculate an
procedure power(a : nonzero real number, n :
nonnegative integer)if n = 0
then power(a , n) : = 1else
power(a , n) := a · power(a , n - 1)
Example
GCD Algorithmprocedure gcd(a , b: nonnegative integers with a < b)if a = 0
then gcd(a , b) := belse
gcd(a , b) := gcd(b mod a , a)
THANK YOU