# Find $a$ and $b$ such that $a^2-4b$ and $b^2-4a$ are perfect squares

Under what conditions for $a$ and $b$ are $(1)$ and $(2)$ integers? $$\sqrt{a^2-4b}\tag{1}$$ $$\sqrt{b^2-4a}\tag{2}$$ Apologies, but my only attempt is to show that $a^2-4b$ and $b^2-4a$ are perfect squares, but even on that I have no idea how to approach.

• Did you by any chance come from here? – TheSimpliFire Mar 11 '18 at 16:40
• Unfortunately, no. But I can see why you would say that. :) – John Glenn Mar 11 '18 at 16:44
• An answer to this question would solve the one in the link :) – TheSimpliFire Mar 11 '18 at 16:46
• Yes I see that :) This tells me to use modular arithmetic, binary search or the integer version of newton's method, but I have no idea to use them. – John Glenn Mar 11 '18 at 16:50
• I have found one condition $ab\ge 16$ but i don't think it would be complete. – dssknj Mar 11 '18 at 17:28

We claim the only solutions are $(4,4)$, $(5,6)$, and $(6,5)$.

Without loss of generality, let $a\leq b$. Then either $b\leq 4$ or

$$(b-3)^2 <b^2-4b \leq b^2-4a \leq b^2.$$

(we have that $(b-3)^2<b^2-4b$ if $b>9/2$.) The case where $b\leq 4$ can be hand-bashed out to reveal only the solution $\boxed{(4,4)}$. Otherwise, as $b^2-4a$ is a square between $(b-3)^2$ and $b^2$, it is either $(b-2)^2$ or $(b-1)^2$. However, we have

$$b^2-4a=(b-1)^2=b^2-2b+1 \implies 4a=2b-1,$$

which is a contradiction since $2b-1$ is odd and thus not a multiple of $4$. So, $b^2-4a=(b-2)^2$, which gives $a=b-1$. Then, we have that

$$a^2-4b=(b-1)^2-4b=b^2-6b+1$$

is a square. However, if $b\geq 15/2$, we have that

$$(b-4)^2=b^2-8b+16 < b^2-6b+1 < b^2-6b+9 = (b-3)^2,$$

a contradiction. Thus, $b\leq 15/2$, reducing the problem to a finite case check revealing only $\boxed{(5,6)}$, and correspondingly $\boxed{(6,5)}$.

• Have you considered negative values? e.g. $a=2$ and $b=-3$ – James Arathoon Mar 12 '18 at 0:03
• sorry missed comment above that $a$ and $b$ positive. – James Arathoon Mar 12 '18 at 0:11
• @JamesArathoon I haven't (per the comment), but after some testing it seems as if the only solutions are those with $a+b=-1$ and $a=-n^2,b=0$ or vice versa. – Carl Schildkraut Mar 12 '18 at 0:29
• @JamesArathoon Just an addendum; it's actually not that hard to prove that the solutions mentioned in my previous comment are the only ones where one of $\{a,b\}$ is allowed to be non-positive: just split into cases and use the fact that there are no positive integers $a,b$ such that $a^2+4b$ is a square and $b\leq a$. – Carl Schildkraut Mar 12 '18 at 1:55