# A rational version of the $\frac{a^2+b^2}{1+ab}$ problem

There are so many versions of Alternative proof that $(a^2+b^2)/(ab+1)$ is a square when it's an integer around that probably what I am asking is also a duplicate. Well, in that case, just please mark it as a duplicate.

What I am wondering about is for which pairs $(a,b)$ is $\frac{a^2+b^2}{ab+1}$ a perfect square $\textit{in$\mathbb Q$}$?

Here is very little I have been able to observe experimentally.

The rationals of the form $\sqrt{\frac{a^2+b^2}{ab+1}}$ that occur for $a,b\leqslant500$ are $1,\frac{7}{5},\frac{41}{29},\frac{239}{169},\frac{338}{239},\frac{58}{41},\frac{17}{12},\frac{10}{7},\frac{140}{97},\frac{13}{9},\frac{37}{25},\frac{58}{39},\frac{106}{71},\frac{3}{2},\frac{65}{43},\frac{50}{33},\frac{29}{19},\frac{17}{11},\frac{374}{241},\frac{21}{13},\frac{377}{229},\frac{5}{3},\frac{52}{31},\frac{91}{54},\frac{377}{219}$, $\frac{500}{287},\frac{298}{169},\frac{74}{41},\frac{13}{7},\frac{17}{9},\frac{25}{13},\frac{241}{121},2,\frac{65}{32},\frac{260}{127},\frac{15}{7},\frac{41}{19},\frac{20}{9},\frac{202}{89},\frac{5}{2},\frac{13}{5},\frac{155}{58},\frac{113}{41},3,\frac{25}{8},\frac{73}{19},4,5,6,7$ (some of them appear several times for different pairs $(a,b)$). Seems like not all rationals can be obtained but I am very far from being sure about that.

Let us arrange the above pairs in layers, i. e. ask, for each $d=0,1,2,...$, what is the subset $S_d:=\{a\in\mathbb N\mid \text{$\frac{a^2+(a+d)^2}{a(a+d)+1}$is a perfect square in$\mathbb Q$}\}$ of $\mathbb N$.

Having looked up to $a=100000$ gives something that looks pretty impenetrable, at least for me: $$\begin{array}{r|l} d&S_d\\ \hline 0&\{1,7,41,239,1393,8119,47321,...\}\\ 1&\varnothing?\\ 2&\{6,40,238,1392,8118,47320,...\}\\ 3&\varnothing?\\ 4&\varnothing?\\ 5&\varnothing?\\ 6&\{1,2,9,26\}?\\ 7&\{8\}?\\ 8&\varnothing?\\ 9&\varnothing?\\ 10&\varnothing?\\ 11&\{8,32\}?\\ 12..15&\varnothing?\\ 16&\{7\}?\\ 17&\{7\}?\\ 18..21&\varnothing?\\ 22&\{8\}?\\ 23&\{33\}?\\ 24&\{3\}?\\ 25..27&\varnothing?\\ 28&\{20,84\}? \end{array}$$ The sequence $1,7,41,239,...$ for $S_0$ appears in OEIS as A002315 and satisfies $a_n=6a_{n-1}-a_{n-2}$; $S_2$ seems to be $S_0-1$. I have no clue about the rest.

Any takes?

• When $d=2$, it is $a_n = 6 a_{n-1} - a_{n-2} + 2$ with $a_0 = 0, a_1 = 6$.
– MT_
Aug 21, 2016 at 19:37
• Prime factors $q \equiv 3 \pmod 4$ of your numerator are going to be rare. To get $$A^2 x^2 - B^2 xy + A^2 y^2 = B^2,$$ and $\Delta = B^4 - 4 A^4,$ we find $(\Delta | q) = (-1|q).$ Therefore, $q|B$ implies $q|x$ and $q|y,$ so the form actually represents $B / q^2.$ In case such $B$ is prime, the form is the principal form, i.e. represents $1.$ For example, $25 x^2 - 49 xy + 25 y^2$ clearly represents $1, x=y=1.$ Clear that $4 x^2 - 9 xy + 4 y^2$ represents $-1,$ it also represents $1$ because the discriminant is a prime $17 \equiv 1 \pmod 4.$ Aug 22, 2016 at 2:51
• Here's a good one. From your $91/54,$ we find $2916 x^2 -8281 x y + 2916y^2$ does not integrally represent either $\pm 1,$ but it does integrally represent $169 = 8281/ 7^2$ Aug 22, 2016 at 2:56
• @WillJagy Do you imply that the question reduces to the reduction theory for quadratic forms? Aug 22, 2016 at 5:29
• Jan 20, 2020 at 7:28

I decided to make a list of one special case, when $A^2 x^2 - B^2 xy + A^2 y^2 = 1$ has an integer solution, meaning the form is the principal form. Oh, $\gcd(A,B) = 1$ and $A < B \sqrt 2.$ For this list, $A^2 x^2 - B^2 xy + A^2 y^2 = B^2$ is automatically possible, that was the original question. We do get plenty of $B$ divisible by primes $q \equiv 3 \pmod 4;$ when this happens, $B^2$ will be represented, but not primitively. As this way of writing gives very different bounds, we get some fractions not yet listed in the original question, such as $7/2$ and $7/3.$

===============================================

jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefCycle 4 -49 4

0  form              4         -49           4  delta     -1
1  form              4          41         -41

0          -1
1          -1

To Return
-1           1
-1           0

0  form   4 41 -41   delta  -1
1  form   -41 41 4   delta  11     ambiguous
2  form   4 47 -8   delta  -5
3  form   -8 33 39   delta  1
4  form   39 45 -2   delta  -23
5  form   -2 47 16   delta  2
6  form   16 17 -32   delta  -1
7  form   -32 47 1   delta  47
8  form   1 47 -32   delta  -1     ambiguous
9  form   -32 17 16   delta  2
10  form   16 47 -2   delta  -23
11  form   -2 45 39   delta  1
12  form   39 33 -8   delta  -5
13  form   -8 47 4   delta  11
14  form   4 41 -41

form   4 x^2  + 41 x y  -41 y^2

minimum was   1rep   x = 4858   y = 5293 disc 2337 dSqrt 48  M_Ratio  144
Automorph, written on right of Gram matrix:
-102158881  -1140891584
-111306496  -1243050465
=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./indefCycle 9 -49 9 0 form 9 -49 9 delta -1 1 form 9 31 -31 0 -1 1 -1 To Return -1 1 -1 0 0 form 9 31 -31 delta -1 1 form -31 31 9 delta 4 ambiguous 2 form 9 41 -11 delta -3 3 form -11 25 33 delta 1 4 form 33 41 -3 delta -14 5 form -3 43 19 delta 2 6 form 19 33 -13 delta -3 7 form -13 45 1 delta 45 8 form 1 45 -13 delta -3 ambiguous 9 form -13 33 19 delta 2 10 form 19 43 -3 delta -14 11 form -3 41 33 delta 1 12 form 33 25 -11 delta -3 13 form -11 41 9 delta 4 14 form 9 31 -31 form 9 x^2 + 31 x y -31 y^2 minimum was 1rep x = 1808 y = 2233 disc 2077 dSqrt 45 M_Ratio 25 Automorph, written on right of Gram matrix: -35019151 -148975584 -43250976 -183994735 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ =================================================  jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefPrincipal

3  /  1, 2,
4  /  1,
5  /  1, 2, 3,
6  /  1,
7  /  1, 2, 3, 4,
8  /  1,
9  /  1, 4, 5,
10  /  1,
11  /  1, 2, 3, 4, 6,
12  /  1, 7,
13  /  1, 2, 3, 4, 5, 7, 8, 9,
14  /  1, 9,
15  /  1, 2, 4,
16  /  1,
17  /  1, 2, 3, 4, 5, 8, 9, 10, 11, 12,
18  /  1,
19  /  1, 2, 3, 5, 7, 8, 9, 10, 12, 13,
20  /  1, 7,
21  /  1, 4, 5, 11, 13,
22  /  1, 15,
23  /  1, 2, 3, 7, 8, 9, 12, 13, 14, 16,
24  /  1, 7,
25  /  1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17,
26  /  1, 17,
27  /  1, 2, 7, 10, 11, 13, 14, 16, 17, 19,
28  /  1, 9,
29  /  1, 3, 4, 6, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
30  /  1, 7,
31  /  1, 2, 3, 4, 6, 7, 10, 11, 13, 15, 16, 20, 21,
32  /  1, 7, 15, 17,
33  /  1, 2, 4, 7, 8, 10, 13, 16, 17, 19, 23,
34  /  1, 7, 9, 23,
35  /  1, 2, 3, 4, 8, 9, 11, 13, 16, 18, 22, 23, 24,
36  /  1, 17,
37  /  1, 2, 3, 4, 5, 6, 8, 9, 11, 12, 13, 14, 15, 16, 18, 19, 21, 23, 25, 26,
38  /  1, 7, 9, 15, 23, 25,
39  /  1, 2, 5, 7, 8, 16, 20, 22, 23, 25,
40  /  1, 7, 17,
41  /  1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28,
42  /  1,
43  /  1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30,
44  /  1, 17, 23, 25, 31,
45  /  1, 2, 4, 11, 14, 16, 17, 19, 23, 26, 28, 29, 31,
46  /  1, 7, 17, 25,
47  /  1, 2, 6, 9, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 25, 26, 27, 28, 29, 30,
48  /  1,
49  /  1, 2, 4, 8, 9, 11, 15, 16, 19, 22, 23, 24, 25, 26, 27, 29, 30, 32, 33, 34,
50  /  1, 17, 33,

jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus


==================================================

• Very interesting! I now realize that my "layering" can be quite misleading... So maybe all rationals are obtainable after all? Aug 22, 2016 at 19:01
• @მამუკაჯიბლაძე I don't know. This way of calculating things allows for very large $x,y.$ If one of these forms does not represent $1,$ it may still represent $B^2$ or some $B^2 / w^2$ for a factor $w.$ Anyway, pretty long investigation if we gradually let the factorization of $B$ get more complicated. This answer gives some pretty good ideas when $B$ is prime. Aug 22, 2016 at 19:12
• @მამუკაჯიბლაძე Oh, this Lagrange method tells me only those number up to a small bound that are primitively represented by the form. Thus the result is complete for representing $1.$ However, $B^2$ will generally be too large for the Lagrange bound, so no definitive answer this way. Aug 22, 2016 at 19:15