Subsection Summing Arithmetic Sequences: Reverse and Add
Letβs find the sum of the first \(n\) positive integers carefully. Call that sum \(T_n\text{,}\) and write it down twice, once in the usual order and once in reverse order.
\begin{equation*}
\begin{array}{lccccccccc} & T_n & = & 1 & + & 2 &+ & 3 & + \cdots + & n \\ + & T_n & =& n & + &(n-1)& + & (n-2)& + \cdots + &1 \\\hline & 2T_n & =& n+1 & + & n+1 & + & n+1 &+ \cdots + & n+1 \end{array}
\end{equation*}
We then added the two equations together. The left-hand side is \(2T_n\text{.}\) On the right-hand side, something great happens: All the terms of the sum are the same! So instead of adding up a bunch of different numbers, we now just add a bunch of the same number. Thatβs a task that multiplication lives for! There are \(n\) terms in the sum, so we get,
\begin{equation*}
2T_n = n(n+1)\text{.}
\end{equation*}
Solving for \(T_n\) gives us,
\begin{equation*}
T_n = \frac{n(n+1)}{2}\text{,}
\end{equation*}
as expected.
This technique will work for any arithmetic sum.
Example 4.3.1.
Find the sum:
\(2 + 5 + 8 + 11 + 14 + \cdots + 470\text{.}\)
Solution.
The idea is to mimic how we found the formula for triangular numbers. If we add the first and last terms, we get 472. The second term and second-to-last term also add up to 472. To keep track of everything, we might express this as follows. Call the sum
\(S\text{.}\) Then,
\(S =\) |
\(2\) |
\(+\) |
\(5\) |
\(+\) |
\(8\) |
\(+ \cdots +\) |
\(467\) |
\(+\) |
470 |
\(+ \quad S =\) |
\(470\) |
\(+\) |
\(467\) |
\(+\) |
\(464\) |
\(+ \cdots +\) |
\(5\) |
\(+\) |
2 |
\(2S =\) |
\(472\) |
\(+\) |
\(472\) |
\(+\) |
\(472\) |
\(+ \cdots +\) |
\(472\) |
\(+\) |
\(472\) |
To find \(2S\) then, we add 472 to itself a number of times. What number? We need to decide how many terms (summands) are in the sum. Since the terms form an arithmetic sequence, the \(n\)th term in the sum (counting \(2\) as the 0th term) can be expressed as \(2 + 3n\text{.}\) If \(2 + 3n = 470\) then \(n = 156\text{.}\) So \(n\) ranges from 0 to 156, giving 157 terms in the sum. This is the number of 472βs in the sum for \(2S\text{.}\) Thus
\begin{equation*}
2S = 157\cdot 472 = 74104\text{.}
\end{equation*}
It is now easy to find \(S\text{:}\)
\begin{equation*}
S = 74104/2 = 37052\text{.}
\end{equation*}
This will work for the sum of any
arithmetic sequence. Call the sum
\(S\text{.}\) Reverse and add. This produces a single number added to itself many times. Find the number of times. Multiply. Divide by 2. Done.
Example 4.3.2.
Find a closed formula for
\(6 + 10 + 14 + \cdots + (4n - 2)\text{.}\)
Solution.
Again, we have a sum of an arithmetic sequence. How many terms are in the sequence? Clearly each term in the sequence has the form
\(4k -2\) (as evidenced by the last term). For which values of
\(k\) though? To get 6,
\(k = 2\text{.}\) To get
\(4n-2\) take
\(k = n\text{.}\) So to find the number of terms, we must count the number of integers in the range
\(2,3,\ldots, n\text{.}\) This is
\(n-1\text{.}\) (There are
\(n\) numbers from 1 to
\(n\text{,}\) so one less if we start with 2.)
\(S =\) |
\(6\) |
\(+\) |
\(10\) |
\(+ \cdots +\) |
\(4n-6\) |
\(+\) |
\(4n-2\) |
\(+ \quad S =\) |
\(4n-2\) |
\(+\) |
\(4n-6\) |
\(+ \cdots +\) |
\(10\) |
\(+\) |
6 |
\(2S =\) |
\(4n+4\) |
\(+\) |
\(4n+4\) |
\(+ \cdots +\) |
\(4n+4\) |
\(+\) |
\(4n+4\) |
Since there are \(n-1\) terms, we get
\begin{equation*}
2S = (n-1)(4n+4)\qquad \mbox{ so } \qquad S = \frac{(n-1)(4n+4)}{2}\text{.}
\end{equation*}
Besides finding sums, we can use this technique to find closed formulas for sequences we recognize as sequences of partial sums.
Example 4.3.3.
Use partial sums to find a closed formula for
\((a_n)_{n\ge 0}\) which starts
\(2, 3, 7, 14, 24, 37,\ldots \ldots\text{.}\) Assume a recurrence relation for the sequence is
\(a_n = a_{n-1} + 3n-2\text{.}\)
Solution.
First, if you look at the differences between terms, you get a sequence of differences \((d_n)_{n \ge 1}\text{:}\) \(1,4,7,10,13, \ldots\text{,}\) which is an arithmetic sequence. Indeed, we notice that \(d_n = 3n-2\text{,}\) which agrees with the recurrence relation. Written another way:
\begin{align*}
a_0 \amp = 2\\
a_1 \amp = 2+1 = 2 + d_1\\
a_2 \amp = 2+1+4 = 2 + d_1 + d_2\\
a_3 \amp = 2+1+4+7 = 2 + d_1 + d_2 + d_3
\end{align*}
and so on. We can write the general term of \((a_n)\) in terms of the arithmetic sequence as follows:
\begin{equation*}
a_n = 2 + 1 + 4 + 7 + 10 + \cdots + 3n-2\text{.}
\end{equation*}
We can reverse and add, but the initial 2 does not fit our pattern. This just means we need to keep the 2 out of the reverse part:
\(a_n =\) |
\(2\) |
\(+\) |
\(1\) |
\(+\) |
\(4\) |
\(+ \cdots +\) |
\(3n-2\) |
\(+ \quad a_n =\) |
\(2\) |
\(+\) |
\(3n-2\) |
\(+\) |
\(3(n-1)-2\) |
\(+ \cdots +\) |
\(1\) |
\(2a_n =\) |
\(4\) |
\(+\) |
\(2+3n-3\) |
\(+\) |
\(2+3n-3\) |
\(+ \cdots +\) |
\(2+3n-3\) |
Not counting the first term (the 4) there are
\(n\) summands of
\(2+3n-3 = 3n-1\) so the right-hand side becomes
\(4+(3n-1)n\text{.}\)
Finally, solving for \(a_n\) we get
\begin{equation*}
a_n = \d \frac{4+(3n-1)n}{2}\text{.}
\end{equation*}
Just to be sure, we check \(a_0 = \frac{4}{2} = 2\text{,}\) \(a_1 = \frac{4+2}{2} = 3\text{,}\) etc. We have the correct closed formula.
Notice that the closed formula for a sequence that has an arithmetic (i.e., linear) rate of change is a quadratic function. Interesting....
Subsection Higher Degree Polynomials
Since we know how to compute the sum of the first
\(n\) terms of arithmetic sequences, we can compute the closed formulas for sequences that have an arithmetic sequence of differences between terms. But what if we consider a sequence that is the sum of the first
\(n\) terms of a sequence that is itself the sum of an arithmetic sequence?
How many squares (of all sizes) are there on a chessboard? A chessboard consists of \(64\) squares, but we also want to consider squares of longer side length. Even though we are only considering an \(8 \times 8\) board, there is already a lot to count. So instead, let us build a sequence: the first term will be the number of squares on a \(1 \times 1\) board, the second term will be the number of squares on a \(2 \times 2\) board, and so on. After a little thought, we arrive at the sequence
\begin{equation*}
1,5,14,30, 55,\ldots\text{.}
\end{equation*}
This sequence is not arithmetic (or geometric for that matter), but perhaps its sequence of differences is. For differences we get
\begin{equation*}
4, 9, 16, 25, \ldots\text{.}
\end{equation*}
Not a huge surprise: One way to count the number of squares in a \(4 \times 4\) chessboard is to notice that there are \(16\) squares with side length 1, 9 with side length 2, 4 with side length 3 and 1 with side length 4. So the original sequence is just the sum of squares. Now this sequence of differences is not arithmetic since its sequence of differences (the differences of the differences of the original sequence) is not constant. In fact, this sequence of second differences is
\begin{equation*}
5, 7, 9, \ldots\text{,}
\end{equation*}
which is an arithmetic sequence (with constant difference 2). Notice that our original sequence had third differences (that is, differences of differences of differences of the original) constant. We will call such a sequence \(\Delta^3\)-constant. The sequence \(1, 4, 9, 16, \ldots\) has second differences constant, so it will be a \(\Delta^2\)-constant sequence. In general, we will say a sequence is a \(\Delta^k\)-constant sequence if the \(k\)th differences are constant.
Example 4.3.4.
Which of the following sequences are \(\Delta^k\)-constant for some value of \(k\text{?}\)
-
\(2, 3, 7, 14, 24, 37,\ldots\text{.}\)
-
\(1, 8, 27, 64, 125, 216, \ldots\text{.}\)
-
\(1,2,4,8,16,32,64,\ldots\text{.}\)
Solution.
-
This is the sequence from
ExampleΒ 4.3.3, in which we found a closed formula by recognizing the sequence as the sequence of partial sums of an arithmetic sequence. Indeed, the sequence of first differences is
\(1,4,7, 10, 13,\ldots\text{,}\) which itself has differences
\(3,3,3,3,\ldots\text{.}\) Thus
\(2, 3, 7, 14, 24, 37,\ldots\) is a
\(\Delta^2\)-constant sequence.
-
These are the perfect cubes. The sequence of first differences is \(7, 19, 37, 61, 91, \ldots\text{;}\) the sequence of second differences is \(12, 18, 24, 30,\ldots\text{;}\) the sequence of third differences is constant: \(6,6,6,\ldots\text{.}\) Thus the perfect cubes are a \(\Delta^3\)-constant sequence.
-
If we take first differences, we get \(1,2,4,8,16,\ldots\text{.}\) Wait, what? Thatβs the sequence we started with. So taking second differences will give us the same sequence again. No matter how many times we repeat this we will always have the same sequence, which in particular means no finite number of differences will be constant. Thus this sequence is not \(\Delta^k\)-constant for any \(k\text{.}\)
The
\(\Delta^0\)-constant sequences are themselves constant, so a closed formula for them is easy to compute (itβs just the constant). The
\(\Delta^1\)-constant sequences are arithmetic, and we have a method for finding closed formulas for them as well. Every
\(\Delta^2\)-constant sequence is the sum of an arithmetic sequence, so we can find formulas for these as well. But notice that the format of the closed formula for a
\(\Delta^2\)-constant sequence is always quadratic. For example, the square numbers are
\(\Delta^2\)-constant with closed formula
\(a_n= n^2\text{.}\) The triangular numbers (also
\(\Delta^2\)-constant) have closed formula
\(a_n = \frac{n(n+1)}{2}\text{,}\) which when multiplied out gives you an
\(n^2\) term as well. It appears that every time we increase the complexity of the sequence, that is, increase the number of differences before we get constants, we also increase the degree of the polynomial used for the closed formula. We go from constant to linear to quadratic. The sequence of differences between terms tells us something about the rate of growth of the sequence. If a sequence is growing at a constant rate, then the formula for the sequence will be linear. If the sequence is growing at a rate which itself is growing at a constant rate, then the formula is quadratic. You might have seen this elsewhere: If a function has a constant second derivative (rate of change), then the function must be quadratic.
Theorem 4.3.5. Polynomial Fitting.
The closed formula for a sequence will be a degree
\(k\) polynomial if and only if the sequence is
\(\Delta^k\)-constant (i.e., the
\(k\)th sequence of differences is constant).
This tells us that the sequence of numbers of squares on a chessboard,
\(1, 5, 14, 30, 55, \ldots\text{,}\) which we saw to be
\(\Delta^3\)-constant, will have a cubic (degree 3 polynomial) for its closed formula.
Now once we know what format the closed formula for a sequence will take, it is much easier to actually find the closed formula. In the case that the closed formula is a degree
\(k\) polynomial, we just need
\(k+1\) data points to βfitβ the polynomial to the data.
Example 4.3.6.
Find a formula for the sequence
\(3, 7, 14, 24,\ldots\text{.}\) Assume
\(a_1 = 3\text{.}\)
Solution.
First, check to see if the formula has constant differences at some level. The sequence of first differences is \(4, 7, 10, \ldots\) which is arithmetic, so the sequence of second differences is constant. The sequence is \(\Delta^2\)-constant, so the formula for \(a_n\) will be a degree 2 polynomial. That is, we know that for some constants \(a\text{,}\) \(b\text{,}\) and \(c\text{,}\)
\begin{equation*}
a_n = an^2 + bn + c\text{.}
\end{equation*}
Now to find \(a\text{,}\) \(b\text{,}\) and \(c\text{.}\) First, it would be nice to know what \(a_0\) is, since plugging in \(n = 0\) simplifies the above formula greatly. In this case, \(a_0 = 2\) (work backward from the sequence of constant differences). Thus
\begin{equation*}
a_0 = 2 = a\cdot 0^2 + b \cdot 0 + c\text{,}
\end{equation*}
so \(c = 2\text{.}\) Now plug in \(n =1\) and \(n = 2\text{.}\) We get
\begin{equation*}
a_1 = 3 = a + b + 2
\end{equation*}
\begin{equation*}
a_2 = 7 = a4 + b 2 + 2\text{.}
\end{equation*}
At this point, we have two (linear) equations and two unknowns, so we can solve the system for
\(a\) and
\(b\) (using substitution or elimination or even matrices). We find
\(a = \frac{3}{2}\) and
\(b = \frac{-1}{2}\text{,}\) so
\(a_n = \frac{3}{2} n^2 - \frac{1}{2}n + 2\text{.}\)
Example 4.3.7.
Find a closed formula for the number of squares on an
\(n \times n\) chessboard.
Solution.
We have seen that the sequence \(1, 5, 14, 30, 55, \ldots\) is \(\Delta^3\)-constant, so we are looking for a degree 3 polynomial. That is,
\begin{equation*}
a_n = an^3 + bn^2 + cn + d\text{.}
\end{equation*}
We can find \(d\) if we know what \(a_0\) is. Working backward from the third differences, we find \(a_0 = 0\) (unsurprisingly, since there are no squares on a \(0\times 0\) chessboard). Thus \(d = 0\text{.}\) Now plug in \(n = 1\text{,}\) \(n =2\text{,}\) and \(n =3\text{:}\)
\begin{align*}
1 = \amp a + b + c\\
5 = \amp 8a + 4b + 2c\\
14 = \amp 27a + 9b + 3c\text{.}
\end{align*}
If we solve this system of equations, we get
\(a = \frac{1}{3}\text{,}\) \(b = \frac{1}{2}\) and
\(c = \frac{1}{6}\text{.}\) Therefore the number of squares on an
\(n \times n\) chessboard is
\(a_n = \frac{1}{3}n^3 + \frac{1}{2}n^2 + \frac{1}{6}n = \frac{1}{6}n(n+1)(2n+1)\text{.}\)
Note: Since the squares-on-a-chessboard problem is really asking for the sum of squares, we now have a nice formula for
\(\d\sum_{k=1}^n k^2\text{.}\)
Example 4.3.8.
Find a closed formula for
\((a_n)_{n \ge 0}\) which starts
\(2, 3, 7, 14, 24, 37,\ldots\text{.}\) Assume a recurrence relation for the sequence is
\(a_n = a_{n-1} + 3n-2\)
Solution.
Note that we have already done this in
ExampleΒ 4.3.3, but now we can solve this using polynomial fitting.
The sequence of (first) differences is \(1, 4, 7, 10, 13,\ldots\) (which agrees with what is given in the recurrence relation). The sequence of second differences is \(3, 3, 3, 3, \ldots\) constant! So we expect that the closed formula for \(a_n\) will be a degree 2 polynomial. That is, we guess,
\begin{equation*}
a_n = an^2 + bn + c\text{.}
\end{equation*}
Since \(a_0 = 2\text{,}\) we know that \(c = 2\) (as \(a\cdot 0^2 + b\cdot 0^2 + c = 2\)). Then, we can see what happens with \(n = 1\) and \(n = 2\text{:}\)
\begin{align*}
a_1 = 3 = \amp a\cdot 1^2 + b\cdot 1 + 2\\
a_2 = 7 = \amp a\cdot 2^2 + b\cdot 2 + 2\text{.}
\end{align*}
Simplifying this, we must find \(a\) and \(b\) which satisfy the equations
\begin{align*}
1 =\amp a +b\\
5 = \amp 4a + 2b\text{.}
\end{align*}
Using a computer algebra system or substitution or elimination, we find that \(a = \frac{3}{2}\) and \(b = -\frac{1}{2}\text{.}\) Therefore the closed formula is,
\begin{equation*}
a_n = \frac{3}{2}n^2 - \frac{1}{2}n + 2\text{.}
\end{equation*}
This is the same as we found in
ExampleΒ 4.3.3, once you multiply out that solution.
Not all sequences will have polynomials as their closed formula. We can use the theory of finite differences to identify these.
Example 4.3.9.
Determine whether the following sequences can be described by a polynomial, and if so, of what degree.
-
\(\displaystyle 1, 2, 4, 8, 16, \ldots\)
-
\(\displaystyle 0, 7, 50, 183, 484, 1055, \ldots\)
-
\(\displaystyle 1,1,2,3,5,8,13,\ldots\)
Solution.
-
As we saw in
ExampleΒ 4.3.4, this sequence is not
\(\Delta^k\)-constant for any
\(k\text{.}\) Therefore the closed formula for the sequence is not a polynomial. In fact, we know the closed formula is
\(a_n = 2^n\text{,}\) which grows faster than any polynomial (so is not a polynomial).
-
The sequence of first differences is
\(7, 43, 133, 301, 571,\ldots\text{.}\) The second differences are:
\(36, 90, 168, 270,\ldots\text{.}\) Third differences:
\(54, 78, 102,\ldots\text{.}\) Fourth differences:
\(24, 24, \ldots\text{.}\) As far as we can tell, this sequence of differences is constant so the sequence is
\(\Delta^4\)-constant, and as such the closed formula is a degree 4 polynomial.
-
This is the Fibonacci sequence. The sequence of first differences is
\(0, 1, 1, 2, 3, 5, 8, \ldots\text{,}\) the second differences are
\(1, 0, 1, 1, 2, 3, 5\ldots\text{.}\) We notice that after the first few terms, we get the original sequence back. So there will never be constant differences, so the closed formula for the Fibonacci sequence is not a polynomial.
Subsection Solving Systems of Equations with Technology
The point of polynomial fitting is that if we can be sure that a sequence has a polynomial as its closed formula, then we can find that formula. Since we know the degree of the polynomial, all we need is to find its coefficients, and with enough terms of the sequence, we can find a system of enough linear equations whose solution will be those coefficients. However, this requires solving a system of linear equations.
For a degree 2 polynomial, we need to find three coefficients (the constant term, the coefficient of
\(n\text{,}\) and the coefficient of
\(n^2\)). A system of three linear equations will be enough to find these three unknowns. In fact, since
\(a_0\) will be the constant term, we can really get away with just two equations and two unknowns, and this is not difficult to solve by hand.
For higher degree polynomials, the number of equations is larger, and solving by hand can be tedious. Luckily, it is easy for computers to solve these equations. Below we demonstrate how to use the free computer algebra system SageMath, as well as python, to solve these systems of equations. Besides these two choices, pretty much any computer algebra system (including Wolfram Alpha) can solve these systems of equations.
Suppose we have the following system of three equations and three unknowns, as in the chess board example above:
\begin{align*}
1 = \amp a + b + c\\
5 = \amp 8a + 4b + 2c\\
14 = \amp 27a + 9b + 3c
\end{align*}
In SageMath, we can use the solve method to solve the system of equations. Here is the code:
This is easier than in python, but python might be more readily available. One way you can solve the system in python is to use the numpy library. In this case, you would create a matrix of coefficients and a vector of constants, and then use the solve method. Here is the code:
An explanation of what is going on here: We create a matrix A
of coefficients of the system of equations (not the coefficients of the closed formula we are looking for),
\begin{equation*}
A = \begin{bmatrix} 1 \amp 1 \amp 1 \\ 8 \amp 4 \amp 2 \\ 27 \amp 9 \amp 3 \end{bmatrix}
\end{equation*}
and a vector b
for the constants,
\begin{equation*}
b = \begin{bmatrix} 1 \\ 5 \\ 14 \end{bmatrix}\text{.}
\end{equation*}
What numpy does is solve the matrix equation
\begin{equation*}
Ax = b\text{.}
\end{equation*}
The vector \(x\) that satisfies this matrix equation will be the values of the unknowns in the system (so the vector \([a,b,c]\)).
Of course, once you find the coefficients of the polynomial, you should still write out the closed formula using those coefficients. It is always a good idea to check that the formula appears to work by using an
\(n\) that you did not use to get your system of equations.