# Integer values of difference between cube and sqaure

I am trying to find square integer values for

$k = a^3-b^2$ and $\gcd(a,b) = 1$

i.e. the values of and b for which k is a perfect square.

-
So you want $k=m^2=\sqrt{a^3-b^3}$, that is $m^4=a^3-b^3$? – Ross Millikan Dec 18 '12 at 20:30
Sorry, i edited the question. – fosho Dec 18 '12 at 20:30
b is squared not cubed, sorry about that. – fosho Dec 18 '12 at 20:33
This problem can be thought of in terms of integral points on elliptic curves. This article by Keith Conrad covers some examples (in particular k=4). – Thom Tyrrell Dec 18 '12 at 20:43
So you're looking for $a^3=b^2+c^2$? I know I've seen this before. I just need to remember how to derive it... – Mike Dec 18 '12 at 20:45

If $a$ is such that its prime divisors congruent to $3$ módulo $4$ appear with an even exponent, then the same is true of $a^3$. Fermat's theorem on sums of two squares implies that $a^3$ is the sum of two squares.

Edit.

The above answer does not take into account the requirement $\gcd(a,b)=1$. Let $a=p$ be a prime such that $$p\equiv1\mod 4.$$ The $p$ can be written in a unique way as $$p=b^2+c^2,\quad b,c\in\mathbb{N},\quad b\,c\ne0.$$ The formula for the number of representations of an integer as a sum of two squares shows that $p^3$ can be written as a sum of two squares in two different ways. One of them is $$p^3=(b\,p)^2+(c\,p)^2.$$ Let the other one be $p^3=d^2+e^2$. Then we must have $\gcd(p,d)=\gcd(p,e)=1$. For instance \begin{align*} 5^3&=2^2+11^2\\ 13^3&=9^2+46^2\\ 17^3&=47^2+52^2 \end{align*}

A similar analysis can be carried out for other integers $a$.

-

All right, I think I remember how to derive this. First, you'll want the formula for Pythagorean triples

$$(m^2-n^2)^2+(2mn)^2=(m^2+n^2)^2$$

Now multiply both sides by $m^2+n^2$.

$$(m^2+n^2)^3=(m^2+n^2)[(m^2-n^2)^2+(2mn)^2]$$

Finally, from here, you'll want to use Brahmagupta's Identity

$$(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(ad-bc)^2=(ac-bd)^2+(ad+bc)^2$$

to yield equations in the proper form with $a=m^2+n^2$.

-