Formula for the simple reapeted infinitely continued fractions I was thinking about infinite fractions of the form $1+\frac{a}{1+\frac{a}{1+...}}$ but realised it would be much more useful and satisfying and only a little bit harder to solve fractions of the form $a+\frac{b}{a+\frac{b}{a+...}}$. One thing that I realised is that solving that fraction should be equivilant to solving for $x$ in $x=a+\frac{b}{x}$. Working that out I got $x=\frac{1}{2}(a\pm\sqrt{4b+a^2})$, but this formula is not defined for all and $a$ and $b$ values because of the square root, and disagrees with the infinite fraction for many values of $a$ and $b$ but works for others. Is there another formula that I missed online, or is there no general formula (which I doubt), or is it just a simple mistake that I made. One thing that I noticed is that most of the inconsistencies are when $16a^2>b^4$.
 A: A partial answer, in which the series of fractions is proved convergent if $4b + a^2 \ge 0$ and $a \neq 0$, but not proved divergent if $4b + a^2 < 0$ (though this is probably true). For given $a$ and $b$, the successive terms are defined by $x_0 = 1$, $x_{n+1} = a + b/x_n$ (provided $x_n \neq 0$). If $a = 0$, the terms are alternately $1$ and $b$, and hence converge iff $b = 1$. If $a + b = 1$ then all terms are $1$. From now on assume $a \neq 0$ and $a + b \neq 1$. First consider $4b + a^2 = 0$. We can put $a = 2c$ and $b = -c^2$ where (by the above assumptions) $c \neq 0, 1$. It's easily proved by induction that
$$x_n = {{(n + 1)c - nc^2}\over{n - (n - 1)c}} = {{c(1 - c + 1/n)}\over{1 - c + c/n}},$$
from which $x_n \rightarrow c$ as $n \rightarrow \infty$
(but the inductive definition fails if $c = 1 + 1/n$ for some $n$). Now consider $4b + a^2 > 0$. Define
$$r = {1\over2}(a + \sqrt{4b + a^2}),\quad s={1\over2}(a - \sqrt{4b + a^2}).$$
By induction, $x_n = p_{n+1}/p_n$ where $p_n$ is defined by the Fibonacci-like recurrence
$$p_0 = 1,\quad p_1 = 1,\quad p_{n+1} = ap_n + bp_{n-1}.$$
This is solved in the usual way as $p_n = Ar^n + Bs^n$, where $A = (1 - s)/(r - s)$, $B = (r - 1)/(r - s)$. Hence
$$x_n = {{(1 - s)r^{n+1} + (r - 1)s^{n+1}}\over{(1-s)r^n + (r - 1)s^n}}.$$
The above assumption $a + b \neq 1$ implies $r \neq 1$ and $s \neq 1$. If $a > 0$ then $|r| > |s|$, hence $x_n \rightarrow r$. If $a < 0$ then $|s| > |r|$, hence $x_n \rightarrow s$.
