2
$\begingroup$

I need to emulate this sequence for a program: http://oeis.org/A025302

Stuff that I've taken into account:

  • After finding the prime divisors of a number. I take any divisor as p and apply the following rule:

p is an odd prime divisor of n, then either p appears to an even power in n, or p≡1(mod4)

  • Also I only consider sums of 2 distinct nonzero squares

The sequence in the described link only goes as far as 229. Until here my simulator using these 2 rules work, but I'm not so sure after that since I get these numbers ( which I'm not sure that they belong in my sequence ) when I loop until n <= 1000..

[0] 325 int
[1] 425 int
[2] 650 int
[3] 725 int
[4] 845 int
[5] 850 int
[6] 925 int

So my question is:

Do these 7 digits belong originally to the http://oeis.org/A025302 sequence, or have I gotten wrong my algorithm, if so, can you point the missing rule ?

Any question, feel free to comment

$\endgroup$
4
  • 1
    $\begingroup$ $325=5^2 \cdot 13=1^2+18^2=6^2+17^2=10^2+15^2$. $\endgroup$
    – Somos
    Commented Jan 21, 2019 at 0:33
  • $\begingroup$ So it definitely shouldnt be in the sequence. Do you have any ideas on how to compute this sequence ? My algorithm is wrong apparently $\endgroup$
    – Greggz
    Commented Jan 21, 2019 at 1:54
  • 1
    $\begingroup$ crossposted at: math.stackexchange.com/q/3080101/195021 $\endgroup$ Commented Jan 21, 2019 at 2:08
  • $\begingroup$ See the Mathematica code now in OEIS A025302 $\endgroup$
    – Somos
    Commented Jan 21, 2019 at 2:12

1 Answer 1

4
$\begingroup$

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

To find in how many ways a positive integer $n>1$ can be expressed as a sum of $k=2$ squares ignoring order and signs, factor it as $$n=2^{a_0}p_1^{2a_1}...p_r^{2a_r}q_1^{b_1}...q_s^{b_s}$$
where the $p_i$ are primes of the form $4k+3$ and the $q_i$ are primes of the form $4k+1$. If $n$ does not have such a representation with integer $a_i$ because one or more of the powers of $p_i$ is odd, then there are no representations. Otherwise, define $$B=(b_1+1)(b_2+1)...(b_r+1)$$
The number of representations of $n$ as the sum of two squares ignoring order and signs is then given by:

$$ r'_2(n)= \left\{ \begin{array}{lll} 0 & \textrm{if any } a_i \textrm{ is a half integer}, \\ \frac{1}{2}B & \textrm{if all } a_i \textrm{ are integers and } B \textrm{ is even}, \\ \frac{1}{2}\big(B-(-1)^{a_0}\big) & \textrm{if all } a_i \textrm{ are integers and } B \textrm{ is odd} \end{array} \right. $$

which implies that the missing rule in your algorithm (which btw is just the Sum of two squares theorem), is the following:
In order to have $r'_2(n)=1$, there can only be three cases:

  • Either: $n$ has a single $4k+1$ prime factor with multiplicity $b=1$, hence $B=b+1=1+1=2$ and $r'_2(n)=\frac{1}{2}B=1$
    ($n=5$ provides an example for that case),
  • or: $n$ has a single $4k+1$ prime factor with multiplicity $b=2$ and the multiplicity (in the prime factorization of $n$) of $2$ is $a_0$:even, hence $B=b+1=2+1=3$ and $r'_2(n)=\frac{1}{2}(B-(-1)^{a_0})=\frac{1}{2}(3-1)=1$
    ($n=100=2^2\cdot 5^2$ provides an example for that case),
  • or: there are no $4k+1$ prime factors in the prime factorization of $n$ and the multiplicity (in the prime factorization of $n$) of $2$ is $a_0$:odd, hence in that case, all $b_j$ are zero which gives $B=1$ thus $r'_2(n)=\frac{1}{2}(B-(-1)^{a_0})=\frac{1}{2}(1+1)=1$.
    However, this last case should be excluded from your considerations since you are asking for numbers $n$ which can be written in a unique way as a sum of two distinct squares while this last case leads to numbers which are twice a square ($n=18=2\cdot 3^2=3^2+3^2$ for example).

You might also be interested in Theorem 4.4, p. 10 from these notes and as for some code the function PowersRepresentations[n, 2, 2] could also be of some use to your purposes (however note that this function also allows zeros).

$\endgroup$
6
  • $\begingroup$ Thanks for your answer, can you please explain to me how do I test if a number is 4k+1 $\endgroup$
    – Greggz
    Commented Jan 21, 2019 at 9:19
  • $\begingroup$ Also, in your last point between brackets, can you explain it trough an example ? My math syntax is really limited. Thank you so much $\endgroup$
    – Greggz
    Commented Jan 21, 2019 at 9:21
  • $\begingroup$ @Greggz, when a number $p=4k+1$ i just mean that $p\equiv 1(\mod 4)$. Regarding your second question: If all $a_i$ are integers then $r'_2(n)=1$ is equivalent to either $B=b+1=1+1=2$ or $B=b+1=2+1=3$ and $a_0$: even. In the latter case we get: $r'_2(n)=\frac{1}{2}(B-(-1)^{a_0})=\frac{1}{2}(3-1)=1$. $\endgroup$ Commented Jan 21, 2019 at 15:33
  • $\begingroup$ I have edited the answer providing more details and some examples. $\endgroup$ Commented Jan 21, 2019 at 18:13
  • 1
    $\begingroup$ Thank you so much for your work and dedication $\endgroup$
    – Greggz
    Commented Jan 21, 2019 at 18:57

Not the answer you're looking for? Browse other questions tagged .