While on some work on symmetric functions, we encountered
$$f(a,b)=\frac{a^2+b^2}{1+ab}$$
is an integer iff it is a perfect square, where $(a,b)\in\mathbb{N}^2$. Well, it turns out that this is a well-known (well-documented) problem.


So, I propose a slight alteration to the question:



> 
> When is $f(a,b)$ a perfect square rational number?
> 
> 
> Is there a complete way of listing all such pairs $(a,b)\in\mathbb{N}^2$?
> 
> 
> 


**Examples:** $(a,b)=(7,1), (7,7), (15,8), (15,9)$, etc.



When is $f(a,b)=\frac{a^2+b^2}{1+ab}$ a perfect square rational number?
**Edit:** in the original formulation, it wasn't clear that $a,b$ were supposed to be positive integers. This answer solves the question for $a,b$ *rational* instead.


---


The function $f$ takes every square value, once rational $a,b$ are allowed. Let $t$ be any rational number, and take the equation $(a^2+b^2)/(1+ab)=t^2$. Then
$$
a^2 + b^2 = t^2 + t^2ab.
$$
For a given non-zero rational $t$, this is a smooth conic with a point $(a,b)=(t,0)$. So it has infinitely many solutions $(a,b)$, so in particular infinitely many non-trivial ones, and moreover they form a parametrizable set. (For $t=0$, the only solution is $a=b=0$.)


You take a line $b = v(a-t)$ which intersects the conic in the $(a,b)$-plane in one rational point besides $(t,0)$. Solving for this point gives
$$
a^2 + v^2(a-t)^2 = t^2 + t^2v a(a-t)
$$
which leads to
$$
(1-t^2v+v^2)a^2 + (t^3v - 2tv^2) a + t^2v^2 - t^2 = 0.
$$
The two solutions must add up to minus the linear coefficient divided by the quadratic coefficient, so the second solution $a$ satisfies
$$
a = \frac{2tv^2 - t^3v}{1-t^2v+v^2} - t
$$
while
$$
b = v(a-t)
$$
which is your way of completely listing all pairs $(a,b)$ for which $f(a,b)$ is square.


