Find all functions $f:\mathbb{Q}^+\rightarrow\mathbb{Q}^+$ such that $f(x)+f(y)+2xyf(xy)=\frac{f(xy)}{f(x+y)}$

Find all functions $f:\mathbb{Q}^+\rightarrow\mathbb{Q}^+$ such that $$f(x)+f(y)+2xyf(xy)=\frac{f(xy)}{f(x+y)}$$ for all $x,y\in\mathbb{Q}^+$.

Before this problem, I have solved few similar problems and I noticed that easiest way to solve this type of problems is to substitute specific values of $x$ and $y$ to obtain some values of $f$ or to notice some rule. I firstly tried $x=y=1$. From this, I noticed that $f(2)=\frac14$. Then I tried similar values like $(x,y)=\left\{(2,1),(1,2),(2,2),(x,x),\left(x,\frac1x\right),(x,1),\dots\right\}$ but this didn't give me anything.
Then I come to another idea. In this problem we have one very important constraint: domain and range of $f$ must be positive rational numbers. So, I wrote $f(x)$ as $\frac{p(x)}{q(x)}$ where $p$ and $q$ are polynomial functions. Substituting it to main equation and simplifying I got $$p(x)p(x+y)q(y)q(xy)+p(y)p(x+y)q(x)q(xy)+2xyp(xy)p(x+y)q(x)q(y)=p(xy)q(x)q(y)q(x+y)$$ Now, for $x=y$ we have that degree of LHS must be equal to degree of RHS becuase this is true for any $x$. Let degree of $p(x)$ be $m$ and degree of $q(x)$ be $n$. Now, degree of LHS will be $$\max\{m+m+n+2n,m+m+n+2n,2+2m+m+n+n\}=\max\{2m+3n,3n+2m+2\}$$ and degree of RHS will be $$2m+n+n+n=2m+3n$$ Solving equation $$\max\{2m+3n,3n+2m+2\}=2m+3n$$ I get $n\ge m+2$. This gives me infinitely many solutions, so I don't know how to prove or disprove that it is true for any $f(x)=\frac{p(x)}{q(x)}$ where degree of $p(x)$ is $m$ and degree of $q(x)$ is $n$ such that $n\ge m+2$. I only proved that one correct solution is for $m=0,n=2,p(x)=1,q(x)=x^2$.

I have two questions:
$1.$ If domain and range of some function are rational numbers, does it always mean we can write it as quotient of two polynomials?
$2.$ Can $f(2)=\frac14$ help me to find other solutions or prove this is the only solution? If not, what is the other way?

• Comments rather than a complete solution: (1) is absolutely false. For instance, consider the function $f(x)=1$ if $x=0$ and $f(x)=0$ otherwise, or less trivially the function $f(\frac pq)=\frac1q$ (assuming that $\frac pq$ is in lowest terms). As for (2), you should at the very least be able to see what $f(4)$ is - try $x,y=2$. More generally, note that plugging in $x=1$ gives you a formula involving only $y$, $f(1)$, $f(y)$ and $f(y+1)$ - this should be enough to let you find $f(n)$ for all integer $n$. – Steven Stadnicki Jul 22 '15 at 23:13
• @StevenStadnicki Can you explain how substituting $x=1$ can help us find solution for all integers? Notice that we do not know value of $f(1)$. – user164524 Jul 22 '15 at 23:24

Here's an attempt to plough through the problem straight ahead. First of all, let's try and find $f(3)$, substituting $x=2, y=1$:
$$f(2)+f(1)+4f(2) = \frac{f(2)}{f(3)}$$ $$f(1)+\frac54=\frac1{4f(3)}$$ $$f(3)=\frac1{4f(1)+5}$$ Awkward, but workable. Now, let's take a look at $f(4)$ the same way, substituting $x=3, y=1$: $$f(3)+f(1)+6f(3)=\frac{f(3)}{f(4)}$$ $$f(4)=\frac{f(3)}{f(1)+7f(3)}=\frac{\frac1{4f(1)+5}}{f(1)+\frac7{4f(1)+5}} =\frac1{4f(1)^2+5f(1)+7}$$
But we can also try plugging in $x=2,y=2$: $$f(2)+f(2)+8f(4)=\frac{f(4)}{f(4)}$$ $$\frac14+\frac14+8f(4)=1$$ $$f(4)=\frac1{16}$$ So now we have a quadratic equation in $f(1)$: $4f(1)^2+5f(1)+7=16$, or $4f(1)^2+5f(1)-9=0$. By inspection, $f(1)=1$ is a solution to this equation, and then by your method of choice (there are at least three different ones that are worth knowing: the quadratic formula, polynomial division of $4x^2+5x-9$ by $x-1$, and Vieta's formula for the sum of roots) the other root can be shown as $-\frac94\not\in\mathbb{Q}^+$. This shows that $f(1)=1$; now can you work the rest of the problem from here?