MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS 1

1
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
1
INSTITIÚID TEICNEOLAÍOCHTA CHEATHARLACH
INSTITUTE OF TECHNOLOGY CARLOW
MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
1
Introduction
Recurrence relations, recursive algorithms, and mathematical induction are closely related. In all
three, prior instances of the current case are assumed known. A recurrence relation uses prior values in
a sequence to complete the current value. A recursive algorithm uses smaller instances of the current
input to process the current input. The inductive step in a proof by mathematical induction assumes
the truth of prior instances of the statement to prove the truth of the current statement.
2
The Principle of Mathematical Induction
In order to prove that certain results hold for all positive integers, the Principle of Mathematical
Induction is often employed. These results may, for example, be summation formulae or results from
number theory relating to divisibility. We will also illustrate how the principle is used to establish the
truth of inequalities. Firstly, some preliminary information.
2.1
Integers and Natural Numbers
An integer is a whole number. We denote the the set (or collection) of integers by Z. (The word for
‘number’ in German is ‘Zahl’.)
Z = {.......... − 3, −2, −1, 0, 1, 2, 3, ............}
2
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
2
We specify important subsets of this set.
The non-negative integers are Z+ = {0, 1, 2, 3, ............}.
The non-positive integers are Z− = {0, −1, −2, −3, ............}.
The positive integers are Z+
0 = {1, 2, 3, 4, ..........}
The negative integers are Z−
0 = {−1, −2, −3, −4, ..........}
The natural numbers are the positive integers 1,2,3,4,..........
N = {1, 2, 3, 4, ..........}
In some books 0 appears in this set. Note that the terms ‘natural number’ and ‘positive integer’
refer to the same objects.
2.2
The Well-Ordered Principle
Every nonempty set of positive integers contains a smallest member.
+
+
So, clearly, the set N is well ordered as are the sets Z+ and Z+
0 . However , the sets Q0 or R0 do not
have a smallest element and hence are not well ordered. The principle of mathematical induction is
based on this property of subsets.
2.3
Introduction to the Principle of Mathematical Induction
For each n ∈ N, let Sn , denote the sum of the first n (positive) odd numbers. Calculating S1 , S2 , S3 , S4 , S5
we find
S1 = 1 = 1
S2 = 1 + 3 = 4
S3 = 1 + 3 + 5 = 9
S4 = 1 + 3 + 5 + 7 = 16
S5 = 1 + 3 + 5 + 7 + 9 = 25
You may notice a pattern beginning to emerge. Does this pattern continue? Suppose that we see
whether or not the pattern continues to S6 . Adding up, we find
S6 = 1 + 3 + 5 + 7 + 9 + 11 = 36
3
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3
We are thus led to the conjecture that
Sn = n2
for all natural numbers n? Can we prove this? If so, how?
Merely testing the proposition for a few values of n, no matter how many, cannot in itself suffice to
prove that the proposition holds for all natural numbers n. Some propositions may turn out to be true
in a very large number of cases, and yet fails for others. Such a proposition is the following:
n < 1, 000, 000, 000
This proposition holds for a very large number of natural numbers n, (for 999,999,999 of them to
be precise), yet it obviously fails to hold for all natural numbers n. A strategy for proving that some
conjecture holds for all natural numbers n is the Principle of Mathematical Induction.
Theorem 1 Let P (n) denote some proposition.
i. Verify statement P (n) is true for the smallest value of n (usually 1).
ii. Assume the statement P (n) is true for some value k < n and prove it also true for k + 1.
iii. If P (1) holds, then by point ii, P (2) holds and so on up to n.
To understand the justification for the Principle of Mathematical Induction, consider the following.
For each natural number n, let P (n) denote a proposition (that is either true or false). We suppose
that we have proved that P (1) is true, and that if P (k) is true then P (k + 1) is true.
Now
P (1) is true.
If P (1) is true then P (2) is true. Moreover P (1) is true.
Therefore P (2) is true.
If P (2) is true then P (3) is true. Moreover P (2) is true.
Therefore P (3) is true.
If P (3) is true then P (4) is true. Moreover P (3) is true.
Therefore P (4) is true.
:
:
:
:
:
:
If P (n − 2) is true then P (n − 1) is true. Moreover P (n − 2) is true.
4
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
4
Therefore P (n − 1) is true.
If P (n − 1) is true then P (n) is true. Moreover P (n − 1) is true.
Therefore P (n) is true.
The pattern exhibited in these statements should convince you that P (n) is true for any natural number
n, no matter how large.
2.4
Examples – Summation Formulae
Example We claim that
n
X
i=
i=1
for all n ∈ N, where
n
X
n(n + 1)
2
i = 1 + 2 + 3 + .......... + n
i=1
We prove this result using the Principle of Mathematical Induction.
Let
P (n) =
n(n + 1)
2
We can verify statement P (n) is true for the smallest value of n i.e., n = 1. So
P (1) =
1(1 + 1)
=1
2
Therefore P (1) is true. Now assume the statement P (n) is true for some value k < n and prove it
also true for k + 1. So we assume the following statement to be true
P (k) =
k
X
i=
i=1
k(k + 1)
2
We must now prove that the following statement is true
P (k + 1) =
k+1
X
i=1
i=
(k + 1)(k + 2)
2
5
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
5
We can do so as follows
P (k + 1) =
k+1
X
i
=
1 + 2 + 3 + 4 + ............ + k + (k + 1)
i=1
=
k
X
i + (k + 1)
i=1
=
=
=
=
k(k + 1)
+ (k + 1)
2
k(k + 1) + 2(k + 1)
2
(k + 1)(k + 2)
2
k+1
X
i
i=1
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all natural
numbers, which is the result we set out to prove.
Example We claim that
n
X
i2 =
i=1
n(n + 1)(2n + 1)
6
for all n ∈ N, where
n
X
i2 = 12 + 22 + 32 + .......... + n2
i=1
We prove this result using the Principle of Mathematical Induction.
Let
P (n) =
n(n + 1)(2n + 1)
6
We can verify statement P (n) is true for the smallest value of n i.e., n = 1. So
P (1) =
1(1 + 1)(2 + 1)
=1
6
Therefore P (1) is true. Now assume the statement P (n) is true for some value k < n and prove it
also true for k + 1. So we assume the following statement to be true
P (k) =
k
X
i=1
i2 =
k(k + 1)(2k + 1)
6
6
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
6
We must now prove that the following statement is true
P (k + 1) =
k+1
X
i2 =
i=1
(k + 1)(k + 2)(2k + 3)
6
We can do so as follows
P (k + 1) =
k+1
X
i
2
2
2
2
2
2
=
1 + 2 + 3 + 4 + ............ + k + (k + 1)2
i=1
k
X
=
i2 + (k + 1)2
i=1
k(k + 1)(2k + 1)
+ (k + 1)2
6
k(k + 1)(2k + 1) + 6(k + 1)2
6
=
=
(k + 1) k(2k + 1) + 6(k + 1)
=
6
(k + 1)(2k 2 + 7k + 6)
=
6
(k + 1)(k + 2)(2k + 3)
=
6
k+1
X
=
i2
i=1
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all natural
numbers, which is the result we set out to prove.
Example We claim that
n
X
i(i + 3) =
i=1
n(n + 1)(n + 5)
3
for all n ∈ N, where
n
X
i(i + 3) = 1.4 + 2.5 + 3.6 + .......... + n(n + 3)
i=1
We prove this result using the Principle of Mathematical Induction.
Let
P (n) =
n(n + 1)(n + 5)
3
We can verify statement P (n) is true for the smallest value of n i.e., n = 1. So
7
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
P (1) =
7
1(1 + 1)(1 + 5)
=4
3
Therefore P (1) is true. Now assume the statement P (n) is true for some value k < n and prove it
also true for k + 1. So we assume the following statement to be true
P (k) =
k
X
i(i + 3) =
i=1
k(k + 1)(k + 5)
3
We must now prove that the following statement is true
P (k + 1) =
k+1
X
i(i + 3) =
i=1
(k + 1)(k + 2)(k + 6)
3
We can do so as follows
P (k + 1) =
k+1
X
i(i + 3)
=
1.4 + 2.5 + 3.6 + .......... + k(k + 3) + (k + 1)(k + 4)
i=1
=
k
X
i(i + 3) + (k + 1)(k + 4)
i=1
=
=
k(k + 1)(k + 5)
+ (k + 1)(k + 4)
3
k(k + 1)(k + 5) + 3(k + 1)(k + 4)
3
(k + 1) k(k + 5) + 3(k + 4)
=
3
(k + 1)(k 2 + 8k + 12)
=
3
(k + 1)(k + 2)(k + 6)
=
3
k+1
X
=
i(i + 3)
i=1
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all natural
numbers, which is the result we set out to prove.
8
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
8
Example We claim that
n
X
5i i =
i=1
5
(4n − 1)5n + 1
16
for all n ∈ N, where
n
X
5i i = 5.1 + 25.2 + 125.3 + .......... + 5n n
i=1
We prove this result using the Principle of Mathematical Induction.
Let P (n) = 5n n. We can verify statement P (n) is true for the smallest value of n i.e., n = 1. So
P (1) = 51 1 = 5. Therefore P (1) is true. Now assume the statement P (n) is true for some value k < n
and prove it also true for k + 1. So we assume the following statement to be true
P (k) =
k
X
5i i =
i=1
5
(4k − 1)5k + 1
16
We must now prove that the following statement is true
P (k + 1) =
k+1
X
5i i =
i=1
5
(4(k + 1) − 1)5k+1 + 1
16
We can do so as follows
P (k + 1) =
k+1
X
5i i
=
i=1
k
X
5i i + 5k+1 (k + 1)
i=1
=
=
=
=
=
=
5
k
(4k − 1)5 + 1 + 5k+1 (k + 1)
16
5
k
k
(4k − 1)5 + 1 + 16(k + 1)5
16
5
k
(20k + 15)5 + 1
16
5
k+1
(4k + 3)5
+1
16
5
k+1
(4(k + 1) − 1)5
+1
16
k+1
X
5i i
i=1
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all natural
numbers, which is the result we set out to prove.
9
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
Exercise
i Prove using the Principle of Mathematical Induction
n
X
i3 =
i=1
n2 (n + 1)2
4
ii Prove using the Principle of Mathematical Induction
n
X
(2i − 1)2 =
i=1
n(2n − 1)(2n + 1)
3
iii Prove using the Principle of Mathematical Induction
n
X
i=1
i(i + 2) =
n(n + 1)(2n + 7)
6
9
10
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3
10
Difference Equations
3.1
Introduction
Definition A sequence is a function which maps the natural numbers to the real numbers.
f : N −→ R
Let a particular sequence be defined by the following general term
un = 5.2n−1
To generate the first 4 terms of this sequence we have
u1 = 5.21−1 = 5.20 = 5
u2 = 5.22−1 = 5.21 = 10
u3 = 5.23−1 = 5.22 = 20
u4 = 5.24−1 = 5.23 = 40
Hence the sequence is 5, 10, 20, 40, ...........
Exercise For the sequence defined by the following general term
un =
2n
n2 + 1
find the terms u1 , u2 , u3 , u4 , u5 .
Many sequences have had explicit formulas for their terms. That is, sequences for which we could
write the nth or ‘general term’ as un = f (n) for some known function f . For example
un = n2 − (n − 1)2
then it is an easy matter to compute explicitly, say, u4 = 7 or u5 = 9. In such cases we are able to
compute any given term in the sequence without reference to any other terms in the sequence. However,
it is often the case in applications that we do not begin with an explicit formula for the terms of a
sequence; rather, we may know only some relationship between the various terms.
11
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.2
11
Recurrence Relations
Definition A recurrence relation is a mathematical relationship expressing fn as some combination of
fi with i < n.
Example The most famous example of a recurrence relation is the one defining the Fibonacci numbers,
fn = fn−1 + fn−2
for n ≥ 3 and with f1 = f2 = 1.
The Fibonacci numbers are computed as follows:
f3
=
f2 + f1 = 1 + 1 = 2
f4
=
f3 + f2 = 2 + 1 = 3
f5
=
f4 + f3 = 3 + 2 = 5
f6
=
f5 + f4 = 5 + 3 = 8
f7
=
f6 + f5 = 8 + 5 = 13
f8
=
f7 + f6 = 13 + 8 = 21
f9
=
f8 + f7 = 21 + 13 = 34
So we get the following sequence
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...................
Remark In his book, written in 1202, the mathematician Fibonacci (1180-1228) posed a problem
concerning the growth of the number of rabbits in a certain area. The problem can be phased as
follows: A young pair of rabbits, one of each sex, is placed on an island. Assuming that rabbits do not
breed until they are two months old and after they are two months old, each pair of rabbits produces
another pair each month, how many pairs are there after n months.
Exercise Compute the first five terms of the following recurrence relations:
i un = 2un−1 + 1 for n ≥ 1 with u1 = 1.
ii un = 3un−1 + un−2 for n ≥ 1 with u1 = 1 and u2 = 1.
iii un = un−1 + un−2 for n ≥ 2 with u1 = u2 = 1.
12
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
12
Definition Consider the sequence
u1 , u2 , u3 , .................
A function f : Z+ −→ Z+ is recursively defined if
uk = f (uk−1 , uk−2 , .........., u2 , u1 )
A difference equation may be defined as a rule which expresses each member of the sequence, from
some point on, in terms of the previous member of the sequence.
uk − uk−1 = f (uk−2 , .........., u2 , u1 )
Remark For the sequence
u1 , u2 , u3 , u4 ....................
we have a first order recurrence relation
un = f (un−1 )
and first order difference equation
un − un−1 = f (un−1 )
Example For the first–order recurrence relation
un = n(un−1 )2
(n = 2, 3, 4, .......)
and the initial condition u1 = 1 determine the sequence as far as u5 .
Solution: In the recurrence relation we allow n = 2, 3, 4, 5 to get
u2
=
2(u1 )2 = 2 × 1 = 2
u3
=
3(u2 )2 = 3 × 22 = 12
u4
=
4(u3 )2 = 4 × 122 = 576
u5
=
5(u4 )2 = 5 × 5762 = 1658880
13
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
13
Note A recurrence relation may be converted to a difference equation by subtracting un−1 from both
sides. Correspondently a difference equation may be converted to a recurrence relation by moving
the un−1 to the other side of the equation. For the recurrence relation un = n(un−1 )2 we have the
corresponding difference equation
un − un−1 = n(un−1 )2 − un−1
Remembering that the L.H.S. is now the difference between a member of the sequence and the
previous member of the sequence with u1 = 1 we have
u2 − u1
=
2(u1 )2 − u1 = 2 × 1 − 1 = 1
u3 − u2
=
3(u2 )2 − u2 = 3 × 22 − 2 = 10
u4 − u3
=
4(u3 )2 − u3 = 4 × 122 − 12 = 564
u5 − u4
=
5(u4 )2 − u4 = 5 × 5762 − 576 = 1658304
which again yields the sequence 1, 2, 12, 576, 1658880.
Dif f erence Equation
Recurrance Relation
-
un = f (un−1 )
un − un−1 = f (un−1 )
14
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
14
Example For the second–order recurrence relation
un = 2un−1 + (un−2 )3
(n ≥ 3)
with initial conditions u1 = 1 and u2 = 2 determine the solution as far as u5 .
Solution: In the recurrence relation we allow n = 3, 4, 5 to get
u3
=
2u2 + (u1 )3 = 4 + 1 = 5
u4
=
2u3 + (u2 )3 = 10 + 8 = 18
u5
=
2u4 + (u3 )3 = 36 + 125 = 161
Notice that as the order increases the number of required initial conditions increase correspondently.
Also we will only consider first order recurrence relations and corresponding first order difference equations.
Exercise For the first–order recurrence relation
un = 2un−1 + (un−1 )3
and the initial condition u1 = 1 determine the sequence as far as u5 . Write down the corresponding
difference equation and again determine the solution as far as u5 .
3.3
Solving Recurrence Relations
To solve a recurrence relation involving the sequence u1 , u2 , u3 , .......... is to find an explicit formula for
the general term un .
The process of repeatedly substituting old values back into the recurrence relation to produce new
ones is called iteration. It is clear that this process will eventually produce un for any value of u. While
iteration has the advantage of being repetitive, and therefore easy to apply, it has drawbacks. For
example, if you wished to calculate u100 , say, by iteration then you would also have to write down all
the preceding members of the sequence u1 , u2 , u3 , .............., u98 , u99 regardless if you wanted them or
not.
For some recurrence relations it is possible to find a simple formula giving the solution un as a
function of u. Such a formula is said to provide a ‘closed-form’ solution of the recurrence relation and
15
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
15
enables u100 , say, to be calculated directly, without any need to calculate all the preceding members of
the sequence.
The following examples illustrate how a closed–form solution may be guessed and then checked.
Example Guess a formula for the solution of the first–order recurrence relation
un = 1 + un−1 + 2
p
1 + un−1
(n ≥ 2)
with initial conditions u1 = 0.
Solution: First calculate u1 , u2 , u3 , u4 .
From the recurrence relation (or corresponding difference equation) and the initial condition it
follows by iteration that these four numbers are respectively 0, 3, 8, 15. These numbers look very close
to the perfect squares 1, 4, 9, 16. More precisely
u1
=
12 − 1
u2
=
22 − 1
u3
=
32 − 1
u4
=
42 − 1
This leads to the guess un = n2 − 1 for all n ≥ 1.
Remark We can show that the formula un = n2 −1 satisfies both the initial condition and the difference
equation as follows:
At n = 1 we get the initial condition u1 = 0.
At n = n − 1 we get un−1 = (n − 1)2 − 1.
Substituting into the difference equation we get
p
un = 1 + un−1 + 2 1 + un−1
p
= (n − 1)2 + 2 (n − 1)2
=
(n − 1)2 + 2(n − 1)
=
n2 − 1
=
un
Thus the difference equation is satisfied.
as n ≥ 1
16
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.4
16
Linear Difference Equations with Constant Coefficients
Now that we have defined a recurrence relation (and corresponding difference equation) and sought to
find a solution of such equations we should proceed by classifying different types of difference equations
and consider how to determine their solution in a more structured way.
In ordinary algebra, we call y = mx + c a linear equation. Certain difference equations look a little
like this, namely those of the form
un = αun−1 + β
and are examples of first-order linear difference equations. Here, α and β are constants. They may,
in more advanced cases, take the form of functions. So this is a first-order linear difference equation
with constant coefficients.
Definition If the terms of the difference equation that involve sequence variables (i.e., which contain
0
uns ) involve no product of sequence variables, nor functions of sequence variables, then we call the
difference equation linear. Otherwise the difference equation is termed non-linear. Note that the
restriction apply only to the terms involving the sequence variable and not to any added terms which
don’t involve the sequence variables.
To formalize the definition of the order of a difference equation we have the following definition:
Definition If from the highest subscript of the difference equation you subtract the lowest subscript
the resulting number is called the order of the difference equation.
The following are first-order linear difference equations with constant coefficients
un = 2un−1
un = 3un−1 + 5
The following are second-order linear difference equations with constant coefficients
un = 3un−2 + n2
un = 5un−2 + un−1
un = 3un−2 − 4un−1 − 6
The following are non-linear difference equations with constant coefficients
un = 2(un−1 )2
un = (un−2 )(un−1 )
17
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.4.1
First-Order Linear Difference Equation
-
un = f (n)
-
un = f (un−1 )
un − un−1 = f (un−1 )
Theorem 2 For a first-order linear difference equation of the form:
un = αun−1
where u1 = C a solution is of the form
un = Cαn−1
Example For the first-order linear difference equation
un − 3un−1 = 0
with initial condition u1 = 5 notice that it is equivalent to the difference equation
un = 3un−1
and has a solution is given as
un = 5.(3)n
17
18
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.4.2
18
Second-Order Linear Difference Equation
-
un = f (n)
-
un = f (un−2 , un−1 )
un − un−1 = f (un−2 , un−1 )
Theorem 3 For a second-order linear difference equation of the form:
un+2 − αun+1 + βun = 0
where α and β are constants, a solution is of the form un = l.an + m.bn where a and b are the
solutions of the quadratic equation (characteristic equation) x2 − αx + β = 0.
Example To solve the second-order difference equation
un+2 − 8un+1 + 15un = 0
given that u1 = 1 and u2 = −7 – it has characteristic equation x2 − 8x + 15 = 0. This equation has
solutions x1 = 5 and x2 = 3. Hence the solution of this second-order difference equation is of the form
un = l.5n + m.3n
Now evaluating this expressions at each of the initial conditions we get
19
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
u1 = 1
u2 = −7
⇒
l.51 + m.31 = 1
⇒
5l + 3m = 1
2
19
∗
2
⇒
l.5 + m.3 = −7
⇒
25l + 9m = −7
∗
Now solving these two simultaneous equations * for l and m yieldsl = −1 and m = 2. So, the
solution of the difference equation is
un = 2.3n − 5n
As an exercise check that this is the correct solution.
Exercise Show that un = 4.3n + 2n is a solution of the difference equation
un+2 − 5un+1 + 6un = 0
Exercise Solve the difference equation
3un+2 − 11un+1 + 6un = 0
where u1 = 9 and u2 = 41.
Exercise The solution of the difference equation
un+2 − 9un+1 + 14un = 0
is given as un = a.7n − 2n . Find the value of a if u2 = 241.
20
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.5
20
The Fibonacci Sequence
Return again to the most famous example of a recurrence relation that defines the Fibonacci numbers,
fn+2 = fn+1 + fn
for n ≥ 1 and with f1 = f2 = 1.
The Fibonacci numbers are computed as follows:
f3
=
f2 + f1 = 1 + 1 = 2
f4
=
f3 + f2 = 2 + 1 = 3
f5
=
f4 + f3 = 3 + 2 = 5
f6
=
f5 + f4 = 5 + 3 = 8
f7
=
f6 + f5 = 8 + 5 = 13
f8
=
f7 + f6 = 13 + 8 = 21
f9
=
f8 + f7 = 21 + 13 = 34
So we get the following sequence
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...................
Each term in the sequence (after the second) is the sum of the two that immediately proceed it. Now
to find an explicit formulae for the Fibonacci sequence notice that the sequence is linear second-order
difference equation
fn+2 − fn+1 − fn = 0
with f1 = 1 and f2 = 1 – it has characteristic equation x2 − x − 1 = 0. This equation has solutions
√
1+ 5
x1 =
2
,
√
1− 5
x2 =
2
Hence the solution of this second-order difference equation is of the form
√ n
√ n
1+ 5
1− 5
fn = l.
+ m.
2
2
Now evaluating this expressions at each of the initial conditions we get
21
21
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
f1 = 1
⇒
√ √ 1+ 5
1− 5
l.
+ m.
=1
2
2
f2 = 1
⇒
√ 2
√ 2
1+ 5
1− 5
l.
+ m.
=1
2
2
∗
∗
Solving these two equations for l and m yields
1
l= √
5
,
1
m = −√
5
Therefore an explicit formula for the Fibonacci sequence is
√ n
√ n
1
1+ 5
1− 5
1
√
√
fn =
.
.
−
2
2
5
5
Exercise The most famous example of a recursive defined sequence is the one defining the Fibonacci
sequence,
fn = fn−1 + fn−2
for n ≥ 3 and with f1 = f2 = 1.
i Prove, using the Principle of Mathematical Induction, that
n
X
fi2 = fn fn+1
i=1
for all n ∈ N.
ii Prove, using the Principle of Mathematical Induction, that
n
X
i=1
for all n ∈ N.
fi = fn+2 − 1
22
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
3.6
22
Recursive Algorithms
A recursive function is a function that invokes itself. A recursive algorithm is an algorithm that contains
a recursive function. Recursion is a powerful, elegant, and a natural way to solve a large class of
problems. A problem in this class can be solved using a divide-and-conquer technique in which the
problem is decomposed into problems of the same type as the original problem. Each subproblem, in
turn, is decomposed further until the process yields subproblems that can be solved in a straightforward
way. Finally, solutions to the subproblems are combined to obtain a solution to the original problem.
An example of a recursive function is n factorial, i.e.,
f (n) = n! = n(n − 1)(n − 2)..........3.2.1 = n(n − 1)!
This representation shows how to decompose the original problem (to compute n!) into increasingly
simpler subproblems of computing (n − 1)!, and computing (n − 2)! etc., until the process reaches the
straightforward problem of computing 0!. The solutions to these subproblems can then be combined, by
multiplying, to solve the original problem. So, for example, the problem of computing 5! is reduced to
computing 4!; the problem of computing 4! is reduced to computing 3!; and so on until the computing
of 0!.
P roblem
Solution
0!
1!
2!
3!
4!
5!
1
1.0!
2.1!
3.2!
4.3!
5.4!
A recursive algorithm that computes factorials is as follows:
Algorithm: Factorial n
Input: n, an integer greater than or equal to zero.
Output: n!
1.
factorial(n) {
2.
if (n==0)
3.
return 1
4.
5.
return n*factorial(n-1)
}
23
23
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
We can use the Principle of Mathematical Induction to prove that the algorithm correctly returns
the correct value of n!.
At n = 0, the algorithm returns the correct value for 0! = 1.
Assume algorithm correctly returns the value of (n − 1)!, ∀n ∈ N.
Now we must prove that algorithm correctly returns the value of n!.
If the function correctly returns the value of (n−1)!, then line 4., the function correctly computes the
value n.(n − 1)! = n!. Therefore, by the Principle of Mathematical Induction, the algorithm correctly
returns the value of n!, ∀n ∈ N.
Remark There is an important link between mathematical induction and recursive algorithms. The
basic step of a proof by mathematical induction corresponds to the basic case(s) of a recursive function,
and the inductive step of a proof corresponds to the part of a recursive function where the function
calls itself.
Example A robot can take steps of 1 meter or 2 meters. Write a recursive algorithm to calculate the
number of ways the robot can walk n meters.
Firstly, some analysis
Distance
Sequence of Steps
N umber of ways to walk
1
1
1
2
1, 1 or 2
2
3
1, 1, 1 or 1, 2 or 2, 1
3
4
1, 1, 1, 1 or 1, 1, 2 or 1, 2, 1 or 2, 1, 1, or 2, 2
5
Let walk(n) denote the number of ways the robot can walk n meters. We have observed that
walk(1) = 1
,
walk(2) = 2
24
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
24
Now suppose that n > 2. The robot can begin by taking a step of 1 meter or a step of 2 meters.
If the robot begins by taking a 1-meter step, a distance of n − 1 meters remains. By definition the
remainder of the walk can be completed in walk(n − 1) ways. Similarly, if the robot begins by taking
a 2-meter step, a distance of n − 2 meters remains. By definition the remainder of the walk can be
completed in walk(n − 2) ways. Since the walk must begin with a 1-meter step or a 2-meter step, all
of the ways to walk n meters are accounted for. We obtain the formula
walk(n) = walk(n − 1) + walk(n − 2)
So, for example,
walk(4) = walk(3) + walk(2) = 3 + 2 = 5
We can write a recursive algorithm to compute walk(n) by translating this equation directly into
an algorithm. This algorithm computes the function defined by

 1,
2,
walk (n) =
 walk(n − 1) + walk(n − 2)
n=1
n=2
n > 2.
Algorithm: Robot Walking
Input: n, an integer greater than or equal to zero.
Output: walk(n)
1.
walk(n) {
if (n==1 ∨ n==2)
2.
3.
return n
4.
5.
return walk(n-1)+walk(n-2)
}
Example
i Use the formulas
s1 = 2 , sn = sn−1 + 2n
,
∀n ≥ 2,
to write a recursive algorithm that computes
sn = 2 + 4 + 6 + ............ + 2n
25
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
25
ii Give a proof, using mathematical induction, that your algorithm from part i is correct.
i
Input: Natural Number n.
Output: 2 + 4 + 6 + ............ + 2n
1.
sum(s,n) {
2.
if (n==1)
3.
return 2
4.
5.
return sum(n-1)+2n
}
ii Using the Principle of Mathematical Induction we can prove that the algorithm is correct.
Let
sum(n) = 2 + 4 + 6 + .............. + 2n
We can verify statement sum(n) is true for the smallest value of n i.e., n = 1. So
sum(1) = 2
Therefore, if n = 1, we correctly return 2.
Now assume the statement sum(k − 1) is true for some value k < n and prove it also true for k.
So we assume the following statement to be true
sum(k − 1) = 2 + 4 + 6 + .............. + 2(k − 1)
We must now prove that the following statement is true
sum(k) = 2 + 4 + 6 + .............. + 2k
We can do so as follows
sum(k)
=
2 + 4 + 6 + ................. + 2(k − 1) + 2k
= sum(k − 1) + 2k
which is the correct value. Hence
sum(k − 1) ⇒ sum(k)
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all
natural numbers, which is the result we set out to prove.
26
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
26
Exercise
i Write a recursive algorithm to find the maximum of a finite sequence of numbers.
ii Give a proof, using mathematical induction, that your algorithm from part i is correct.
Input: The sequence s1 , s2 , ................sn and the length n of the sequence.
Output: The maximum value of the sequence.
1.
f indmax(s, n) {
2.
if (n==1)
3.
return s1
4.
x = f indmax(s, n − 1)
5.
if (x > sn )
6.
return x
7.
else
8.
9.
return sn
}
Example Consider the following recursive algorithm
Input: Natural number n
Output: Sequence
1.
if n=1 then
u1 ←− 0
2.
3.
4.
else
√
un ←− 1 + un−1 + 2 1 + un−1
i Trace the algorithm as far as u5 .
ii By inspection, conjecture a non-recursive formula for the nth term of the sequence.
iii Use the Principle of Mathematical Induction to prove the formula from part ii is correct.
iv Using the non-recursive formula from part ii, write an iterative algorithm to output the first n
terms of the sequence.
27
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
27
Firstly, u1 = 0, hence
u2
=
u3
=
u4
=
u5
=
√
1 + u1 + 2 1 + u1
√
1 + u2 + 2 1 + u2
√
1 + u3 + 2 1 + u3
√
1 + u4 + 2 1 + u4
√
=1+1+2 1=3
√
=1+3+2 4=8
√
= 1 + 8 + 2 9 = 15
√
= 1 + 15 + 2 16 = 24 ..............
So, our sequence is, 0, 3, 8, 15, 24, ....................
By inspection, we conjecture the formula un = f (n) = n2 − 1 for all n ≥ 1.
Using the Principle of Mathematical Induction we can prove that this formula is correct.
Let P (n) = n2 − 1. We can verify statement P (n) is true for the smallest value of n i.e., n = 1.
So P (1) = 12 − 1 = 0. Therefore P (1) is true. Now assume the statement P (n) is true for some value
k < n and prove it also true for k + 1. So we assume the following statement to be true
P (k) = k 2 − 1
We must now prove that the following statement is true
P (k + 1) = (k + 1)2 − 1
We can do so as follows
P (k + 1)
√
1 + uk + 2 1 + uk
p
= 1 + k2 − 1 + 2 1 + k2 − 1
√
= 1 + k2 − 1 + 2 k2
=
=
1 + k 2 − 1 + 2k
=
k 2 + 2k + 1 − 1
=
(k + 1)2 − 1
=
P (k + 1)
We can now conclude from the Principle of Mathematical Induction that P (n) is true for all natural
numbers, which is the result we set out to prove.
Finally, using this non-recursive formula from part ii, we can write an iterative algorithm to output
the first n terms of the sequence.
28
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
28
Input: Natural number n
Output: Sequence
1.
for n=1 to n
un ←− n2 − 1
2.
Example
Consider the following recursive algorithm
Input: Natural number n
Output: Sequence
1.
if n=1 then
u1 ←− 1
2.
3.
if n=2 then
u2 ←− −7
4.
5.
6.
else
un ←− 8un−1 − 15un−2
i Trace the algorithm as far as u5 .
ii Determine a non-recursive formula for the nth term of the sequence.
iii Using the non-recursive formula from part ii, write an iterative algorithm to output the first n
terms of the sequence.
Firstly, u1 = 1 and u2 = −7 , hence
u3
=
8u2 − 15u1 = 8.(−7) − 15.(1) = −71
u4
=
8u3 − 15u2 = 8.(−71) − 15.(−7) = −463
u5
=
8u4 − 15u3 = 8.(−463) − 15.(−71) = −2639 ..............
So, our sequence is, 1, −7, −71, −463, −2639, ....................
Now
un = 8un−1 − 15un−2
un − 8un−1 + 15un−2 = 0
29
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
29
This is equivalent to the following second order linear difference equation
un+2 − 8un+1 + 15un = 0
Using Theorem 3. this equation may be solved to yield the non-recursive formula f (n). Firstly, its
has characteristic equation
x2 − 8x + 15 = 0
This equation has solutions x1 = 5 and x2 = 3
Hence the solution of this second-order difference equation is of the form
un = l.5n + m.3n
Now evaluating this expressions at each of the initial conditions we get
u1 = 1
u2 = −7
⇒
l.51 + m.31 = 1
⇒
5l + 3m = 1
⇒
l.52 + m.32 = −7
⇒
25l + 9m = −7
∗
∗
Now solving these two simultaneous equations * for l and m yields
l = −1
,
m=2
So, the solution of the difference equation is
un = f (n) = 2.3n − 5n
Finally, using this non-recursive formula from part ii, we can write an iterative algorithm to output
the first n terms of the sequence.
Input: Natural number n
Output: Sequence
1.
2.
for n=1 to n
un ←− 2.3n − 5n
30
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
30
Exercise
Consider the following recursive algorithm
Input: Natural number n
Output: Sequence
1.
if n=1 then
u1 ←− −4
2.
3.
if n=2 then
u2 ←− 16
4.
5.
6.
else
un ←− 10un−1 − 16un−2
i Trace the algorithm as far as u4 .
ii Determine a non-recursive formula for the nth term of the sequence.
iii Using the non-recursive formula from part ii, write an iterative algorithm to output the first n
terms of the sequence.
31
CHAPTER 6. MATHEMATICAL INDUCTION AND DIFFERENCE EQUATIONS
31
Contents
1 Introduction
1
2 The Principle of Mathematical Induction
1
2.1
Integers and Natural Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
2.2
The Well-Ordered Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2.3
Introduction to the Principle of Mathematical Induction
. . . . . . . . . . . . . . . . .
2
2.4
Examples – Summation Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
3 Difference Equations
10
3.1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
3.2
Recurrence Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
3.3
Solving Recurrence Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14
3.4
Linear Difference Equations with Constant Coefficients . . . . . . . . . . . . . . . . . . .
16
3.4.1
First-Order Linear Difference Equation
. . . . . . . . . . . . . . . . . . . . . . .
17
3.4.2
Second-Order Linear Difference Equation . . . . . . . . . . . . . . . . . . . . . .
18
3.5
The Fibonacci Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
3.6
Recursive Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22