Login
📚 Discrete Mathematics
Chapters ▾
⇩ Download ▾

3.3 Polynomial Fitting

So far we have seen methods for finding the closed formulas for arithmetic and geometric sequences. Since we know how to compute the sum of the first n terms of arithmetic and geometric sequences, we can compute the closed formulas for sequences which have an arithmetic (or geometric) sequence of differences between terms. But what if we consider a sequence which is the sum of the first n terms of a sequence which is itself the sum of an arithmetic sequence?

Before we get too carried away, let's consider an example: 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 × 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 × 1 board, the second term will be the number of squares on a 2 × 2 board, and so on. After a little thought, we arrive at the sequence

1 , 5 , 14 , 30 , 55 ,

.

This sequence is not arithmetic (or geometric for that matter), but perhaps it's sequence of differences is. For differences we get

4 , 9 , 16 , 25 ,

.

Not a huge surprise: one way to count the number of squares in a 4 × 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 it's sequence of differences (the differences of the differences of the original sequence) is not constant. In fact, this sequence of second differences is

5 , 7 , 9 ,

, 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 Δ 3 -constant. The sequence 1 , 4 , 9 , 16 , has second differences constant, so it will be a Δ 2 -constant sequence. In general, we will say a sequence is a Δ k -constant sequence if the k th differences are constant.

The Δ 0 -constant sequences are themselves constant, so a closed formula for them is easy to compute (it's just the constant). The Δ 1 -constant sequences are arithmetic and we have a method for finding closed formulas for them as well. Every Δ 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 Δ 2 -constant sequence is always quadratic. For example, the square numbers are Δ 2 -constant with closed formula a n = n 2 . The triangular numbers (also Δ 2 -constant) have closed formula a n = n ( n + 1 ) 2 , 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 have seen this elsewhere: if a function has a constant second derivative (rate of change) then the function must be quadratic.

This works in general:

This tells us that the sequence of numbers of squares on a chessboard, 1 , 5 , 14 , 30 , 55 , , which we saw to be Δ 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.

Note: Since the squares-on-a-chessboard problem is really asking for the sum of squares, we now have a nice formula for k = 1 n k 2 .

Not all sequences will have polynomials as their closed formula. We can use the theory of finite differences to identify these.

Make up sequences that have

  1. 3, 3, 3, 3, … as its second differences.
  2. 1, 2, 3, 4, 5, … as its third differences.
  3. 1, 2, 4, 8, 16, … as its 100th differences.

Consider the sequence 1 , 3 , 7 , 13 , 21 , . Explain how you know the closed formula for the sequence will be quadratic. Then “guess” the correct formula by comparing this sequence to the squares 1 , 4 , 9 , 16 , (do not use polynomial fitting).

a n = n 2 n + 1 .

Use a similar technique as in the previous exercise to find a closed formula for the sequence 2 , 11 , 34 , 77 , 146 , 247 , .

a n = n 3 + n 2 n + 1

Generalize Exercise: Find a closed formula for the sequence of differences of a n = a n 2 + b n + c . That is, prove that every quadratic sequence has arithmetic differences.

a n 1 = a ( n 1 ) 2 + b ( n 1 ) + c = a n 2 2 a n + a + b n b + c . Therefore a n a n 1 = 2 a n a + b , which is arithmetic. Notice that this is not quite the derivative of a n , which would be 2 a n + b , but it is close.

Can you use polynomial fitting to find the formula for the n th term of the sequence 4, 7, 11, 18, 29, 47, …? Explain why or why not.

No. The sequence of differences is the same as the original sequence so no differences will be constant.

Will the n th sequence of differences of 2 , 6 , 18 , 54 , 162 , ever be constant? Explain.

No. The sequence is geometric, and in fact has closed formula 2 3 n . This is an exponential function, which is not equal to any polynomial of any degree. If the n th sequence of differences was constant, then the closed formula for the original sequence would be a degree n polynomial.

In their down time, ghost pirates enjoy stacking cannonballs in triangular based pyramids (aka, tetrahedrons), like those pictured here:

A single shaded circle (meant to represent a cannonball)
Four overlapping circles, drawn to represent cannonballs stacked with a layer of three in a triangle with a single cannonball resting on top.
Overlapping circles drawn to represent a three-dimensional tetrahedron of balls consisting of a triangle of 6 balls supporting a triangle of 3, with a single ball balanced on top.

Note, these are solid tetrahedrons, so there will be some cannonballs obscured from view (the picture on the right has one cannonball in the back not shown in the picture, for example)

The pirates wonder how many cannonballs would be required to build a pyramid 15 layers high (thus breaking the world cannonball stacking record). Can you help?

  1. Let P ( n ) denote the number of cannonballs needed to create a pyramid n layers high. So P ( 1 ) = 1 , P ( 2 ) = 4 , and so on. Calculate P ( 3 ) , P ( 4 ) and P ( 5 ) .
  2. Use polynomial fitting to find a closed formula for P ( n ) . Show your work.
  3. Answer the pirate's question: how many cannonballs do they need to make a pyramid 15 layers high?
  4. Bonus: Locate this sequence in Pascal's triangle. Why does that make sense?

Discrete Mathematics: An Open Introduction, 3rd edition, by Oscar Levin (discrete.openmathbooks.org), licensed under CC BY-SA 4.0; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.