Number of primitive representations?

97 Views Asked by At

Here :

http://mathworld.wolfram.com/SumofSquaresFunction.html

$r_2'(n)$ is a function calculating the number of solutions $a^2+b^2=n$ with integers $a,b$ satisfying $0<a\le b$

How can I calculate $P(n)$ , which shall be here the number of the primitive solutions ($\gcd(a,b)=1$) of $a^2+b^2=n$ with integers $a,b$ satisfying $0<a\le b$ ?

Some cases are relatively easy :

  • If $n$ is odd and squarefree, $\gcd(a,b)$ is necessarily satisfied. Hence we just have $P(n)=r_2'(n)$
  • If $n$ is an odd square of a squarefree number $m$ , then it can be shown that $P(n)=P(m)$ holds.

But how can I calculate $P(n)$ in general ?