# Link between the negative pell equation $x^2-dy^2=-1$ and a certain continued fraction

Consider the generalized continued fraction

$$F(x)=(x-1)-\cfrac{(x+1)}{x+\cfrac{(-1)(5)} {3x+\cfrac{(1)(7)}{5x+\cfrac{(3)(9)}{7x+\cfrac{(5)(11)}{9x+\ddots}}}}}$$

I experimentally discovered that at certain cases it converges to quadratic irrationals $\frac{a+b\sqrt{d}}{c}$ where $a,b,c$ and$d\gt1$(square free) are integers. Here's a list of some of its closed forms

$$F(1)=\frac{11+5\sqrt{5}}{3}$$

$$F(2)=-\sqrt{2}$$

$$F(3)=\frac{120-26\sqrt{13}}{69}$$

$$F(4)=\frac{109-25\sqrt{5}}{33}$$

$$F(5)=\frac{349-29\sqrt{29}}{71}$$

$$F(6)=\frac{258-35\sqrt{10}}{39}$$

$$F(7)=\frac{3610-212\sqrt{53}}{429}$$

$$F(8)=\frac{485-51\sqrt{17}}{47}$$

$$F(9)=\frac{8841-425\sqrt{85}}{717}$$

$$F(10)=\frac{1604-143\sqrt{26}}{111}$$

$$F(11)=\frac{5988-1250\sqrt{5}}{359}$$

$$F(12)=\frac{6105-481\sqrt{37}}{321}$$

$$F(13)=\frac{32395-1211\sqrt{173}}{1509}$$

$$F(14)=\frac{1754-625\sqrt{2}}{73}$$

$$F(16)=\frac{16891-1105\sqrt{65}}{573}$$

$$F(17)=\frac{27935-879\sqrt{293}}{863}$$

$$F(18)=\frac{12840-779\sqrt{82}}{363}$$

$$F(20)=\frac{12471-707\sqrt{101}}{299}$$

$$F(22)=\frac{26330-1403\sqrt{122}}{543}$$

$$F(23)=\frac{82390-2132\sqrt{533}}{1583}$$

$$F(26)=\frac{16036-765\sqrt{170}}{253}$$

To my surprise, the discriminants $d$ of the quadratic irrationals are only numbers for which the negative pell equation $x^2-dy^2=-1$ is solvable,see OEIS A031396.

Question:Can the link between the continued fraction and pell equation be proven?

• Do the (seemingly unnecessary?) parenthesis here havy any meaning? Commented Apr 24, 2016 at 13:07
• Your result is interesting because you must know that for classical continued fractions "having a value $(a+b\sqrt{c})/d), \ a,b,d \in \mathbb{Z}, d \in \mathbb{N}$ " (i.e., a real solution to a quadratic with integer coefficients is equivalent to having a periodical (classical...) continued fraction. Thus your generalized development in continuous fraction should be transformable into a classical periodical cont. fraction décomposition. Commented Apr 24, 2016 at 13:50
• Up to $F(20)$ is fine. :) Commented Apr 24, 2016 at 16:48
• @Tito Piezas III: thanks for checking ,I've just added to the list Commented Apr 24, 2016 at 17:09

Given your continued fraction $F(x)$, it seems it has a general closed-form. Define,

$$d=x^2+4\tag1$$

then,

$$F(x) = x-1-\frac{(x+1)\big(-x^3+12x+d\sqrt{d}\big)}{6(3x^2-4)}\tag2$$ hence,

$$G(x)=\frac{-x^3+12x+d\sqrt{d}}{6(3x^2-4)}=\cfrac{1}{x+\cfrac{(-1)(5)} {3x+\cfrac{(1)(7)}{5x+\cfrac{(3)(9)}{7x+\cfrac{(5)(11)}{9x+\ddots}}}}}\tag3$$

Plugging in $x$, you'll recover all your values, including the missing $F(15)$ and $F(19)$.

If $d$ as defined by $(1)$ is supposed to be square-free $d'$, then the negative Pell equation,

$$p^2-d'q^2 = -1\tag4$$

always has a solution.

1. Even $x$: If $x=2v$, then $d'=v^2+1$, and $p =v,\;q = 1$.
2. Odd $x$: Then $d'=x^2+4$, and $p=\frac{x(x^2+3)}{2},\;q=\frac{x^2+1}{2}$ while $p,q$ are integers since $x$ is odd.
• Fantastic @Tito,however a rigorous proof establishing the closed form is still needed. Commented Apr 24, 2016 at 17:46
• @Nicco: Yes. However, another interesting point is what is the cfrac for the other root, $$G'(x) = \frac{-x^3+12x\color{red}{-}d\sqrt{d}}{6(3x^2-4)}$$ Commented Apr 24, 2016 at 17:51
• I think ,just taking the reciprocal of the cfrac we have is good enough just like it is done when we need the conjugate of $\phi$ using its simple continued fraction Commented Apr 24, 2016 at 19:46
• Hm, using the reciprocal would do. By the way, how come you didn't find $F(15)$ and $F(19)$? Commented Apr 24, 2016 at 20:28
• @ Tito Piezas III :please ,see this closely related question Commented May 7, 2016 at 14:26