0% found this document useful (0 votes)
19 views5 pages

Solutions Week 6

Uploaded by

bill19012004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Solutions Week 6

Uploaded by

bill19012004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MATH2081 | MATH2328: Math for Computing

1
Lecturers: Dr Nguyen Hieu Thao & Dr Jeff Nijsse
Email: [email protected]

Tutorial Solutions: Induction, Recursion


and Recurrence
(2024C, Week 6)1

1. Prove by induction that for every positive integer n, it holds that

n(n + 1)(n + 2)(3n + 5)


1 · 22 + 2 · 32 + · · · + n · (n + 1)2 = . (1)
12

Proof.

• Base case. For n = 1, (1) becomes

1(1 + 1)(1 + 2)(3 + 5)


1 · 22 = ,
12
which is true.
• Induction hypothesis. Assume that (1) is true for all positive integers n ≤ k (k ≥ 1).
• Induction step. It suffices to prove that (1) is true for n = k + 1. That is,

(k + 1)(k + 2)(k + 3)(3k + 8)


1 · 22 + 2 · 32 + · · · + k · (k + 1)2 + (k + 1) · (k + 2)2 = .
12
Indeed,

k(k + 1)(k + 2)(3k + 5)


LHS = + (k + 1) · (k + 2)2 (induction hypothesis for n = k)
12
(k + 1)(k + 2)(k(3k + 5) + 12(k + 2))
=
12
(k + 1)(k + 2)(3k 2 + 17k + 24)
=
12
(k + 1)(k + 2)(k + 3)(3k + 8)
= = RHS.
12
That is, equation (1) is also true for n = k + 1, and hence the proof is complete. 

1 Some of the content of this document is taken from the book [1].
2

2. Write a recursive function finding the minimum of a finite sequence of numbers.


Solution. Recursive function:

min(x1 , x2 , · · · , xn ) :
if n = 1 : return x1
else if n = 2 : if x1 ≤ x2 return x1 , else return x2
else : return min (min(x1 , x2 , . . . , xn−1 ), xn ) .

3. Write a recursive function reversing a finite sequence of numbers.


Solution. Recursive function:

reverse(x1 , x2 , · · · , xn ) :
if n = 1 : return x1
else : return xn , reverse (x1 , x2 , . . . , xn−1 ) .

4. The sequence g1 , g2 , . . . is defined by the recurrence relation

gn = gn−1 + gn−2 + 1, n ≥ 3,

and initial conditions g1 = 1, g2 = 3. By using mathematical induction show that

gn = 2fn+1 − 1, n ≥ 1, (2)

where f1 , f2 , . . . is the Fibonacci sequence.

Proof.
• Base case. For n = 1, (2) becomes g1 = 1 = 2f2 − 1 = 2 − 1 which is true because
g1 = 1 and f2 = 1.

For n = 2, (2) becomes g2 = 3 = 2f3 − 1 = 4 − 1 which is true because g2 = 3 and


f3 = 2.
• Induction hypothesis. Assume that (2) is true for all positive integers n ≤ k (k ≥ 2).
• Induction step. It suffices to prove that (2) is true for n = k + 1. That is,

gk+1 = 2fk+2 − 1.

Indeed, by definition of g, the induction hypothesis and definition of f , we have

gk+1 = gk + gk−1 + 1 (definition of g)


= 2fk+1 − 1 + 2fk − 1 + 1 (induction hypothesis for n = k and n = k − 1)
= 2(fk+1 + fk ) − 1
= 2fk+2 − 1 (definition of f ).

That is, equation (2) is true for n = k + 1, and hence the proof is complete. 
3

5. The Lucas sequence L1 , L2 , . . . is defined by the recurrence relation


Ln = Ln−1 + Ln−2 , n ≥ 3,
and the initial conditions L1 = 1, L2 = 3.

(a) Find the values of L3 , L4 , and L5 .


Solution. L3 = 4, L4 = 7, L5 = 11.
(b) Show that
Ln+2 = fn+1 + fn+3 , n ≥ 1, (3)
where f1 , f2 , . . . is the Fibonacci sequence.
Proof.
• Base case. For n = 1, (3) becomes L3 = 4 = f2 + f4 = 1 + 3, which is true because
L3 = 4, f2 = 1 and f4 = 3.
For n = 2, (3) becomes L4 = 7 = f3 + f5 = 2 + 5, which is true because L4 = 7,
f3 = 2 and f5 = 5.
• Induction hypothesis. Assume that (3) is true for all positive integers n ≤ k (k ≥ 2).

• Induction step. It suffices to prove that (3) is true for n = k + 1. That is,
Lk+3 = fk+2 + fk+4 .
Indeed, by definition of L, the induction hypothesis and definition of f , we have
Lk+3 = Lk+2 + Lk+1 (definition of L)
= fk+1 + fk+3 + fk + fk+2 (induction hypothesis for n = k and n = k − 1)
= fk+1 + fk + fk+3 + fk+2
= fk+2 + fk+4 (definition of f ).
That is, equation (3) is true for n = k + 1, and hence the proof is complete. 

6. Solve the recurrence relation with the given initial conditions.


(a) 2an = 7an−1 − 3an−2 with a0 = a1 = 1.
Solution. Solve the equation:
7 3 1
t2 − t + = 0 ⇔ t1 = 3 ∨ t2 = .
2 2 2
Then
an = b · 3n + d · 2−n
where b and d are constants.

To find b and d, we use the initial conditions:


( (
1
a0 = b + d = 1 b= 5

a1 = 3b + 12 d = 1 d= 4
5

Hence,
1 n 4 −n
an = ·4 + ·2 .
5 5
4

√ √ √
(b) an = an−1 + 2 an−2 with a0 = a1 = 1.

Solution. Set bn = an . We get b0 = b1 = 1 and bn = bn−1 + 2bn−2 .
Solve the equation:
t2 − t − 2 = 0 ⇔ t1 = −1 ∨ t2 = 2.
Then
bn = b · (−1)n + d · 2n
where b and d are constants.
To find b and d, we use the initial conditions:
( (
1
b0 = b + d = 1 b= 3
⇔ 2
b1 = −b + 2d = 1 d= 3

Then,
1 2
bn = · (−1)n + · 2n .
3 3
Hence,
 2
1 2
an = b2n = · (−1)n + · 2n .
3 3

7. Find a recursive formula of the function f (n) = 2n + 5.


Solution. f (1) = 7, f (n) = f (n − 1) + 2 (∀n ≥ 2) .

8. The recursive formula of f (n) is a linear function f (n) = a · f (n − 1) + b, where a and b


are constants. Find a and b given that f (1) = 2, f (2) = 7 and f (3) = 17.
Solution. Solve the system of equations:
( ( (
f (2) = af (1) + b 7 = 2a + b a=2
⇔ ⇔
f (3) = af (2) + b 17 = 7a + b b=3

Hence, the recursive version of f is: f (1) = 2 and f (n) = 2f (n − 1) + 3 (∀n ≥ 2).

9. Consider the following recursive function f : N+ → N+ :

f (1) = 1, f (n) = 10 · f (n − 1) + 1 (∀n ≥ 2).

(a) Compute f (2), f (3) and f (4).

• f (2) = 10f (1) + 1 = 10 + 1 = 11


• f (3) = 10f (2) + 1 = 102 + 10 + 1 = 111
• f (4) = 10f (3) + 1 = 103 + 102 + 10 + 1 = 1111
5

(b) Prove by induction that f takes the following explicit form:

10n − 1
f (n) = , for all n ≥ 1. (4)
9
Proof.
• Base case. For n = 1, (4) becomes
10 − 1
f (1) = = 1,
9
which is true.

• Induction hypothesis. Suppose that (4) is true for all positive integers n ≤ k
(k ≥ 1). In particular,
10k − 1
f (k) = .
9

• Induction step. It suffices to prove that (4) is true for n = k + 1. That is,

10k+1 − 1
f (k + 1) = .
9
Indeed,
10k − 1 10k+1 − 1
f (k + 1) = 10f (k) + 1 = 10 +1= .
9 9

That is, equation (4) is true for n = k + 1, and hence the proof is complete. 

References
1. Johnsonbaugh, R.: Discrete Mathematics - Eighth Edition. Pearson Education, New York
(2018).

You might also like