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?


Solution 1:

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.