Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

The question is: with a fixed integer $n$, what are the points with integer coordinates $(a,b)$ so that $a^2 + b^2 = n^3$?

The equation is symmetric in $a$ and $b$, so if $(x,y)$ is a solution, then $(y,x)$ is a solution as well.

Obviously if $n$ is a perfect square, so we always have the solution $a=n^{3/2}$; b=0.

I think there is a solution only if $n$ is a perfect square and that this is the only solution.

I tried to prove it this way:

I can always write

$\begin{align*}a&=n^{3/2} \sin(t)\\ b&=n^{3/2} \cos(t)\end{align*}$

if $n$ is not a perfect square I would like to say that $a$ and $b$ can't both be integers, but I really can't :(

if $n$ is a perfect square I need that if $\sin(t)$ is rational then $\cos(t)$ can't be (except for the case $\sin(t)=1$; $\cos(t)=0$). I tried to use the equality $\sin^2 (t) + \cos^2 (t) = 1$ but I know I'm missing something.

Thank you for the help.

share|cite|improve this question
$4+4=8$. $121+4=125$. – Chris Eagle Nov 24 '11 at 16:58
Ok I feel stupid now :( What was I thinking? O.O – ugosugo Nov 24 '11 at 17:27

There is a complete description of the integers that can be written as sum of 2 squares : see

(a theorem of fermat states that it is exactly the integers such that their odd prime factors all have a rest equal to 1 mod 4).

it can also be shown that any integers can be written as a sum of 4 squares.

share|cite|improve this answer
hum, what's wrong with my answer ? pretty sure I didn't insult anyone and gave a complete answer on the existence of solutions, with a reference... was it because I didn't mention the fact that this property is stable by product and therefore there is no loss of generality in replacing $n^3$ by a prime ? – Glougloubarbaki Nov 24 '11 at 17:41

The following theorem gives the number of representations of the positive integer $N$ as a sum of two squares. Please note that for example $5=1^2+2^2$, $5=2^2+1^2$, $5=(-1)^2+2^2$ (and so on) count as different representations. But that's exactly what you want for your geometric problem. Let $$N=2^k (p_1^{a_1} p_2^{a_2}\cdots p_s^{a_s})(q_1^{b_1} q_2^{b_2}\cdots q_t^{b_t}),$$ where the $p_i$ are distinct primes of the form $4u+1$, and the $q_i$ are distinct primes of the form $4u-1$. (Here $s$ and/or $t$ can be $0$, and $k$ may be $0$.)

If one or more of the $b_i$ is odd, there are no representations of $N$. If all the $b_i$ are even, then the number of representations of $N$ is $$4(a_1+1)(a_2+1)\cdots(a_s+1).$$ (An empty product is interpreted to be $1$.)

In your case, we have $N=n^3$. If for some prime $q$ of the form $4u-1$, the largest $b$ such that $q^b$ divides $n$ is odd, then the same will be true for $n^3$, and there are no representations. Otherwise, we can adapt the formula for the number of representations of $N$ to get a formula for the number of representations of $n^3$ in terms of the prime factorization of $n$.

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.