# Finding solutions for expression to be a perfect square

Determine all integers such that $$n^4- n^2 +64$$ is the square of an integer.

The first two lines of the solution given in the textbook is as below:

Since $n^4-n^2+64>(n^2-1)^2.$ For some non negative integer $k$, $n^4-n^2+64=(n^2+k)^2$.

I fail to understand what the author tries to say here. Can't this problem be done in another manner?

• $$(n^2+8)^2-(3n)^2=?$$ – lab bhattacharjee Jul 23 '17 at 18:01
• $$(n^2+8)^2-(3n)^2=(n^2-3n+8)(n^2+3n+8)$$ If prime $p$ divides both, $p$ will divide $2(n^2+8),6n$ $p$ must divide $6(n^2+8)-n(6n)=48\implies p=2,3$ Clearly, $n^2\pm3n+8$ are even and will be divisible by $3\iff n\equiv1\pmod3$ – lab bhattacharjee Jul 23 '17 at 18:08
• How did you convert the expression into $(n^2+8)^2-(3n)^2$ – Viraam Jul 23 '17 at 18:10
• "Given Solution in the textbook is below:" No it isn't. – fleablood Jul 23 '17 at 18:49
• Hmmm, if you have trouble understanding a solution in the textbook, I think a good strategy would be to try to understand it, rather than asking for a different method in the hope that it is easier. Seeking alternative approaches is great for increasing understanding, not for avoiding it. – Erick Wong Jul 23 '17 at 21:40

An alternative solution ... We have $n^4-n^2+64=A^2$. Multiply this by $4$ and complete the square $(2n^2-1)^2+255=4A^2$. So \begin{eqnarray*} (2A+2n^2-1)(2A-2n^2+1)= 3 \times 5 \times 17. \end{eqnarray*} This gives
\begin{eqnarray*} 2A+2n^2-1 = x \\ 2A-2n^2+1= y \end{eqnarray*} There are $4$ possible values for $(x,y)$ ... $(15,17),(17,15),(51,5),(85,3),(255,1)$. These lead to $(A,n^2)$ having the values $(8,0),(8,1),(14,12),(22,21),(64,64)$. The first second and last will give valid answers $\color{red}{n=0}$, $\color{red}{n= \pm 1}$ and $\color{red}{n= \pm 8}$.

• You omitted the negative solutions – user97615 Jul 23 '17 at 20:29

If ( with integer $a \geq 1$) $$(a-1)^2 < w < a^2,$$ then $w$ is not a square at all. I guess I can add that then $$a-1 < \sqrt w < a,$$ so that $\sqrt w$ is not an integer, it lies strictly between two consecutive integers.

As usual, there are a few cases to check for small $w$

You are given $n^4 - n^2 + 64.$ Now, $(n^2)^2 = n^4.$ Also $(n^2 - 1)^2 = n^4 - 2 n^2 + 1.$

For $n \geq 9$ we have $n^2 > 64$ so that $n^4 - n^2 + 64 < n^4.$

For $n \geq 8,$ $$n^4 - n^2 + 64 - (n^2 - 1)^2 = n^2 - 63 > 0,$$ so $$n^4 - n^2 + 64 > (n^2 - 1)^2.$$

Alrighty, for $n \geq 9$ we get $$(n^2 - 1)^2 < n^4 - n^2 + 64 < (n^2)^2$$ so that $n^4 - n^2 + 64$ is NOT a square for $n \geq 9.$

You still need to check $n=0,1,2,3,4,5,6,7,8.$

• In this case between which two squares do we bound the given expression? – Viraam Jul 23 '17 at 18:13
• @Viraam finished typing the answer – Will Jagy Jul 23 '17 at 18:19
• ohh ok. Thanks a lot – Viraam Jul 23 '17 at 18:27

Following the author's solution, since $n^4-n^2+64>(n^2-1)^2$ any $n^4-n^2+64$ which equals a square can be written as $(n^2+k)^2$ for $k$ a non-negative integer (i.e. $k>-1$ in the $(n^2-1)^2$). That means $$n^4-n^2+64 = n^4+2kn^2+k^2$$ and $$n^2=\frac{64-k^2}{(2k+1)}.$$ We need to check for $0\leq k\leq 8$ (since $n^2>0$) to see which values are squares, and find only $k=0, 7$ and $8$ work giving us the solutions $n=0, n=\pm1$, and $n=\pm8$.

• Ohh yes thats the way the author did it. One question, why is it that $n^4-n^2+64>(n^2-1)^2$ imply that the square must be of the form $(n^2+k)^2$? – Viraam Jul 23 '17 at 18:33
• It's just that it's a number that is bigger than $n^2-1$, so whatever number it is, it can be written as $n^2+k$ with $k$ non-negative. Call the number $m$, then $m-n^2=$ something. Call that $k$. – sharding4 Jul 23 '17 at 18:49
• $a^2 = n^4 - n^2 + 64 > (n^2 -1)^2 \implies a \ge n^2$ . Let $k = a - n^2$. Then $a^2 = (n^2 + k)^2 = n^4 - n^2 + 64$. – fleablood Jul 23 '17 at 18:53
• Every square $a^2$ is of the form $(n^2 + k)^2$ if you let $k = a - n^2$. Every number $w$ is of the form $z + k$ for any number $z$ simply by letting $k = w - z$. You can always do that. In this case we know $k \ge 0$ so that will help. – fleablood Jul 23 '17 at 18:59
• @fleablood Ohh OK. thanks A lot. I can understand now. – Viraam Jul 24 '17 at 1:02

$$(n^2-x)^2=n^4-n^2+64=n^4-2xn^2+x^2$$ where $x$ is an integer.Then, $$n^2=\dfrac{x^2-64 }{2x-1 }\geq 0$$ hence by multiplying both sides by 4 $$4n^2=\dfrac{4x^2-1+1-256 }{2x-1 }=2x+1-\dfrac{255}{2x-1}$$ Since $255=1\cdot 3\cdot 5\cdot 17$ then the ratio is an integer only if $$2x-1=\pm 3^a5^b17^c$$ where $a,b,c \in\{0,1\}$

Which will yield: $$n\in \{0,\pm 1, \pm 8\}$$

Clearly $n^4$ is a square, since $(n^2)^2=n^4$. The next smaller square is $(n^2-1)^2 = n^4-2n^2+1$, which is clearly less than the given expression. So if $n^4-n^2+64$ is a square, it needs to be not less than $n^4$, that is, we need $64\ge n^2 \implies |n|\le8$ (meaning the number of solutions finite and small)

We can see by inspection that $n=\pm8$ provides a solution where $n^4-n^2+64=n^4$, which is square without further checking. Any other solutions will involve a square greater than $n^4$, that is for some $k>0,$ $(n^2+k)^2 = n^4+2kn^2+k^2$. Then we would need $2kn^2+k^2 = -n^2+64$ giving $64=(2k+1)n^2+k^2$. Checking values of $k$ up to $8$, we can find intermediate solutions $(k,n^2)=\{(0,64), (1,21),(2,12), (7,1),(8,0)\}$ of which only $k=\{8,7,0\}$ give integer values for $n$ of $\{0, \pm1,\pm8\}$ (the last of which we already noted).

This is a brute force approach.

The square previous to $\left(n^2\right)^2=n^4$ is $\left(n^2-1\right)^2=n^4-2n^2+1$. Since it is impossible for $$n^4-n^2+64\le n^4-2n^2+1\implies n^2\le-63$$ we are left with $$n^4-n^2+64=n^4\implies\color{#C00}{n^2=64}$$ or $$n^4-n^2+64=n^4+2n^2+1\implies n^2=21$$ or $$n^4-n^2+64=n^4+4n^2+4\implies n^2=12$$ or $$n^4-n^2+64=n^4+6n^2+9\implies7n^2=55$$ or $$n^4-n^2+64=n^4+8n^2+16\implies3n^2=16$$ or $$n^4-n^2+64=n^4+10n^2+25\implies11n^2=39$$ or $$n^4-n^2+64=n^4+12n^2+36\implies13n^2=28$$ or $$n^4-n^2+64=n^4+14n^2+49\implies\color{#C00}{n^2=1}$$ or $$n^4-n^2+64=n^4+16n^2+64\implies\color{#C00}{n^2=0}$$ The next square is $\left(n^2+9\right)^2=n^4+18n^2+81$ and it is impossible for $$n^4-n^2+64\ge n^4+18n^2+81\implies19n^2\le-15$$ Therefore, we have the solution set of $$n\in\{0,\pm1,\pm8\}$$

I was thinking of writing

\begin{align} n^4 - n^2 + 64 &= (n^2 + A)^2 \\ n^4 - n^2 + 64 &= n^4 + 2An^2 + A^2 \\ 2An^2 + n^2 + A^2 &= 64 \\ n^2(2A+1) &= 64 - A^2 \\ n^2 &= -\dfrac{A^2 - 64}{2A+1} \\ n^2 &= -\frac 12A + \frac 14 + \frac{255}{4(2A+1)} \\ 4n^2 &= -2A + 1 + \frac{255}{2A+1} & \text{$2A+1$ must be a positive divisor of $255$} \\ \hline 2A + 1 &\in \{ 1,3,5,15,17,51,85,255 \} \\ A &\in \{ 0,1,2,7,8,25,42,177 \} \\ 4n^2 &\in \{256, 84, 48, 4, 0, -44, -80, -252 \} \\ n &\in \pm\{ 8, 1,0 \} \end{align}

## ALSO

\begin{align} n^4 - n^2 + 64 &= A^2 \\ (n^2-1)^2 + (n^2-1) - (a^2-64) &= 0\\ n^2-1 &= \frac{-1 \pm \sqrt{4A^2-255}}{2}\\ \hline 4A^2 - 255 &= B^2 \\ (2A-B)(2A+B) &= 255 \\ (2A-B, 2A+B) &\in \{(1,255),(3,85),(5,51),(15,17)\} \\ (A,B) &\in \{(64,127),(22,41),(14,23),(8,1)\} \\ A &\in \{64,22,14,8\} \\ n^2-1 &\in \{63, 20, 11, 0, -1\} \\ n &\in \pm\{8,1,0\} \end{align}