11. Sequences, Recursive Definitions, and Induction
11.1. Sequences, Series, and Sigma Notation
11.1.1. Sequences
A sequence is a function from the natural numbers \(\mathbb{N}=1,2,3\ldots\), into a set \(A\). The sequence may be denoted \(a_n\) for the sequence \(a_1,\ a_2,\ldots\). Sometimes the domain of the sequence may be the set of nonnegative numbers, \(0,1,2,3\ldots\), in which case \(a_n\) would be the sequence \(a_0,\ a_1,\ a_2,\ldots\).
Sequences may be defined using explicit functions or may be defined recursively.
Sequences generated by linear functions as in Example 1 are called arithmetic sequences . Thinking recursively, they are determined by a first term and a common difference. The arithmetic sequence \(a_n=3n+1\) is the sequence whose first term is \(a_1=4\), and whose common difference is \(d=3\). As arithmetic sequences are generated by linear functions \(f\left(x\right)=dx+c\), the general arithmetic sequence is \(a_n=d\cdot n+b\), \(d\) being the common difference.
Sequences generated by exponential functions as in Example 2 are called geometric sequences . Thinking recursively, they are determined by a first term and a common ratio. The geometric sequence \(b_n=2\cdot3^n\), is the sequence whose first term is \(b_1=6\) and whose common ratio is \(r=3\). As geometric sequences are generated by exponential functions \(f\left(x\right)=a\cdot r^n\), the general geometric sequence is \( a_n=a\cdot r^n\), with \(r\) being the common ratio.
11.1.2. Series and Sigma notation
Given a sequence of numbers \( \left\{a_{n\ }\right\}=\left\{a_1,a_2,a_3,\ldots\right\}\) we are often interested in adding them up.
Adding a sequence of numbers produces what is called a series .
\( a_1+a_2+a_3+a_4\) is a finite series with 4 terms, and \( a_1+a_2+a_3+\ldots+a_n\) is a finite series up to some finite, but possibly variable number of terms \(n\).
By contrast \(a_1+a_2+a_3+\ldots\) is used to denote an infinite series .
There is a shorthand way of writing a series using sigma , or sum notation , denoted by the \(\sum\) symbol. |
For example, \(a_1+a_2+a_3+a_4=\sum\limits_{i=1}^{4}a_i \) which means starting at \(i=1\), we add up \(a_1\) and then increase \(i\) to 2 and add \(a_2\), and so on, all the way up to the last one at \(i=4\).
\(a_1+a_2+a_3+\ldots+a_n=\sum\limits_{i=1}^{n}a_i\)
The infinite sum is denoted \(a_1+a_2+a_3+\ldots=\sum\limits_{i=1}^{\ \infty\ }a_i\)
11.2. Defining Sequences Recursively
A recurrence relation for a sequence \({a_n}\) is an equation that expresses \(a_n\) in terms of one or more of the previous terms of the sequence, namely \(a_0, a_1, \dots, a_{n-1}\) for all integers \(n\) with \(n \ge n_0\), where \(n_0\) is a nonnegative integer. The initial conditions for such a recurrence relation specify the terms that precede the first term where the recurrence relation takes effect.
Some sequences, like the Fibonacci sequence , are easier to generate recursively. The Fibonacci sequence is defined recursively as
\(f_1=1\) and \(f_2=1\), and \(f_n=f_{n-1}+f_{n-2}\).
So, \( f_3=f_{3-1}+f_{3-2}=f_2+f_1=1+1=2\)
\(f_4=f_{4-1}+f_{4-2}=f_3+f_2=2+1=3\)
\(f_5=f_{5-1}+f_{5-2}=f_4+f_3=3+2=5\)
\(f_6=f_{6-1}+f_{6-2}=f_5+f_4=5+3=8\)
\(f_7=f_{7-1}+f_{7-2}=f_6+f_5=8+5=13\)
We say we have solved the recurrence relation together with the initial conditions when we find an explicit formula, called a closed formula , for the terms of the sequence.
We can solve a recurrence relation using iteration .
A recursively defined function has two parts:
-
BASIS STEP: Specify the value of the function at zero
-
RECURSIVE STEP: Give a rule for finding its value at an integer from its value at smaller integers.
This is similar to a recurrence relation, but using function notation.
11.3. Recursive Algorithms
Algorithms or procedures may invoke other procedures. An algorithm that calls itself is said to be a recursive algorithm .
One way to think of recursive algorithms, is as algorithms which reduce tasks to instances of the same task with a smaller number of inputs.
We illustrate with some basic examples. The first few examples are intended mainly to introduce the concept of recursion and are not necessarily the most efficient or intuitive ways to implement the given tasks. Recursive methods are to be contrasted with iterative methods.
11.3.1. Recursive Implementation of Factorial
We begin with a recursive method for computing \(n!\) for integers \(n \geq 0\).
Recall that \(5!=5\ \times\ 4\ \times\ 3\ \times\ 2\ \times\ 1\ =\ 5\ \times\ 4!\).
In general, we may define \(n!\) recursively or inductively as
\(0!=1\)
\(n!\ =\ n\ \cdot\ (n-1)!\ \)
An implementation of the factorial procedure is given below.
11.3.2. Recursive Implementation of the Power Function \(b^n\)
As another simple example, we consider a recursive implementation of exponentiation \(b^n\) with \(n\) a nonnegative integer, \(b>0\), and \(b \neq 1\).
Consider for example \(5^4=5\ {\cdot\ 5}^3\) Hence we can recursively define exponentiation as
\(b^0=1\)
\(b^n=b\cdot\ b^{n-1}\).
A pseudocode recursive implementation of the power function or exponential function \(b^n\) is below.
11.3.3. Recursively Defined Arithmetic Sequences
Consider the arithmetic sequence, \(5, 9, 13, 17,\ldots \), which is an arithmetic sequence with first term \(a_1=5\) and common difference \(d=4\), which may be defined recursively as
\(a_1=5\)
\(a_n=4+a_{n-1}\)
The general arithmetic sequence with first term \(a_1=a\) and common difference \(d\) can be defined recursively,
\(a_1=a\)
\(a_n=d+a_{n-1}\),
and the sequence can be generated recursively using the following pseudocode.
11.3.4. Recursive Generation of the Fibonacci sequence
Recall the Fibonacci sequence \(1, 1, 2, 3, 5, 8, 13 \ldots \) is defined recursively,
\(f_1=1\)
\(f_2=1\)
\(f_n=f_{n-1}+f_{n-2}\)
We provide a recursive Python implementation to compute the \(n^{th}\) Fibonacci number.
11.3.5. The Merge Sort Algorithm
Merge Sort is a recursive sorting algorithm. The general idea is to divide a list of length \(n\) into \(n\) sublists of length \(1\), where a list of length one is considered already sorted. Subsequently, the algorithm repeatedly merges the sublists to make sorted lists until only a single list of length \(n\) is remaining. This will be the a sorted list consisting of the elements of the original list.
The picture below illustrates this with a list of length seven.
Notice that Merge Sort has complexity \(n \log{n}\). The first part of Merge Sort, similar to Binary Search which is \(O(\log{n})\), the list is repeatedly divides into two halves. The second part of Merge Sort merges \(n\) elements which occurs with complexity \(n\). Since the algorithm performs the first AND the second parts, we multiply to obtain that the complexity is \(O(n \log{n})\).
11.4. Mathematical Induction
Mathematical induction is a method of proof used to prove a series of different propositions, say \(P_1,\ P_2,P_3,\ldots P_n\). A useful analogy to help think about mathematical induction is that of climbing a ladder. It is useful to think of climbing a ladder as made up of two parts. The first part involves being able to actually step onto the ladder, or make it to the first rung (or at least some rung) of the ladder. The second part involves knowing that if we are on on some rung of the ladder we can get to the next rung of the ladder. This tells me I can climb the ladder.
Remember to climb the ladder we require two different components.
-
I can get to the first step of the ladder or be able to prove that \(P(1)\) is true. This is called the basis step .
-
In the second component, I want to know that if I’m on any given step I can climb to the next one. Proving \(P(m+1)\) assuming \(P(m)\) for general \(m\), is called the induction step .
Types of statements that can be proven by induction:
-
Summation formulas: Prove that 1(1!) + 2(2!) + · · · + n(n!) = (n + 1)! – 1, for all positive integers.
-
Inequalities: Prove that \(2^n < n!\) for every positive integer \(n\) with \(n ≥ 4\).
-
Divisibility: Prove that \(n^3+2n\) is divisible by 3 for every positive integer \(n\).
-
Sets: Prove that if \(S\) is a set with \(n\) elements where \(n\) is a nonnegative integer, then \(S\) has \(2^n\) subsets.
-
Algorithms: Prove that the recursively defined algorithm fac(n) returns \(n!\) for all nonnegative integers.
11.5. Strong Induction
Recall the idea behind mathematical induction, prove that a proposition \(P\left(m\right)\) is true for a base step, say \(P_1\). Then prove the inductive step. This involves proving that \(P_m\) implies \(P_{m+1}\). Strong induction is a generalized version of induction where in the inductive step we assume \(P_1, P_2,\ldots, P_m\) is true and show all these together imply \(P_{m+1}\) is true.
Strong version of Mathematical Induction:
-
Base Case: Prove the first statement \(P_1\). (Or the first several \(P_r\), if needed.)
-
Inductive Step: Given any integer \(m \geq 1\), prove \(P_1\land {P_2\land {\ P_3\land {\ldots\land {P_m,\ }}}}\) implies \(P_{m+1}\)
Algorithmically:
-
Base Case: Prove that \(P_{1,\ }P_2\ ,\ldots,\ P_r\), are all true.
-
Inductive Hypotheses: Assume, \(P_{1,\ }P_2\ ,\ldots,\ P_m\)are all true for some \(m ≥ 1\),
-
Inductive step: Assuming, \(P_{1,\ }P_2\ ,\ldots,\ P_m\) are all true for some \( m ≥ 1\), prove that \(P_{m+1}\) is true.
11.6. Exercises
Prove using induction.
-
For all \(n ≥ 1\) prove that \(1+2+3+\ldots+n=\displaystyle\sum_{i=1}^{n}i=\displaystyle \frac{n\left(n+1\right)}{2}\)
-
For all \(n ≥ 1\) prove that \(1^2+2^2+3^2+\ldots+n^2=\displaystyle\sum_{i=1}^{n}i^2=\frac{1}{6} n (n+1) (2 n+1)\)
-
For all \(n ≥ 1\) prove that \(1^3+2^3+3^3+\ldots+n^3=\displaystyle\sum_{k=1}^{n}k^3=\frac{1}{4} n^2 (n+1)^2\)
-
For all \(n ≥ 1\), prove that \({23}^n-1\) is divisible by 11.
-
Prove by induction that \(n^2+n = n(n+1)\) is even for all integers \(n ≥ 1\).
-
Find an appropriate \(N \in \mathbb{Z}\), and prove by induction that \(n^3 +3n^2\) is even for all \(n ≥ N\).
-
Find an appropriate \(N \in \mathbb{Z}\), and prove by induction that \(n^3 +2n\) is divisible by 3 for all \(n ≥ N\). (Hint: You may use the result \(n(n+1)\), is even for \(n\), an integer.)
-
Prove by induction that \(7\) divides \(2^{4n+2} + 3^{2n+1}\) for all nonnegative integers \(n\).
-
Prove that for any \(n ≥ 1\) and \(x ≥ 0\) that \(\left(1+x\right)^n\geq1+nx\).
-
For all \(n ≥ 5\), prove that \( 2^n>n^2\).
-
For all \(n ≥ 5\), prove that \( 2^n>n^2\).
-
Graph \(n!\) and \(2^n\), and then prove by induction that \( n! > 2^n\), for \(n>3\).
-
Graph \(n^3\) and \(5n+12\), and then use your graph to find an appropriate \(N \in \mathbb{Z}\) to prove by induction that \( n^3 > 5n+12\) whenever \(n>N\).
-
Prove by induction that a set \(A\) with cardinality \(|A|=n\) has \(2^n\) subsets.
-
Prove by induction that there are \(3^n\) numbers in base 3 (using the digits 0 ,1, 2) made up of \(n\) digits.
-
Prove by induction that there are \(4^n\) numbers in base 4 (using the digits 0 ,1, 2, 3,) made up of \(n\) digits.
-
State the principle of mathematical induction using a conditional logical statement.
-
Consider the sequence defined recursively as \(a_1=1,a_2=5,\) and \(a_n=5a_{n-1}-6a_{n-2}.\)
-
Calculate the first eight terms of the recursive sequence.
-
Prove by induction that the recursive sequence is given by the formula \(a_n=3^n-2^n.\)
-
-
Consider the sequence defined recursively as \(a_1=1\) and \(a_n=2a_{n-1}+n\).
-
Calculate the first eight terms of the recursive sequence
-
Prove by induction that the recursive sequence is given by the formula \(a_n={4\cdot2}^{n-1}-n-1\).
-
-
Prove by induction that the sum of the first \(n\) Fibonacci numbers is \[ f_1+f_2+\ldots+f_n=\sum_{i=1}^{n}{f_i=f_{n+2}-1}. \]
-
Prove by induction that the sum of the squares of the first \(n\), Fibonacci numbers is \[ f_1^2+f_2^2+ \cdots + f_n^2 = \sum_{i=1}^{n} f_i^2=f_n \cdot\ f_{n+1}. \]