# Solving quadratics using continued fractions - 2 puzzling cases for me.

Suppose you have $$x^2 - 2x -1 = 0$$, as in the related question (Solving Quadratics Using Continued Fractions/Nonsimple to Simple Continued Fractions). Although that question did not go through the steps used to calculate $$[2; \overline{2}]$$, there is a particularly simple technique that can be used for such quadratics (constant of -1, coefficient of 1 for the linear term), which is to divide through by $$x$$ and rearrange to get $$x = 2 + \frac{1}{x}$$ in this example. Simple enough, but here are two things that puzzle me. The first is, suppose I rearranged as $$x = \frac{1}{-2 + x}$$ instead, getting $$[-2;\overline{-2}]$$ instead of $$[2; \overline{2}]$$. OK, I know continued fraction representations are not unique, but in calculating $$[-2; \overline{-2}]$$ I get $$-r$$ where $$r = [2; \overline{2}] = 1 + \sqrt{2}$$, while the quadratic formula gives $$1 - \sqrt{2}$$ for the other root.

The second thing I noticed was supposing I try the same basic technique on a quadratic with imaginary roots, say $$x^2 + 2x + 2 = 0$$, with roots $$-1 \pm i$$. It isn't a simple continued fraction, but dividing by $$x$$ and rearranging as before I get $$x = -2 - \frac{2}{x}$$. I'm not sure how to calculate a convergent for a non-simple continued fraction (and I haven't tried to use the technique in the referenced question yet to convert this to a simple continued fraction if it is possible to do that even), but if nothing else it doesn't look like this expression even converges. That would make sense, but I'm wondering if there is any connection to the correct answer anyway (analogous to a https://en.wikipedia.org/wiki/Ramanujan_summation), and what the best intuition for this failure of a simple technique might be?

The formula $$x = \frac 1{-2 + x}$$ has solution $$x = [0; \overline{-2}]$$ not $$[-2; \overline{-2}]$$. Note that the entry before the semi-colon is the integral part, which is $$0$$ for $$\dfrac 1{-2 +\dfrac 1{-2 + \dfrac 1{ -2 + \dots}}}$$ And sure enough, $$[0; \overline{-2}] = [-2; \overline{-2}] + 2 = (-[2; \overline{2}]) + 2 = -1-\sqrt 2 + 2 = 1-\sqrt 2$$
The recursion formulas for $$x^2 + 2x + 2 = 0$$ are \begin{align}x &= -2 + \dfrac {-2}x\\ x &= \dfrac{-2}{x+2}\end{align} which solve to \begin{align}x &= [\overline{-2; 1}] = [-2; \overline{1,-2}]\\x&=[0; \overline{-1,2}]\end{align}
When the terms of a continued fraction (other than the first) are all $$\ge 1$$, the fraction is guaranteed to converge. But when the terms can be negative, that guarantee no longer holds. In this case, the convergents can be obtained from the recursion formulas, considered as continuous functions on the Riemann Sphere. If $$f$$ is the recursion formula, then the sequence of convergents is given by $$f(\infty), f^2(\infty), f^3(\infty), \ldots$$ where $$f^k := \underbrace{f\circ \cdots\circ f}_{k\text{ times}}$$. For these two recursions, they are $$-2, -1, 0, \infty, -2, \ldots\\ 0, -1, -2, \infty, 0, \dots$$
As you can see, they fall into loops of the same four values, with the only difference between the two being in which direction they go (indeed, the two recursion functions are inverses of each other). In fact, $$f(x) = -2 + \frac{-2}x$$ satisfies $$f^4(x) = x$$ for all $$x$$, so it doesn't even help to start somewhere other than $$\infty$$.