# Solving a function for square numbers

Essentially I'm curious; could a perfect square($x$ squared) be less than the sum of all lesser perfect squares by a perfect square, and if so, what would the smallest solution be. Take $36$ for example, $36 < 25+16+9+4+1$ by $19$, $19$ is not a perfect square.

$\dfrac{(x(x+1)(2x+1))}{6}$ sums the squares so I substitute $x-1$ and take away the highest square and I get $\dfrac{(x(x-1)(2x-1))}{6}-x^2=$ "Perfect Square" how would you find if there exists any integers $x$ that satisfy such an equation?

Thank you!

-
set your thing equal to $y^2,$ multiply through by 6, there are finitely many integer solutions, if any. About as quick to run a computer search as any other method. – Will Jagy Aug 14 '13 at 4:10
I had the thought to write a program to run through square numbers until the criteria matches up. I was deterred because that wouldn't be much of a programming challenge for me. Furthermore, I am interested how this would be disproved (or hopefully solved) mathematically. – Machining Machine Aug 14 '13 at 4:21
It's an elliptic curve. There is no guarantee that anyone on the site will be able to resolve it, and anything other than a Mordell curve is a shitload of work. You are asking strangers to put in quite a bit of effort before you have put in any. – Will Jagy Aug 14 '13 at 4:32
True. I don't mean to sound like I'm asking for help. I'm lacking essential knowledge to do this, although really interested in it. I'm just hoping someone here with that knowledge might find this as interesting as I think it is, and we can talk about it. – Machining Machine Aug 14 '13 at 4:35
I'll just add that the programming approach probably wouldn't help much - I'm in the tens of millions right now. – Sp3000 Aug 14 '13 at 5:15

Picking up where Prometheus left off:

The forgotten case $x = 3a^2,\, y = 2b^2$ produces

\begin{align} 2b^2 &= 18a^4 - 27a^2 + 1\\ \iff 16b^2 &= 144a^4 - 216a^2 + 8 = (12a^2 - 9)^2 - 73\\ \iff 73 &= (12a^2 - 9)^2 - (4b)^2 = (12a^2-9-4b)(12a^2-9+4b). \end{align}

$73$ is prime, so that forces $12a^2 - 9 - 4b = 1$ and $12a^2-9+4b = 73$, whence $b = 9$ and $12a^2 = 1 + 4\cdot 9 + 9 = 46$ which obviously is impossible.

Then, looking further at the case $x = 6a^2,\,y = b^2$ and the equation

\begin{align} b^2 &= 72a^4 - 54a^2 + 1\\ \iff 8b^2 &= (24a^2)^2 - 2\cdot 9(24a^2) + 8 = (24a^2 - 9)^2 - 73\\ \iff 73 &= (24a^2 - 9)^2 - 2(2b)^2. \end{align}

The equation $u^2 - 2v^2 = 73$ has infinitely many solutions, but none of them has the required form.

The ring $\mathbb{Z}[\sqrt{2}]$ is Euclidean, hence factorial. The rational prime $73$ is reducible in $\mathbb{Z}[\sqrt{2}]$, $73= (19 + 12\sqrt{2})(19-12\sqrt{2})$, and all solutions of $u^2 - 2v^2 = 73$ arise from the solution $u = 19,\, v = 12$ by multiplication with a unit of norm $+1$. The smallest solution of $x^2 - 2y^2 = 1$ is $x = 3,\, y = 2$, so all solutions are generated by $(3+2\sqrt{2})^k(19+12\sqrt{2})$. Looking at the remainders modulo $24$ of the solutions, we find a short period,

$$(19,12),\, (9,2),\, (11,0),\, (9,22),\, (19,12)$$

and the cycle closes. The first component never has the remainder $-9 \equiv 15 \pmod{24}$.

Thus:

$$\frac{x(x-1)(2x-1)}{6} - x^2$$

is never a perfect square.

-
Very nice answer. – Zavosh Aug 15 '13 at 3:17

Here's a partial solution. I may return to this when I have time...

(EDIT: Daniel Fischer's solution completes this answer, and also provides the missing case.)

Suppose $\frac{x(x-1)(2x-1)}{6} - x^2 = k^2$ for some integer $k$. Rewriting:

$$x(x-1)(2x-1)-6x^2 = 6k^2$$ $$x(2x^2-9x+1)=6k^2$$

Let $y=2x^2-9x+1$, and note that $gcd(x,y)=1$. That means the prime factors of $k^2$ all occur either in $x$ or in $y$. There are three cases depending on how the factor $6$ is split between $x$ and $y$.

Case 1: $x=a^2, y = 6b^2$, where $k=ab$.

Then $6b^2 = 2a^4 - 9a^2+1$. Since $y$ is even, $a$ must be odd, therefore $a^2 \equiv 1$ (mod $8$), and the right hand side is $2 - 9 + 1 \equiv 2$ (mod $8$). If $b$ is even, the left hand side is divisble by 8, so $b$ must be odd, in which case $6b^2 \equiv 6 \not\equiv 2$(mod $8$). Thus this case is discounted.

Case 2: $x = 2a^2, y = 3b^2$

We have $3b^2 = 8a^4 - 18a^2 +1$. The right hand side is odd, so $b$ is odd. Therefore $b^2 \equiv 1$ (mod $8$) and $3b^2 \equiv 3$ (mod $8$). But the right hand side is $-2a^2+1$ (mod $8$), which is $\pm 1$ (mod $8$) depending on whether $a$ is even or odd. Therefore, this case is also discounted.

Case 3: $x = 6a^2, y = b^2$

Then $b^2 = 72a^4 - 54a^2 +1$.

I stopped here. The right hand side is not a square for values of $a$ between $1$ and $50000$. In that range, it's frequently squarefree; when it's not, one of the prime factors has exponent 2, very rarely 3.

See Daniel Fischer's answer for the rest.

The missing case was $x=3a^2$, $y=2b^2$. Here's a short way to deal with it:

$2b^2 = 18a^4 - 27a^2 +1$ implies $2b^2 \equiv 1$ (mod $3$) $\Rightarrow b^2 \equiv 2$ (mod $3$), which is not possible.

Also, Daniel's solution shows $72x^2 - 54x + 1$ is not a square for any integer $x>0$.

-
You also need to do Case 4: $x=3a^2,y=2b^2$ which says $b$ has a factor 4 and $a^2 \equiv 9 \pmod {16}$ but a good approach. – Ross Millikan Aug 14 '13 at 23:07

Here's a simpler proof of the "hard" case in the solution begun by Prometheus and completed by Daniel Fischer. Their analysis distinguishes four cases, with $x$ of the form $a^2$, $2a^2$, $3a^2$, and $6a^2$, respectively. The first three cases are ruled out by simple congruence conditions; only $x=6a^2$ seemed to require more effort. Here's an approach that doesn't.

Let's go back to the original equation, $x(x-1)(2x-1)-6x^2=6k^2$ and write it as

$$x(x-1)(2x-1)=6(x^2+k^2)$$

Note that the three terms on the left hand side are relatively prime. Now suppose $x=6a^2$. Then we have

$$a^2(6a^2-1)(12a^2-1)=((6a^2)^2+k^2)$$

where the terms $a^2$, $6a^2-1$, and $12a^2-1$ are still relatively prime. But $12a^2-1\equiv3\pmod4$, which means that its factorization into primes includes a prime $p\equiv3\pmod4$ to an odd power. Since that prime cannot divide either of the other two terms on the left hand side, it must appear to the same odd power in the factorization of the right hand side. But $(6a^2)^2+k^2$ is the sum of two squares. The factorization of any such number can only include even powers of primes congruent to $3\pmod4$. Therefore we cannot have $x=6a^2$.

-
I'd like to thank @Daniel Fischer, Prometheus and Barry for your interest in this perplexity. That was great work, and I enjoyed it very much. – Machining Machine Aug 15 '13 at 19:42