4

I'm expanding my notes on exercises from Donald Knuth's The Art of Computer Programming, and found something rarely mentioned in the Internet, but still useful to prove Nicomachus' Theorem about the sum of cubes.

Knuth phrases this in the following way in exercise 8(a) to chapter 1.2.1:

Prove the following theorem of Nicomachus (A.D. c. 100) by induction: $1^3=1$, $2^3=3+5$, $3^3=7+9+11$, $4^3=13+15+17+19$, etc.

In the answers to exercises, the author gives the following formula: $(n^2-n+1)+(n^2-n+3)+...+(n^2+n-1)=n^3$

My question is, how do I get to that formula from the sample sums given in the problem? It looks kind of odd, especially because the last summand doesn't give me any idea on how it is connected with first ones. Usually one is able to see this clearly, but not here.

I tried to get to that formula by the following set of thoughts:

To get $n^3$ one must sum up $n$ odd numbers, starting from the $(n-1)$th central polygonal number, meaning that a cube of number $n$ is made by summing up odd numbers, starting from $(n-1)$th central polygonal number to $n$th triangular number.

Since odd numbers form arithmetic progression with $a_1=1, d=2$, it's possible to use the following formula of summing up $p$th to $q$th member of this progression:

$$S_{p,q}=\dfrac{a_p+a_q}2\cdot(q-p+1)$$

We can simplify $\dfrac{a_p+a_q}2$, putting $a_p=2p-1$ and $a_q=2q-1$:

$$\dfrac{a_p+a_q}2=\dfrac{(2p-1)+(2q-1)}2=\dfrac{2p+2q-2}2=p+q-1$$

Thus, the formula of summing up $p$th to $q$th member of this progression is:

$$(p+q-1)(q-p+1)=(q+(p-1))(q-(p-1))=q^2-(p-1)^2$$

Substituting in $p=\dfrac{n(n-1)}{2}+1=\dfrac{n^2-n+2}{2}$, and $q=\dfrac{n(n+1)}{2}$, we get the formula:

$$\left(\dfrac{n(n+1)}{2}\right)^2-\left(\dfrac{n(n-1)}{2}+1-1\right)^2=\left(\dfrac{n(n+1)}{2}\right)^2-\left(\dfrac{n(n-1)}{2}\right)^2=\\ \dfrac{(n(n+1))^2-(n(n-1))^2}{4}=\dfrac{(n(n+1)-n(n-1))(n(n+1)+n(n-1))}{4}=\\ \dfrac{n^2(n+1-n+1)(n+1+n-1)}{4}=\dfrac{4n^3}{4}=n^3$$

This... kind of... proves the sum formula for any $n$, really. But it doesn't give out the formula in question, i.e. $(n^2-n+1)+(n^2-n+3)+...+(n^2+n-1)$.

What is the correct way to get this formula? Any hints are greatly appreciated.

Rusurano
  • 690
  • 3
  • 12
  • 1
    Write it as $(n^2-(n-1))+(n^2-(n-3))+...+(n^2+(n-3))+(n^2+(n-1))=n^3$ and notice that the terms cancel, leaving $n\times n^2$ – Daniel Mathias Feb 07 '22 at 00:05
  • @DanielMathias This explanation is good! However, I don't yet understand why this generalizes the cases of odd and even $n$ (probably because the middle term is hidden in your sum). – Rusurano Feb 07 '22 at 22:26
  • When $n$ is odd, the middle term is $(n^2 - n + n)$ which, of course, is just $n^2$. When $n$ is even, the two middle terms are $(n^2 - n + (n-1))=n^2-1$ and $(n^2 - n + (n-1))=n^2+1$ – Daniel Mathias Feb 07 '22 at 23:06
  • @DanielMathias How does $(n^2-n+(n-1))=n^2+1$? To me it's $n^2-1$. Also, that still separates the cases for even and odd instead of uniting them into the aforementioned formula, which makes it impossible to write a 'general term' for this sum. – Rusurano Feb 08 '22 at 14:20
  • There are few methods on how to find the odd numbers that sum up to a given cube in this link: https://math.stackexchange.com/questions/3760340/cubes-as-the-sum-of-odd-integers/3764376#3764376 – user25406 Dec 29 '22 at 21:29

3 Answers3

2

Welcome to MSE!

What we're doing is moving out from $n^2$ in either direction by $2$s. You should have something analogous to gauss's trick for summing $1 \ldots n$ in mind, where we pair up $1$ and $n$, then we pair up $2$ and $n-1$, etc.

So for instance, let's look at $n = 5$. We get the sequence of numbers

$$5^2 - 4 \quad 5^2 - 2 \quad 5^2 \quad 5^2 + 2 \quad 5^2 + 4$$

Of course, if we pair these off from the outside, we see that we get $5$ copies of $5^2$. That is, $5^3$ in total. There's nothing special about $5$ in this example, and every odd number works similarly. We have $\lfloor \frac{n}{2} \rfloor$ entries on either side of $n^2$, moving by $2$s. It's easy to see these are all odd, and that they sum to $n \cdot n^2$ when we pair them off (leaving the one in the middle alone).

For even numbers, we do the obvious thing. For instance, if $n=6$ we get

$$ 6^2 - 5 \quad 6^2 - 3 \quad 6^2 - 1 \quad 6^2 + 1 \quad 6^2 + 3 \quad 6^2 + 5 $$

where now we again have $6$ copies of $6^2$, but now everybody has a friend. Since $6^2$ is even, moving to either side gives us odd numbers again.


As for how one might have come up with this formula, if we want to end up with $n^3$ and we want an arithmetic progression of length $n$, we know that the values should average to $n^2$ (do you see why?). Of course, once we have values averaging $n^2$ and we know we want an arithmetic progression, then we're forced to consider the sequence (let's assume $n$ is odd again, so there's a middle)

  • $n^2$
  • $n^2 - k \quad n^2 \quad n^2 + k$
  • $n^2 - 2k \quad n^2 - k \quad n^2 \quad n^2 + k \quad n^2 + 2k$
  • ...

where we continue until we have $n$ numbers total. The case $k=2$ is exactly your sequence of interest.

I'll leave the generalization of $k \neq 2$ with $n$ even to you as a (fun?) exercise!


I hope this helps ^_^

HallaSurvivor
  • 38,115
  • 4
  • 46
  • 87
  • Almost there! Now I understand how this sequence forms, but this shoved me into another problem. If $n$ is even, then we have $1, 3, 5, ...$ (odd numbers) added and subtracted. If $n$ is odd, we have $0, 2, 4, ...$ (even numbers) added and subtracted. The formula in question generalizes both cases, but I'm not really sure how this 'generalization' happens. I'm good with it when I'll know it! – Rusurano Feb 07 '22 at 22:23
1

$\sum_{k=0}^{n-1} (n^2 -n + 1 + 2k)$ = $\sum_{k=0}^{n-1} n^2 + \sum_{k=0}^{n-1} (-n + 1 + 2k)$, but the second sum is 0 because of the symmetry relative to 0: $\sum_{k=0}^{n-1} (-n + 1 + 2k) = \sum_{2k\leq n-1} \left((-n+1+2k) + (n-1-2k)\right) =\sum 0$. What remains is $\sum_{k=0}^{n-1} n^2 = n\cdot n^2 = n^3$

blamocur
  • 1,153
  • This explains how the sequence forms, but it's not really clear why is the general term $(-n+1+2k)$ exactly for the rest of the numbers. Like, where did this come from? How does this generalize odd and even cases of $n$ (see my comment to the answer above). – Rusurano Feb 07 '22 at 22:25
1

I've approached the problem wrongly, as it turned out. Below is the concise solution I came up with and haven't seen elsewhere.

Let's start out from analyzing initial data:

  • To get $1^3$, add $1$ odd number, starting from the $1$st odd number.
  • To get $2^3$, add $2$ odd numbers, starting from the $2$nd odd number.
  • To get $3^3$, add $3$ odd numbers, starting from the $4$th odd number.
  • To get $4^3$, add $4$ odd numbers, starting from the $7$th odd number.

That leads to the following conclusions:

  • To get $1^3$, it's needed to sum $1$st to $1$st odd numbers.
  • To get $2^3$, it's needed to sum $2$nd to $3$rd odd numbers.
  • To get $3^3$, it's needed to sum $4$th to $6$th odd numbers.
  • To get $4^3$, it's needed to sum $7$th to $10$th odd numbers.

Hence it's needed to demonstrate that a cube of any natural number $n$ is equal to sum of $n$ odd numbers, starting from the next odd number after the last one used to get a cube of $(n-1)$.

To avoid 'notice that <...>' kind of wording with the goal of avoiding the risk of misunderstanding the way things are, it's necessary to base further logic directly on facts stated above.

If for getting, for example, the value of $2^3$ it's necessary to add $2$nd to $3$rd odd number, then it's necessary to subtract the sum of the first one odd number (technically, it's just the first odd number) from the sum of the first three odd numbers. In mathematical terms, $2^3=(1+3+5)-(1)$.

This same principle can be applied further, which can be seen below:

  • $3^3=(1+3+5+7+9+11)-(1+3+5)$
  • $4^3=(1+3+5+7+9+11+13+15+17+19)-(1+3+5+7+9+11)$

For purposes of clarity and concision, the first such sum be denoted as minuend sum, and the second such sum as the subtrahend sum. For example, $3^3$ has the minuend sum $1+3+5+7+9+11$ and the subtrahend sum $1+3+5$.

To be able to generalize these cases, it's necessary to have the formula of the quantity of terms in each of these two sums for any natural $n$.

According to the pattern discovered directly from the initial data, incrementing $n$ adds $n$ new terms to the minuend sum. For example, the minuend sum of $2^3$ has $2$ more terms than the minuend sum of $1^3$. Hence the minuend sum of $n^3$ will have $1+2+...+n$ terms, and the subtrahend sum will have as much terms as the minuend sum of $(n-1)^3$, i.e. $1+2+...+(n-1)$ terms.

The sequence A005408 from OEIS gives the formula for $n$th odd number: $(2n-1)$. The sum of first $n$ natural numbers has a special name in mathematics: triangular numbers. The sequence A000217 provides a formula $1+2+...+n=\dfrac{n(n+1)}2$, provable by numerous ways, one being mentioned in this question.

From here, we get:

$1+2+...+n=\dfrac{n(n+1)}2$,

$1+2+...+(n-1)=\dfrac{(n-1)((n-1)+1)}2=\dfrac{n(n-1)}2$.

Plugging these into the formula of $n$th odd number, we get the last term of the minuend sum:

$2\cdot\dfrac{n(n+1)}2-1=n(n+1)-1=n^2+n-1$

Same approach is used to get the last term of the subtrahend sum:

$2\cdot\dfrac{n(n-1)}2-1=n(n-1)-1=n^2-n-1$

Thus, this is how we generalize the initial case:

$n^3=(1+3+...+(n^2+n-1))-(1+3+...+(n^2-n-1))$

After subtracting the subtrahend sum from the minuend sum, all terms up to $(n^2-n-1)$ inclusive will cancel out, so we are left with the sum of the odd numbers from the one next to $(n^2-n-1)$, which is $(n^2-n-1+2)=(n^2-n+1)$ to $(n^2+n-1)$. Thus, we have just discovered the formula in question!

$n^3=(n^2+n+1)+(n^2+n-2)+...+(n^2+n-1)$.

Hope this will be helpful to those struggling to understand this task.

Rusurano
  • 690
  • 3
  • 12