When is $f(a,b)=\frac{a^2+b^2}{1+ab}$ a perfect square rational number?

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.

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.

• I guess one could say that, but I was seeking for something like this. In the case $t\in\mathbb{N}$ (an integer) then once we know $(a,b)=(t,t^3)$ is a solution (and it is) then we can list another by $(b,tb-a)$. Then, iterate. In fact, these are the only solutions. – T. Amdeberhan Sep 18 '16 at 14:49
• In any case, it does produce all solutions to your problem, which is what you wanted. – RP_ Sep 18 '16 at 14:58
• Yes but for which $t$ is there a $v$ making both $a$ and $b$ integers? – მამუკა ჯიბლაძე Sep 18 '16 at 19:24
• Oh sorry, I didn't realize you wanted $a$ and $b$ to be still integral. Good question, I will think about it some more... – RP_ Sep 18 '16 at 19:28
• The main interest in the solution is that all pairs $(a,b)$ are integers and $f(a,b)$ is a perfect square rational number. – T. Amdeberhan Sep 18 '16 at 20:13

For finding solutions in the case if the square is rational.

$$\frac{a^2+b^2}{ab+1}=(\frac{t}{k})^2$$

Use the same formula. For finding all solutions need to consider all possible solutions of the equation Pell. Consider the case where these solutions exist. To do this, lay on the multiplier coefficients.

$$t=cd$$

$$k=nv$$

And you need to check when this Pell equation has the solutions?

$$p^2-(t^4-4k^4)s^2=dv$$

And then the solution is substituted in the above formula.

$$b=4cnps$$

$$a=\frac{c}{nv^2}(p^2+2t^2ps+(t^4-4k^4)s^2)$$

Consider the case which invited.

$$\frac{a^2+b^2}{ab+1}=(\frac{t}{k})^2=(\frac{58}{41})^2$$

$t=58$ ; $c=2$ ; $d=29$ ;

$k=41$ ; $n=1$ ; $v=41$ ;

$$p^2-(58^4-4*41^4)s^2=p^2-13452s^2=1189$$

Use the first solution. $p=121$ ; $s=1$

Then ;

$$b=4*2*121=968$$

$$a=\frac{2}{41^2}(121^2+2*58^2*121+13452)=1002$$

• Many thanks for working this out! But is it obvious that $a$ will come out integer? – მამუკა ჯიბლაძე Sep 23 '16 at 8:42
• @მამუკაჯიბლაძე this will not always be. Only in some cases. Such as here by setting one of the solutions of the Pell equation is negative. – individ Sep 23 '16 at 8:47
• Would it be possible to impose explicit additional constraints on solutions of the Pell equation which would be equivalent to the integrality of $a$? – მამუკა ჯიბლაძე Sep 23 '16 at 8:50
• @მამუკაჯიბლაძე Why? It is necessary to consider all possible factorization of these coefficients. In some cases there will be a whole solution. In others. – individ Sep 23 '16 at 8:54
• @მამუკაჯიბლაძე you can always do $d=\pm1$ ; $v=\pm1$ Although an interesting question. It is necessary to determine whether there is a rational square which does not give the whole solution. – individ Sep 23 '16 at 9:05

For such equations:

$$\frac{x^2+y^2}{xy+1}=t^2$$

Using the solutions of the Pell equation. $p^2-(t^4-4)s^2=1$

You can write the solution.

$$x=4tps$$

$$y=t(p^2+2t^2ps+(t^4-4)s^2)$$

It all comes down to the Pell equation - as I said.
Considering specifically the equation:

$$\frac{x^2+y^2}{xy-1}=5$$

Decisions are determined such consistency. Where the next value is determined using the previous one.

$$p_2=55p_1+252s_1$$

$$s_2=12p_1+55s_1$$

You start with numbers. $(p_1;s_1) - (55 ; 12)$

Using these numbers, the solution can be written according to a formula.

$$y=p^2+2ps+21s^2$$

$$x=3p^2+26ps+63s^2$$

If you use an initial $(p_1 ; s_1) - (1 ; 1)$
Then the solutions are and are determined by formula.

$$y=s$$

$$x=\frac{p+5s}{2}$$

As the sequence it is possible to write endlessly. Then the solutions of the equation, too, can be infinite.

If you use a sequence with the first element. $(p ; s )$ - $( 4 ; 1 )$ Then decisions can be recorded.

$$y=2s$$

$$x=p+5s$$

If you use a sequence with the first element. $( p ; s )$ - $( 55 ; 12 )$

Using this sequence can be different. On its basis with the first element. $( z ; q )$ - $(2 ; 1 )$

$$z_2=pz_1+7sq_1$$

$$q_2=pq_1+3sz_1$$

Then decisions will be.

$$x=z-q$$

$$y=z+q$$

It is necessary to take into account that the number can have a different sign. - $(p ; s )$

• In the question, $t$ is rational, while $x$ and $y$ are integers – მამუკა ჯიბლაძე Sep 18 '16 at 20:11
• @მამუკაჯიბლაძე the formula is already written. Substitute rational ratio and reduce. Or you can apply a General formula to consider all the equivalent forms. I did not write here - because it immediately then begin to remove. artofproblemsolving.com/community/c3046h1048219___2 – individ Sep 19 '16 at 4:17
• No I don't understand. May I ask you to show on another example? Say, I have the following solution:$$\frac{968^2+1002^2}{968\times1002+1}=\left(\frac{58}{41}\right)^2,$$how would you obtain it using your method? – მამუკა ჯიბლაძე Sep 19 '16 at 8:37