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.

  • $\begingroup$ 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. $\endgroup$ – T. Amdeberhan Sep 18 '16 at 14:49
  • 1
    $\begingroup$ In any case, it does produce all solutions to your problem, which is what you wanted. $\endgroup$ – RP_ Sep 18 '16 at 14:58
  • $\begingroup$ Yes but for which $t$ is there a $v$ making both $a$ and $b$ integers? $\endgroup$ – მამუკა ჯიბლაძე Sep 18 '16 at 19:24
  • $\begingroup$ Oh sorry, I didn't realize you wanted $a$ and $b$ to be still integral. Good question, I will think about it some more... $\endgroup$ – RP_ Sep 18 '16 at 19:28
  • $\begingroup$ The main interest in the solution is that all pairs $(a,b)$ are integers and $f(a,b)$ is a perfect square rational number. $\endgroup$ – T. Amdeberhan Sep 18 '16 at 20:13

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


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.



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


And then the solution is substituted in the above formula.



Consider the case which invited.


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

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


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

Then ;



  • $\begingroup$ Many thanks for working this out! But is it obvious that $a$ will come out integer? $\endgroup$ – მამუკა ჯიბლაძე Sep 23 '16 at 8:42
  • 1
    $\begingroup$ @მამუკაჯიბლაძე this will not always be. Only in some cases. Such as here by setting one of the solutions of the Pell equation is negative. $\endgroup$ – individ Sep 23 '16 at 8:47
  • $\begingroup$ Would it be possible to impose explicit additional constraints on solutions of the Pell equation which would be equivalent to the integrality of $a$? $\endgroup$ – მამუკა ჯიბლაძე Sep 23 '16 at 8:50
  • $\begingroup$ @მამუკაჯიბლაძე Why? It is necessary to consider all possible factorization of these coefficients. In some cases there will be a whole solution. In others. $\endgroup$ – individ Sep 23 '16 at 8:54
  • 1
    $\begingroup$ @მამუკაჯიბლაძე 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. $\endgroup$ – individ Sep 23 '16 at 9:05

For such equations:


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

You can write the solution.



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


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



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

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



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



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.



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 )$



Then decisions will be.



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

  • $\begingroup$ In the question, $t$ is rational, while $x$ and $y$ are integers $\endgroup$ – მამუკა ჯიბლაძე Sep 18 '16 at 20:11
  • $\begingroup$ @მამუკაჯიბლაძე 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 $\endgroup$ – individ Sep 19 '16 at 4:17
  • 3
    $\begingroup$ 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? $\endgroup$ – მამუკა ჯიბლაძე Sep 19 '16 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.