Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
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
up vote 0 down vote accepted

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.


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$.

share|cite|improve this answer

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


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


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


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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.