# Do the differences of perfect squares apply to perfect cubes and more?

I'm curious about a special property of squares. The difference between perfect squares starting from 0 are 1,3,5,7,9..., where each difference goes up by 2. I want to know if there are any patterns for perfect cubes or quartics. Are the differences in a pattern of some sort?

• If you're familiar with calculus, you can think of the difference as an approximation to the derivative. The differences between $n^2$ is approximately $2n$ (because $\frac{\mathrm{d}}{\mathrm{d}n}n^2 = 2n$), so the differences between the differences is approximately $2$. Try differentiating $n^3$, $n^4$, etc. repeatedly. – Casey Chu May 9 '14 at 4:22

For cubes $$\begin {array} &0&&1&&8&&27&&64&&125\\&1&&7&&19&&37&&61\\&&6&&12&&18&&24\\&&&6&&6&&6 \end {array}$$ Try it yourself for quartics. What do you find?

• At the fifth row, it gives you 24 for all numbers. :) +1 – Jason Chen May 8 '14 at 20:42
• I figured out that, with x^0, x^1, x^2... the number of rows it takes to get to the same number is equal to the power - 1. – Jason Chen May 8 '14 at 20:45
• @JasonChen: As I count it, the number of rows to a constant is the degree. With the cubes above, there are three rows of differences to get to the $6$'s. If you start with any polynomial, the number of rows to get a constant is the degree. The constant is $n!$ times the coefficient of the leading term. If your polynomial is $7x^3+2x^2$, it will take three sets of differences and the last set will be $7\cdot 3!=42$ – Ross Millikan May 8 '14 at 20:52
• You can use this fact to prove that 0! = 1, because by setting 0 as the power, you get a constant of 1, and the constant is n!, where n is the power. – Jason Chen May 8 '14 at 20:57
• This is actually a property of all polynomials, and you can use it to generate the polynomial from the sequence: trans4mind.com/personal_development/mathematics/series/… Also, this is cool: computerhistory.org/babbage/howitworks – Zook May 9 '14 at 19:28

Look at the pattern of the differences of the differences and so on :)

In general, the sequence is generated by a polynomial of degree $d$, then the sequence of the first differences is generated by a polynomial of degree $d-1$.

To see this, consider a polynomial $p(n)$ with leading coefficient $a$. It is easy to see that $p(n+1)$ also has degree $d$ and leading coefficient $a$. If the term of degree $d-1$ in $p(n)$ is $b$, then the corresponding coefficient in $p(n+1)$ is $b+ad$. Hence $q(n)=p(n+1)-p(n)$ has degree $d-1$ with leading coefficient $ad$.

As an example with the cubes ($n\geq 0$):

$p_0(n)=n^3$: generates $0,1,8,27,64,125,\ldots$

$p_1(n)=p_0(n+1)-p_0(n)=3n^2+3n+1$: generates $1,7,19,37,61,\ldots$

$p_2(n)=p_1(n+1)-p_1(n)=6n+6$: generates $6,12,18,24,\ldots$

$p_3(n)=p_2(n+1)-p_2(n)=6$: generates $6,6,6,\ldots$

For squares:

$$1$$

$$\begin{array}{cc} \color{red}{2} & \color{red}{2} \\ 1 & \color{red}{2} \end{array}$$

$$\begin{array}{ccc} \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} \\ 1 & \color{red}{2} & \color{blue}{3} \end{array}$$

$$\begin{array}{cccc} \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} & \color{green}{4} \\ 1 & \color{red}{2} & \color{blue}{3} & \color{green}{4} \end{array}$$

$$\vdots$$

For cubes, where each array is a slice of the cube:

$$1$$

$$\left.\begin{array}{cc} \color{red}{2} & \color{red}{2} \\ 1 & \color{red}{2} \end{array}\ \ \right| \ \ \begin{array}{cc} \color{red}{2} & \color{red}{2} \\ \color{red}{2} & \color{red}{2} \end{array}$$

$$\left.\begin{array}{ccc} \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} \\ 1 & \color{red}{2} & \color{blue}{3} \end{array}\ \ \right| \ \ \left. \begin{array}{ccc} \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} \end{array}\ \ \right| \ \ \begin{array}{ccc} \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} \end{array}$$

$$\left.\begin{array}{cccc} \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} & \color{green}{4} \\ 1 & \color{red}{2} & \color{blue}{3} & \color{green}{4} \end{array} \ \ \right| \ \ \left. \begin{array}{cccc} \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} & \color{green}{4} \\ \color{red}{2} & \color{red}{2} & \color{blue}{3} & \color{green}{4} \end{array} \ \ \right| \ \ \left. \begin{array}{cccc} \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \\ \color{blue}{3} & \color{blue}{3} & \color{blue}{3} & \color{green}{4} \end{array} \ \ \right| \ \ \begin{array}{cccc} \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \\ \color{green}{4} & \color{green}{4} & \color{green}{4} & \color{green}{4} \end{array}$$

$$\vdots$$

Count the number of elements of each color.

In general, for an nth-order polynomial, if you calculate f(i) for equally-spaced values of i, then take the difference between adjacent results, and take the difference between those differences, and the differences between those differences, and so on, n times, you'll get a constant value.

So for a 2nd order polynomial such as f(x) = x^2, the second-order differences are all the same; in this case, 2, and the first-order differences for f(0), f(1), f(2), ... are 1, 3, 5, 7, ...

For a 3rd order polynomial such as f(x) = x^3, the third-order differences are all the same; in this case, 6; the second-order differences are 12, 18, 24, ... and the first-order differences are 7, 19, 37, 61... Not as pretty a pattern.

This is the basis for the method of differences, which was used for computing tables (such as logarithms) back in the days before computers; with a suitably chosen Taylor expansion, pretty much anything can be calculated with the method of differences. It has two big advantages over expanding a series directly: it doesn't require any multiplication, and every result depends on all the previous ones, so finding errors can be done by spot checking rather than checking every result.

Back in the first half of the 19th century, Charles Babbage designed a calculator that used 7th order differences to compute tables. It wasn't built in his lifetime, but ten or fifteen years ago the London Science Museum built one. More recently they built another, which you can see in operation at the Computer History Museum in Mountain View, CA.

Compare this with what happens in differentiation.

If you differentiate a polynomial function, then the degree drops by$~1$, and if it had degree$~n$ then the $n$-the derivative is a constant function, where the constant is $n!$ times the leading coefficient of the original polynomial. Similarly if you take a sequence given by a polynomial formula of degree$~n$, and you takes its "derived" sequence obtained by taking differences of successive terms and repeat that operation $n$ times, you get a constant sequence, where the constant is $n!$ times the leading coefficient of the original polynomial.

Then main difference is that for differentiation this is obvious by looking at what happens with individual terms of the polynomial ($ax^i$ differentiates to $ia^{i-1}$), but this is not so clear for the derivative sequence operation. However it does become obvious if one looks at what happens to the sequence whose terms are given by a so-called falling factorial power $n(n-1)(n-2)\ldots,(n-d+1)$ of degree$~d$: its difference sequence has terms given by $dn(n-1)\ldots,(n-d+2)$. This becomes nicer with the notation $n^{\underline d}$ for the falling factorial power: taking differences transforms $n^{\underline d}$ into $d\,n^{\underline{d-1}}$. Now if one writes polynomials as linear combinations of falling factorial powers rather than monomials (which is always possible), then it becomes clear why the behaviour described above takes place.

Applying this to the sequence $(n^3)_{n\in\Bbb N}$ gives the following. Using that $n^{\underline3}=n^3-3n^2+n$, $n^{\underline2}=n^2-n$ and $n^{\underline 1}=n$, one gets that $n^3=n^{\underline3}+3n^{\underline2}+n^{\underline1}$. Now, denoting by $\Delta$ the operation of taking successive differences, it follows that \begin{align} (n^3)_{n\in\Bbb N} &=(n^{\underline3}+3n^{\underline2}+n^{\underline1})_{n\in\Bbb N} &&=(0,1,8,27,64,\ldots); \\ \Delta((n^3)_{n\in\Bbb N}) &=(3n^{\underline2}+6n^{\underline1}+1n^{\underline0})_{n\in\Bbb N} &&=(1,7,19,37,61,\ldots); \\ \Delta^2((n^3)_{n\in\Bbb N}) &=(6n^{\underline1}+6n^{\underline0})_{n\in\Bbb N} &&=(6,12,18,24,30,\ldots); \\ \Delta^3((n^3)_{n\in\Bbb N}) &=(6n^{\underline0})_{n\in\Bbb N} &&=(6,6,6,6,6,\ldots). \end{align}