Help with number theory as related to Rydberg formula A question was asked on Physics section about two atomic lines of hydrogen overlapping. Neglecting instrument resolution, the Rydberg formula is:
$$\dfrac{1}{\lambda} = R(\dfrac{1}{n_f^2}-\dfrac{1}{n_i^2})$$
The wavelength of the emitted line is $\lambda$ and the reciprocal is known as the wavenumber. 
The question is can two different lines lines have exactly the same wavenumber?
This reduces to a Diophantine problem. 
$$ \dfrac{1}{n_1^2}-\dfrac{1}{n_2^2} = \dfrac{1}{n_3^2}-\dfrac{1}{n_4^2}$$
where $n_1, n_2, n_3$ and $n_4$ are all positive integers, $n_1 < n_2$, $n_3 < n_4$ and $n_1 \ne n_3$. 
So either $n_1 > n_3$ or $n_1< n_3$. We can assume that $n_1< n_3$. 
 A: We have $\frac{1}{n_1^2} + \frac{1}{n_4^2} = \frac{1}{n_2^2} + \frac{1}{n_3^2}$. By multiplying $\text{lcm}(n_1, n_2, n_3, n_4)^2$ on both sides, we see that there is a bijection between relatively prime solutions $(n_1, n_2, n_3, n_4)$ of the Rydberg equations and relatively prime solutions $(x,y,z,w)$ satisfying $x^2 + y^2 = z^2 + w^2$.
So to massively generate "Rydberg quadruples" you need to find $N \in \mathbb N$ which can be written as sum of two positive squares by at least 2 ways. This type of question is quite classical:
Let $\Sigma(N) = |\{x, y \in \mathbb Z \ | \ x^2 + y^2 = N\}|/4$. We know that is $N_1, N_2$ are relatively prime, $\Sigma(N_1N_2) = \Sigma(N_1)\Sigma(N_2)$. And for a prime $p$, $m>0$,
$$
\Sigma(p^m) = \begin{cases} 1, &\text{if $p=2$;}\\
0, &\text{if $p\equiv 3 \pmod 4$ and $m$ is odd;}\\
1, &\text{if $p\equiv 3 \pmod 4$ and $m$ is even;}\\
m+1, &\text{if $p\equiv 1 \pmod 4$}.
\end{cases}
$$ 
Hope this gives you something to start with. Some small solutions are $1^2 + 7^2 = 5^2 + 5^2$, which gives $(n_1, n_2, n_3, n_4) = (5, 7, 7, 35)$; and $1^2 + 8^2 = 4^2 + 7^2$, which gives $(n_1, n_2, n_3, n_4) = (7, 8, 14, 56)$.
