For which rational inputs to a rational function does the output have a rational square root? Given $a,b,c,d,e,f\in\mathbb{Z}$, I'd like to find all $x\in\mathbb{Q}$ such that
$$
\sqrt{\frac{ax^2+bx+c}{dx^2+ex+f}}\in\mathbb{Q}.
$$
How would one approach such a problem?
As an explicit example, what are the solutions in the case where $(a,b,c,d,e,f)=(1,2,0,1,1,1)$?
 A: This is by no means a complete answer, but just the straightforwrd attempt-
Let $$\frac{ax^2+bx+c}{dx^2+ex+f}=\frac{m^2}{n^2}$$
Then $$(an^2-dm^2)x^2+(bn^2-em^2)x+(cn^2-fm^2)=0$$
which implies $$x=\frac{-(bn^2-em^2)\pm\sqrt{(bn^2-em^2)^2-4(an^2-dm^2)(cn^2-fn^2)}}{2(an^2-dm^2)}$$
To make $x$ a rational number, we want the expression $$E=\{(bn^2-em^2)^2-4(an^2-dm^2)(cn^2-fn^2)\}$$ to be a perfect square.
In your example, $E$ reduces to $\{(2n^2-m^2)^2-4(n^2-m^2)m^2\}$. As we can see here, the solutions either have $m=\pm n$ or $m=0$ or $n=0$. So, chances of a non trivial solution seem to be quite thin.
But, I tweaked your explicit example a little to $(a,b,c,d,e,f)=(1,2,1,1,1,0)$. In  this case however, e have a very nice solution. We can see that
\begin{align*}
E&=(2n^2-m^2)^2-4(n^2-m^2)m^2\\
&=\{n^2+(n^2-m^2)\}^2-4(n^2-m^2)n^2\\
&=\{n^2-(n^2-m^2)\}^2\\
&=m^4
\end{align*}
So, for this particular choice of $(a,b,c,d,e,f)$, all rational values of $x$ will give a rational square root.
A: Here's a solution due to Boris Alexeev.
We want $x\in\mathbb{Q}$ such that $\sqrt{p(x)/q(x)}\in\mathbb{Q}$. Suppose the roots of $p$ and $q$ are all distinct, since otherwise the problem is easier. Multiplying by $q(x)\in\mathbb{Q}$, we equivalently want $\sqrt{g(x)}\in\mathbb{Q}$, where $g(x):=p(x)q(x)$. That is, we want $(x,y)\in\mathbb{Q}^2$ such that $g(x)=y^2$. Since $g$ has all distinct roots by assumption, this is equivalent to finding rational points on a certain elliptic curve (see this treatment, for example). The desired solutions can therefore be obtained with the help of Magma or Sage.
A: The given equation is equvalent to:
$\frac{ax^2+bx+c}{dx^2+ex+f}=\frac{m^2}{n^2}$
We take:
$(a,b,c)=(1,-10,2)$
$(d,e,f)=(1,-8,-5)$
Hence we have:
$x^2-10x+2=m^2  ----(1)$
$x^2-8x-5=n^2   ---(2)$
Solving equation (1) &(2) we get:
$m^2-n^2=(7-2x)$
$(m+n)(m-n)=(7-2x)*(1)$
We take:
$m+n=(7-2x)$
$m-n=(1)$
Hence, $(m,n)=((4-x),(3-x))$
Substituting (m,n) in equations (1) & (2) we get:
$x=-7$
Hence we get:
$(m,n)=(11,10)$
$Hence (m/n)=(11/10)$
