# Last term of repeating continued fraction expansion

Once again, working with stable vector bundles on $\mathbb{P}^2$ I have run into a question that is really out of my area. (Thanks to everybody who helped out with my last question!)

Let $D>9$ be a rational number which is not a square, and consider the quadratic irrational

$$\xi = \frac{-3 + \sqrt{D}}{2},$$

(I'd be willing to force $D$ to be an integer, and even to assume $D \equiv 5 \pmod{8}$, but I don't think it matters). Let $r$ be the positive integer such that

$$(2r+1)^2 < D < (2r+3)^2.$$

Numerous examples with Mathematica suggest that the continued fraction expansion of $\xi$ takes the form

$$\xi = [r-1;\overline{a_1,\ldots,a_k}],$$ where the last term of the repeating part is $a_k = 2r+1$.

For my particular situtation, I'd be happy enough to know that the number $2r+1$ appears somewhere in the expansion.

As I know almost nothing about continued fractions aside from statements of the basic results, I haven't the slightest idea how to prove something like this. I also don't have a source which does much more advanced things than show that the expansion of a quadratic irrational always repeats. Are statements like this well-known? And where should I look for more advanced theory relevant to this problem?

In case it helps, the original form I came to this number is as follows. Put $$q = \frac{1}{8}(D-5).$$ Then $\xi$ is a solution of the equation $$\frac{1}{2}(x^2+3x+1) = q.$$ Thanks!

EDIT: At request, here is what Mathematica gives for the continued fractions for some $D$:

$D=5: [0;-2,\overline{-1}]$ (but I am requiring $D>9$)

$D=10: [0;\overline{12,3}]$

$D=13: [0;\overline{3}]$

$D=141: [4;\overline{2,3,2,11}]$

• Your first definition of $\xi$ is negative, but the continued fraction is for a positive irrational. – Will Jagy Sep 3 '12 at 4:52
• Please give your continued fractions for $D=5$ and $D=13.$ – Will Jagy Sep 3 '12 at 4:56
• Oh, well. Note that if you take $\xi + 2$ you get $\frac{1 + \sqrt D}{2}.$ There really should be a standard descrition somewhere for this. in comparison, for $\sqrt D$ itself, the last $a_k = 2 a_0.$ Somebody has proved the analogous pattern for your problem. Actually, the item that gives a purely periodic continued fraction, which is what you want, is apparently $\frac{2r+1 + \sqrt D}{2}.$ See if I can prove that. – Will Jagy Sep 3 '12 at 5:17

It's known that a quadratic irrational has a purely periodic continued fraction expansion if and only if it is greater than $1$ and its conjugate is between $-1$ and $0$. Your observation amounts to proving that $r+2 + (-3+\sqrt{D})/2$ has this property (note that adding $r + 2$ makes it start with $2r+1$). This amounts to checking that $-1 < (2r+1 - \sqrt{D})/2 < 0$, which is equivalent to your assumption that $(2r+1)^2 < D < (2r+3)^2$.

• Awesome, thanks! Any idea where I could find this fact? (Forgive my earlier comment, I had forgotten the term "purely periodic" includes the integer part) – Jack Huizenga Sep 3 '12 at 5:38
• It should be in most accounts of continued fractions for quadratic irrationals. It's in Section 9 of the continued fractions chapter (Chapter IV) of Davenport's book The Higher Arithmetic, and it's on page 45 of the continued fractions book by Rockett and Szüsz. – Henry Cohn Sep 3 '12 at 5:55
• Great, thanks again! I just found it in Mollin, "Fundamental Number Theory" p. 241 as well. – Jack Huizenga Sep 3 '12 at 5:56

EDIT: I got your fact right here.

ORIGINAL: It seems Henry got it. Meanwhile, let me point out how things appear from the Lagrange viewpoint of right-adjacent reduced forms: given odd numbers $n$ and $1 \leq m \leq n,$ the cycle for the form $\langle -1, n, m \rangle$ has penultimate form $\langle m, n, -1 \rangle,$ then "digit" $\delta = -n,$ then the end of the cycle is again $\langle -1, n, m \rangle .$ Well, see the method in my answer at Upper bound of period length of continued fraction representation of very composite number square root where the fact you need, the final $\delta = -n,$ follows from the definition of the $\delta$'s.

Examples:

=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./indefCycle Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2 -1 5 1 0 form -1 5 1 1 0 0 1 To Return 1 0 0 1 0 form -1 5 1 delta 5 1 form 1 5 -1 delta -5 2 form -1 5 1 minimum was 1rep 1 0 disc 29 dSqrt 5.3851648071 M_Ratio 29 Automorph, written on right of Gram matrix: -1 5 5 -26 Trace: -27 gcd(a21, a22 - a11, a12) : 5 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefCycle
Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2
-1 5 3

0  form             -1           5           3

1           0
0           1

To Return
1           0
0           1

0  form   -1 5 3   delta  1
1  form   3 1 -3   delta  -1
2  form   -3 5 1   delta  5
3  form   1 5 -3   delta  -1
4  form   -3 1 3   delta  1
5  form   3 5 -1   delta  -5
6  form   -1 5 3
minimum was   1rep 1 0 disc   37 dSqrt 6.0827625303  M_Ratio  37
Automorph, written on right of Gram matrix:
-13  72
24  -133
Trace:  -146   gcd(a21, a22 - a11, a12) : 24
=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./indefCycle Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2 -1 5 5 0 form -1 5 5 1 0 0 1 To Return 1 0 0 1 0 form -1 5 5 delta 1 1 form 5 5 -1 delta -5 2 form -1 5 5 minimum was 1rep 1 0 disc 45 dSqrt 6.7082039325 M_Ratio 45 Automorph, written on right of Gram matrix: -1 5 1 -6 Trace: -7 gcd(a21, a22 - a11, a12) : 1 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefCycle
Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2
-1 7 1

0  form             -1           7           1

1           0
0           1

To Return
1           0
0           1

0  form   -1 7 1   delta  7
1  form   1 7 -1   delta  -7
2  form   -1 7 1
minimum was   1rep 1 0 disc   53 dSqrt 7.2801098893  M_Ratio  53
Automorph, written on right of Gram matrix:
-1  7
7  -50
Trace:  -51   gcd(a21, a22 - a11, a12) : 7
=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./indefCycle Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2 -1 7 3 0 form -1 7 3 1 0 0 1 To Return 1 0 0 1 0 form -1 7 3 delta 2 1 form 3 5 -3 delta -2 2 form -3 7 1 delta 7 3 form 1 7 -3 delta -2 4 form -3 5 3 delta 2 5 form 3 7 -1 delta -7 6 form -1 7 3 minimum was 1rep 1 0 disc 61 dSqrt 7.8102496759 M_Ratio 61 Automorph, written on right of Gram matrix: -79 585 195 -1444 Trace: -1523 gcd(a21, a22 - a11, a12) : 195 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$ ./indefCycle
Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2
-1 7 5

0  form             -1           7           5

1           0
0           1

To Return
1           0
0           1

0  form   -1 7 5   delta  1
1  form   5 3 -3   delta  -1
2  form   -3 3 5   delta  1
3  form   5 7 -1   delta  -7
4  form   -1 7 5
minimum was   1rep 1 0 disc   69 dSqrt 8.3066238629  M_Ratio  69
Automorph, written on right of Gram matrix:
2  -15
-3  23
Trace:  25   gcd(a21, a22 - a11, a12) : 3
=========================================
jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$./indefCycle Input three coefficients a b c for indef f(x,y)= a x^2 + b x y + c y^2 -1 7 7 0 form -1 7 7 1 0 0 1 To Return 1 0 0 1 0 form -1 7 7 delta 1 1 form 7 7 -1 delta -7 2 form -1 7 7 minimum was 1rep 1 0 disc 77 dSqrt 8.7749643874 M_Ratio 77 Automorph, written on right of Gram matrix: -1 7 1 -8 Trace: -9 gcd(a21, a22 - a11, a12) : 1 ========================================= jagy@phobeusjunior:~/old drive/home/jagy/Cplusplus$