[Hernandez 1213A] Cs30 day5

Page 1

Mathematical Induction and Recursion

CS 30 : Discrete Mathematics for Computer Science First Semester, AY 2011-2012

https://sites.google.com/a/dcs.upd.edu.ph/nhsh_classes/cs 30

sablay-logo

Nestine Hope S. Hernandez Algorithms and Complexity Laboratory Department of Computer Science University of the Philippines, Diliman nshernandez@dcs.upd.edu.ph updilseal

Day 5

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Mathematical Logic

sablay-logo

1

Mathematical Induction and Recursion Sequences Recursion Mathematical Induction

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

De nition A sequence is simply an ordered list of real numbers.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Sequences Recursion Mathematical Induction

Mathematical Induction and Recursion

De nition A sequence is simply an ordered list of real numbers. We express a sequence in the form {sn }n≼a and mean that our sequence consists of the terms

sablay-logo

sa , sa + , sa + , sa + , sa + , sa + , . . . 1

2

3

4

5

where a ∈ Z. That is, the sequence has been indexed by the integers

a, a + 1, a + 2, a + 3, a + 4, a + 5, . . . Usually, a = 0 or 1, but that need not be the case. If the indexing is clear in context, then a sequence may be displayed as {sn }, or just a formula for sn may be given.

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

Arithmetic Sequence:

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

Arithmetic Sequence: ∀n ≥ 0, sn = s0 + cn

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

Arithmetic Sequence: ∀n ≥ 0, sn = s0 + cn Geometric Sequence: updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

Arithmetic Sequence: ∀n ≥ 0, sn = s0 + cn Geometric Sequence: ∀n ≥ 0, sn = s0 r n updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Closed Formula vs. Recursive Formula A closed formula for a sequence {sn }n≼a is a formula that expresses the value of sn in terms of the index n. That is, it allows sn to be computed directly from n.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Closed Formula vs. Recursive Formula A closed formula for a sequence {sn }n≼a is a formula that expresses the value of sn in terms of the index n. That is, it allows sn to be computed directly from n. A recursive formula is a formula in which sn is expressed not only in terms of n but also in terms of some of the earlier values sa , sa+1 , sa+2 , sa+3 , . . . , sn−1 in the sequence. More generally, a recursive function is a function whose value for a given input is expressed in terms of its values for smaller inputs.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Examples 1

∀n ≥ 0, sn = n!

2

∀n ≥ 1, sn = n

3

∀n ≥ 4, sn = 7 + 3n

4

∀n ≥ 0, sn = 2n

5

∀n ≥ 1, sn = 2e · 3n

6

∀n ≥ 0, sn = (−1)n (5 + 4n)

sablay-logo

Arithmetic Sequence: ∀n ≥ 0, sn = s0 + cn Geometric Sequence: ∀n ≥ 0, sn = s0 r n updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Sequences Recursion Mathematical Induction

Mathematical Induction and Recursion

More Examples 1 2 3

s = 1, s = 2, and ∀n ≥ 2, sn = sn− + 2sn− s = 1, s = −1, and ∀n ≥ 0, sn+ = 5sn − 3sn+ s = 2, s = 1, and ∀n ≥ 2, sn = (sn− ) − (s n− ) 0

1

0

1

1

2

1

2

2

1

1

2

2

2

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Sequences Recursion Mathematical Induction

Mathematical Induction and Recursion

More Examples 1 2 3 4

s = 1, s = 2, and ∀n ≥ 2, sn = sn− + 2sn− s = 1, s = −1, and ∀n ≥ 0, sn+ = 5sn − 3sn+ s = 2, s = 1, and ∀n ≥ 2, sn = (sn− ) − (s n− ) F (1) = 1, F (2) = 1, and ∀n ≥ 3, F (n) = F (n − 1) + F (n − 2) 0

1

0

1

1

2

1

2

2

1

1

2

2

2

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

An Illustration

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

An Illustration

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Prove the following statements: 1

The sum of the rst n positive integers is

n(n+1) 2

.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Prove the following statements: 1

2

The sum of the rst n positive integers is n P i =0

ri =

r n + 1 −1 r −1 ,

n(n+1) 2

.

∀ integer n ≥ 0, ∀ real numbers r except 1.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Prove the following statements: 1

2

The sum of the rst n positive integers is n P i =0

3

ri =

r n + 1 −1 r −1 ,

n(n+1) 2

.

∀ integer n ≥ 0, ∀ real numbers r except 1.

For all integers n ≥ 0, 22n − 1 is divisible by 3.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Prove the following statements: 1

2

The sum of the rst n positive integers is n P i =0

3 4

ri =

r n + 1 −1 r −1 ,

n(n+1) 2

.

∀ integer n ≥ 0, ∀ real numbers r except 1.

For all integers n ≥ 0, 22n − 1 is divisible by 3. For all integers n ≥ 3, 2n + 1 < 2n .

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Prove the following statements: 1

2

The sum of the rst n positive integers is n P i =0

3 4 5

ri =

r n + 1 −1 r −1 ,

n(n+1) 2

.

∀ integer n ≥ 0, ∀ real numbers r except 1.

For all integers n ≥ 0, 22n − 1 is divisible by 3. For all integers n ≥ 3, 2n + 1 < 2n . The recursive formula: s1 = 2, ∀n ≥ 2, sn = 5sn−1 and the closed formula: sn = 2 · 5n−1 , ∀n ≥ 1 represents the same sequence.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

Another Example Observe that 1 1−4 1−4+9 1 − 4 + 9 − 16 1 − 4 + 9 − 16 + 25

= 1 = −(1 + 2) = 1+2+3 = −(1 + 2 + 3 + 4) = 1+2+3+4+5

sablay-logo

Guess a general formula and prove it by mathematical induction.

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Sequences Recursion Mathematical Induction

Mathematical Induction and Recursion

How about this? Suppose that h0 , h1 , h2 , . . . is a sequence de ned as follows:

h = 1, h = 2, h = 3, hn = hn − + hn − + hn − for all integers n ≥ 3 0

1

1

2

2

3

Prove that hn ≤ 3n for all integers n ≥ 0.

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

The Tower of Hanoi

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

The Tower of Hanoi

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

The Tower of Hanoi

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Sequences Recursion Mathematical Induction

The Tower of Hanoi

sablay-logo

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Mathematical Induction and Recursion

Questions?

sablay-logo

See you next meeting!

updilseal

dcs-logo

Discrete Mathematics for Computer Science

CS 30

acl-logo


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.