# Find all integers $m,n$ for which $m^2+n^2$ is a square and $\sqrt{\frac{2m^2+2}{n^2+1}}$ is rational

This is a repost of my old question here. The question is as follows:

Find all integers m and n, such that $m^2 + n^2$ is a square and $\sqrt{\frac{2(m^2+1)}{n^2+1}}$ is rational.

I have made no progress on this problem since I last asked it. Tito gave a very nice answer for if $m,n$ were rational numbers, but it would be awesome if some people could provide some insight into this problem and solve it once and for all. It would also be really cool if we replaced that 2 with another number and investigated that as well.

(For your reference, the original question was 2010 USAJMO problem 6. I tried to bash the question out and somehow I arrived at this problem. I suspect I made a mistake somewhere because the problem is no longer homogeneous.)

• $m\not\equiv n\mod2$ – Lucian Aug 30 '15 at 0:36
• @Lucian I don't see why? – Faraz Masroor Aug 30 '15 at 0:40
• Hint: if $n$ is odd, express $n=2k+1$ so $n^2+1=4k^2+4k+2=2[2(k^2+k)+1]$. – Marconius Aug 30 '15 at 1:20
• Gotcha, that makes sense – Faraz Masroor Aug 30 '15 at 1:55
• This representation of the equations is not convenient. The second equation is better not to submit in the form of the root, as well. $$a^2(n^2+x^2)=2b^2(m^2+x^2)$$ In this form, can be solved. – individ Aug 30 '15 at 4:38

## 2 Answers

I'm not sure we need it or not. But can be useful if for the equation.

$$\frac{x}{y}=\sqrt{\frac{2(b^2+t^2)}{a^2+t^2}}$$

Then the solution can be written as.

$$x=k^2+2l^2$$

$$y=2kl$$

$$b=(k^4-4l^4)(p^2+s^2)$$

$$a=2kl(k^2-2l^2)(p^2+2ps-s^2)$$

$$t=2kl(k^2+2l^2)(p^2-2ps-s^2)$$

Here is my amateur attempt to your problem.

The number is rational iff there exist integers $\,p, q\in \mathbb N\,$ such that $\displaystyle\,\sqrt{\frac{k\left(m^2+1\right)}{n^2+1}}=\frac{p}{q}.\,$

$\,m^2 + n^2\,$ is square $\iff$ there exist an integer $\,r\in \mathbb N\,$ such that $\,m^2 + n^2 = r^2\,$

Thus we get a system \left\lbrace\begin{aligned} \frac{p^2}{q^2} &= \frac{k\left(m^2+1\right)}{n^2+1} \\ r^2 & = m^2 + n^2 \\ \end{aligned}\right. \implies \left\lbrace\begin{aligned} p^2 & = k\left(m^2+1\right) \\ q^2 & = n^2+1 \\ r^2 & = m^2 + n^2 \end{aligned}\right. \implies \left\lbrace\begin{aligned} m^2 & = \frac{p^2}{k} - 1 \\ n^2 & = q^2 - 1 \\ r^2 & = \frac{p^2}{k} + q^2 - 2 \end{aligned}\right. \implies %\left\lbrace\begin{aligned} % p,q,r \in \mathbb N, \\ % \frac{p^2}{k} \in \mathbb N ,\\ %\end{aligned}\right. \left\lbrace\begin{aligned} %\frac{p^2}{k} p^2&/k\in \mathbb N^+ ,\\ p^2 &\ge k>0 \\ q^2 & = n^2 + 1 \end{aligned}\right.

so the problem is only solvable for $\,k\in \mathbb Q^+.\,$ Also, $\, r^2 = m^2 + n^2 \implies m^2 = r^2 - n^2,\,$ therefore

\left\lbrace\begin{aligned} p^2 & = k\left(m^2+1\right) \\ q^2 & = n^2+1 \\ r^2 & = m^2 + n^2 \end{aligned}\right. \Rightarrow \left\lbrace\begin{aligned} p^2 & = k \left( r^2 - n^2 + 1 \right) \\ q^2 & = n^2+1 \\ m^2 & = r^2 - n^2 \end{aligned}\right. \Rightarrow \left\lbrace\begin{aligned} p^2 & = k\left(m^2+1\right) \\ q^2 & = 1 \\ n^2 & = 0 \\ \end{aligned}\right. %\Rightarrow \implies \left\lbrace\begin{aligned} m & = \pm\sqrt{\frac{p^2}{k}-1} \\ % q & = \pm 1 \\ n & = 0 \\ k & \ge 0 \end{aligned}\right. The problem is only well-defined for $\,k \ge 0.\,$ Note that case $\,k=0\,$ is trivial, so we require $\, k \in \mathbb Q^+.\,$ Additionally, $\,r^2 = m^2 + n^2 \ge 0 \,$ is non-trivial iff $\,r^2 >0.\,$ If $\,r^2=0\,$ we would get $\,m = n = 0.\,$ %m^2= \frac{p^2}{k}-1 \implies %\frac{p^2}{k}-m^2 = 1 \implies \left\lbrace\begin{aligned} &p^2 = k\left(m^2+1\right) \\ % &n^2 = 0 \\ &\frac{p^2}{k} + q^2 > 2 \end{aligned}\right. \stackrel{q^2 =1}{\implies } \left\lbrace\begin{aligned} p^2 & = k\left(m^2+1\right) \\ p^2 & > k \end{aligned}\right. \implies m^2 >0 \implies m \neq 0 $$0<k \in \mathbb Q^+ \implies k = \dfrac{a}{b}, \ a,b\in \mathbb N^+ \implies %p^2 = \frac{a\left(m^2 + 1 \right)}{b} m^2 = \frac{b}{a}p^2 - 1\\ \bbox[5pt, border:2pt solid #f10000]{b p^2 - am^2 = a}$$

In this way we obtained a second order Diophantine equation with $\,a,b\in \mathbb N^+\,$ given and $\,m\,$ can possibly be determined from the equation above by choosing appropriate integer values of $\,p.\,$ Note that if we assume integer $\,k \in \mathbb N^+,\,$ we get Pell-like equation which might be easier to solve. $$\bbox[5pt, border:2pt solid #f10000]{m^2 - kp^2 = - 1}$$ According to WolframAlpha, if one of the solutions of such an equation is known, then the rest can be computed using standard techniques for Pell Equation.

In particular, for $\, k = 2\,$ we get $\, a=2, \ b= 1,\,$ and $$\bbox[5pt, border:2pt solid #f10000]{m^2 = 2p^2 - 1}$$ so that in addition to $\,n=0\,$ we get \begin{aligned} p &= 1 &\implies& &m &= \pm 1, \\ p &= 5 &\implies& &m &= \pm 7, \\ p &= 29 &\implies& &m &= \pm 41, \\ \end{aligned} \\ \cdots

• You have found the solutions when $n=0$, but you haven't show that they are unique. – Capublanca Sep 12 '15 at 14:16
• This is a good start, but I was thinking about solutions with mn not equal to zero (should have specified that... sorry), and I don't exactly understand how you set $p^2$ equal to $k(m^2+1)$ or how you got that $q^2=1$. – Faraz Masroor Sep 12 '15 at 14:25
• You can only deduce $p^2 = k\left(m^2+1\right)$ and $q^2 = n^2+1$ if $k\left(m^2+1\right)$ and $n^2+1$ are coprime. Otherwise, they might have a common factor, in which case $p^2$ and $q^2$ are in fact smaller than the values stated above. – Colm Bhandal Sep 15 '15 at 15:30