# Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar.

## Presentation on theme: "Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar."— Presentation transcript:

Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar

Contents  Mathematical Inductions  Strong Induction  Recursion

Mathematical Induction

Suppose we have an infinite ladder: We can reach the first rung of the ladder. If we can reach a particular rung of the ladder, then we can reach the next rung. 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. Climbing an Infinite Ladder Ladder

Mathematical Induction Mathematical induction is an extremely important proof technique. It is extremely important to note that mathematical induction can be used only to prove results obtained. It is not a tool for discovering formulae or theorems.

Let P(n) be a propositional (formula),satisfies that following condition, Step#1: for n=1 p(1) is true. “Case 1 is satisfied” Step#2: The result (formula) is true for n=k (where k is integer +ive) p(k) is true. “case 2 is satisfied” Step#3: now we have to show that, the result is true for n=k+1, if p(k+1) is true then proposition p(n) is true for all positive integer value of n. Definition:-

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: The proposition P(1) is true. INDUCTIVE STEP: The proposition p(k) is true for n=k also p(k+1) is show to be true for n=k+1, hence both P(k) → P(k + 1) is true for all positive integers k. To complete the inductive step, assuming the inductive hypothesis that P(k) holds for an arbitrary integer k, show that must P(k + 1) be true.

Climbing an Infinite Ladder Example: Basis Step: By (1), we can reach rung 1. Inductive Step: Assume the inductive hypothesis that we can reach rung k. Then by (2), we can reach rung k + 1. Hence, P(k) → P(k + 1) is true for all positive integers k. We can reach every rung on the ladder.

Examples:-

Q#1 Show that if n is a positive integer, then 1 + 2+· · ·+n = n(n + 1)/2 We prove this formula by mathematical induction Basic step:- Let p(n) : 1 + 2+· · ·+n = n(n + 1)/2 L.H.S for n=1 R.H.S p(1)=n(n+1)/2 p(1)=1 =1(1+1)/2 =2/2 =1 L.H.S=R.H.S  (case 1 is satisfied) it is true. Inductive step:- Now assume that p(k) it is true for n=k (where k is +ive integer) p(k) : 1 + 2+· · ·+k = k(k + 1)/2  eq # 1 (case 2 is satisfied)

Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1. 1 + 2+· · ·+k + (k + 1) = (k + 1)[(k + 1) + 1]/2 = (k + 1)(k + 2)/2  eq # 2 When we add (k + 1) to both sides of the equation in P(k), we obtain 1 + 2+· · ·+k + (k + 1)= k(k + 1)/2+ (k + 1) = k(k + 1) + 2(k + 1)/2 = (k + 1)(k + 2)/2 Which is same as eq 2. This last equation shows that P(k + 1) is true under the assumption that P(k) is true. This completes the inductive step. Hence,therefore it is true for all +ive integer n.

Q#2 Conjecture a formula for the sum of the first n positive odd integers. Then prove your conjecture using mathematical induction. The sums of the first n positive odd integers n = 1,3,5,7,9,11..... And so on. Positive odd numbersSum of odd numbers 1 (1) 2 =1 3 (2) 2 =4 5 (3) 2 =9 7 (4) 2 =16 9 (5) 2 =25 4 16 9 25

From these values it is reasonable to conjecture that the sum of the first n positive odd integers is n 2. 1 + 3 + 5+· · ·+(2n − 1) = n 2 SOLUTION: Basic step :- Let P(n) : 1 + 3 + 5+· · ·+(2n − 1) = n 2 L.H.S R.H.S for n=1 P(1)=(2(1)-1) p(1)=(1) 2 =(2-1) =1 =1 SoL.H.S=R.H.S  (case 1 is satisfied) it is true. Inductive step:- Now assume that p(k) it is true for n=k (where k is +ive integer) p(k) : 1 + 3 + 5+· · ·+(2k − 1) = k 2  eq # 1

Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1 1 + 3 + 5+· · ·+(2k-1) + (2(k+1)− 1) = (k+1) 2 = (k+1) 2  eq # 2 When we add (2k + 1) to both sides of the equation in P(k), we obtain 1 + 3 + 5+· · ·+(2k − 1)+ (2k+1) = k 2 + (2k+1) =k 2 + 2k+1 =k 2 +k + k+1 = (k+1)(k+1)= (k+1) 2 Which is same as eq 2. Since the result is true for n=K+1, therefore it is true for all +ive integer n.

Note:- some time we need to show that p(n) is true for n=k, n=k+1….. Where k is an integer other than 1. We can use mathematical induction to accomplish this as long as we change the basis step. This proves that the formula is valid for all non negative integers. So that we need to prove that p(n) is true for n=0, 1, 2, 3, ………..

Q#3 1 + 2 + 2 2 +· · ·+ 2 n = 2 n+1 − 1 for all nonnegative integers n. We prove this formula by mathematical induction Basic step:- Let p(n) : 1 + 2 + 2 2 +· · ·+ 2 n = 2 n+1 − 1 L.H.S for n=0 R.H.S p(0)= 2 n+1 − 1 p(0)=2 0 = 2 0+1 − 1 =1 = 2 − 1 =1 L.H.S=R.H.S  (case 1 is satisfied) it is true. Inductive step:- Now assume that p(k) it is true for n=k (where k is +ive integer) p(k) : 1 + 2 + 2 2 +· · ·+ 2 k = 2 k+1 − 1  eq # 1 (case 2 is satisfied)

Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1. 1 + 2 + 2 2 +· · ·+ 2 k + 2 k+1 = 2 (k+1)+1 − 1 = 2 (k+2) − 1  eq # 2 When we add 2 k+1 to both sides of the equation in P(k), we obtain 1 + 2 + 2 2 +· · ·+ 2 k + 2 k+1 = 2 k+1 − 1 + 2 k+1 =2. 2 k+1 − 1 = 2 (k+2) − 1 Which is same as eq 2. Since the result is true for n=K+1, therefore it is true for all non negative integer n.

Summation Formula by Mathematical Induction

Q#1 Show that if n is a positive integer, then We prove this formula by mathematical induction Basic step:- Let p(n) : L.H.S for n=1 R.H.S p(1)=n(n+1)/2 =1(1+1)/2 =2/2 =1 L.H.S=R.H.S  (case 1 is satisfied) it is true. Inductive step:- Now assume that p(k) it is true for n=k (where k is +ive integer) p(k) :  eq # 1 (case 2 is satisfied)

Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1. = (k + 1)[(k + 1) + 1]/2 = (k + 1)(k + 2)/2  eq # 2 When we add (k + 1) to both sides of the equation in P(k), we obtain =k(k + 1)/2+ (k + 1) = k(k + 1) + 2(k + 1)/2 = (k + 1)(k + 2)/2 Which is same as eq 2. This last equation shows that P(k + 1) is true under the assumption that P(k) is true. This completes the inductive step. Since the result is true for n=K+1, therefore it is true for all +ive integer n.

PROVING INEQUALITIES

Q#1 Use mathematical induction to prove the inequality n < 2 n for all positive integers n. Solution:- Basic step:- Let p(n) : n < 2 n for n=1 1< 2 1 1<2 (case 1 is satisfied) it is true Inductive step:- Now we assume that it is true for n=k (k is integer +ive) k< 2 k (case 2 is satisfied) it is true Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1. (k+1) < 2 k+1  eq # 2

When we add 1 to both sides of the equation in P(k), we obtain k < 2k, and then note that 1 ≤ 2k. k+1< 2 k + 1 k+1< 2 k + 2 k k+1< 2.2 k k+1< 2 k+1 Which is same as eq 2. This shows that P(k + 1) is true, namely, that k+1< 2 k+1 based on the assumption that P(k) is true. The induction step is complete. Hence the result is true for n=K+1, therefore it is true for all +ive integer n.

Q#1 Use mathematical induction to prove that 2 n < n ! For n≥ 4. (i.e. n=4,5,6………) Solution:- Basic step:- Let p(n) : 2 n < n ! for n=4 2 4 < 4! 16<4.3.2.1 16 < 24 (case 1 is satisfied) it is true Inductive step:- Now we assume that it is true for n=k (k is integer +ive) 2 k < k! (case 2 is satisfied) it is true  eq # 1

Now we have to show that, under the assumption the result is true for p(k+1) for n=k+1. 2 k+1 < (k+1)!  eq # 2 From eq # 1 2 k < k! 2.2 k / 2< k! (multiply or divide by 2 on L.H.S) 2 k+1 / 2 < k! (multiply (k+1) on both side) (k+1).2 k+1 /2< (k+1).k! (neglected k+1/2 from L.H.S) 2 k+1 < (k+1)! Which is same as eq 2. This shows that P(k + 1) is true, namely, that 2 k+1 < (k+1)! based on the assumption that P(k) is true. The induction step is complete. Hence it is true for every integer n≥ 4.

Strong Induction

Strong Induction: To prove that P(n) is true for all positive integers n, where P(n) is a propositional function, complete two steps: BASIS STEP: We verify that the proposition P(1) is true. INDUCTIVE STEP: We show that the conditional statement [P(1) ∧ P(2) ∧ · · · ∧ P(k)] → P(k + 1) is true for all positive integers k.

Recursion

Definition Sometimes it is difficult to define an object explicitly. However, 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.  the sequence of powers of 2 is given by an = 2 n for n = 0, 1, 2,....  The sequence of powers of 2 can also be defined  by giving the first term of the sequence, namely, a0 = 1, and a rule for finding a term of the sequence from the previous one, namely: a n+1 =2a n for n = 0, 1, 2,....

. For instance, the picture is produced recursively. First, an original picture is given. Then a process of successively superimposing centered smaller pictures on top of the previous pictures is carried out.

Recursively Defined Functions We use two steps to define a function with the set of nonnegative integers as its domain: 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. Such a definition is called a recursive or inductive definition.

EXAMPLES

Q # 1 Suppose that f is defined recursively by f (0) = 3, f (n + 1) = 2f (n) + 3. Find f (1), f (2), f (3), and f (4). Solution: From the recursive definition it follows that f (n + 1) = 2f (n) + 3 with f (0) = 3 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.

Q # 2 find the f(1), f(2),f(3) and f(4) if f(n) is defined recursively by f(0)=1 for n=0,1,2,3,4………… f(n+1)=3f(n) Solution: from recursively definition. f(n+1)=3f(n) with f(0)=1 n=0 : f(1)=3f(0)=3(1)=3 n=1 : f(2)=3f(1)=3(3)=9 n=2 : f(3)=3f(2)=3(9)=27 n=3 : f(4)=3f(3)=3(27)=81

Q # 3 Give an inductive (recursive) definition of the factorial function F(n) = n!. solution: initial value : F(0) = 1 recursive form : F(n+1) = (n+1)! = n!  (n+1) = F(n)  (n+1) which is deserved rule

Q # 4 Give a recursive definition of: Solution: The first part of the recursive definition is a k = a 0 + a 1 + a 2 +……… a n (1) For initial value : ( n=0) (2) For finding a rule : (k=n+1) = a 0 + a 1 + a 2 +……… a n + a n+1 ={ a 0 + a 1 + a 2 +……… a n } + a n+1 = + a n+1 which is deserved rule

Q # 5 Give the recursive definition of the sequence { a n }. n= 1,2,3,4,5,6…….. a n = 6n Solution: a n = 6n (i) For initial value : n=1 a 1 = 6(1) a 1 = 6 (ii) For finding value: a n+1 = 6(n+1)  a n+1 = 6n+6for a n = 6n a n+1 = a n + 6 n>=1

Download ppt "Induction and Recursion by: Mohsin tahir (GL) Numan-ul-haq Waqas akram Rao arslan Ali asghar."

Similar presentations