This post is inspired by an attempt at the final question of the 2008 AIME II.

We consider the question of when a perfect square is equal to the difference of two consecutive cubes. If we let the cubes be and , we see that we require to be a perfect square, say .

If you list the first cubes they are and their differences are . Of these the squares are and . By continuing to list cubes it would take a while to find the next instance of a square as a difference – the next solution is . 🙂

Initially I tried solving this problem by rearranging as but that did not take me far. Another approach was via congruences, noting that the right side is so that had to be of the form . The third and most fruitful approach for me was to view the equation as a quadratic in .

Since this has integer roots, its discriminant must be a perfect square. In other words, for some integer . This equation implies must be a multiple of 3, so letting we obtain , or

In other words, we need to find (positive) integer solutions to where is even. An equation of this form is known as Pell’s equation. We claim that solutions to this equation are of the form , where is the smallest positive solution to while .

To see why this is so, firstly note that if is another positive solution with , then the equation leads to , so and . Hence it makes sense to define the “smallest solution”.

Next, we know there exists some for which

.

Multiplying all sides by and using the fact that gives us

Define . We can use norms in or explicit computation to show that . Equation (2) then contradicts the minimality assumption on unless we have . We conclude that , so all solutions are of this form proving the claim.

In our case, the minimal solution is , so we have the general solution

We can use the recurrence to see that and have the same parity (odd or even), as do and . Since initially , we see that the solutions alternate in parity. Since we are looking for being even, we are looking for odd .

.

Using the same method as before this leads to the recurrences

We can decouple these by taking 7 times the first equation minus 12 times the second to obtain . Then . Similarly we find .

Initial solutions are . From (1) we have , so we require to be odd. This will indeed be the case by our parity arguments from before (that and have different parity). We conclude that this recurrence gives us the entire solution set for . The non-negative solutions are . In other words,

The recurrence linking these can be found to be and and it can be verified that . The factor of 14 in the recurrence indicates that the solution set is relatively sparse (though still infinite).

A similar approach is shown in [3], where the Pell’s equation is obtained by completing the square to obtain rather than using the discrminant.

#### References

[1] Dušan Đukić, “Pell’s equation”, The IMO Compendium Group

[2] Matthew Wright, “Solving Pell’s equation”, available here.