# Compute a finite periodic continued fraction

Compute a FINITE continued fraction of the form

$$x-\cfrac{1}{x-\cfrac{1}{x-\cfrac{1}{x-\cfrac{1}{x-\cdots}}}}$$

I have found many examples on the net but all of them are either infinite or of a particular number of levels. Any help would be good.

• You need to define what happens at the bottom and what counts as the number of levels. In particular is it $x-\frac1x$ or $x-\frac1{x-1}$? You can then find a recurrence for the answer and solve it for a closed form Aug 23, 2021 at 23:12
• Do you want someone to choose a certain value for $x$ and a finite number of levels? What would it mean otherwise to "compute" the continued fraction? Aug 23, 2021 at 23:22
• The three dots stand for 1/x. If I am not wrong this yields the recurrence $a_{n+1}=a_{0}-1/a_{n}$ for $n\geq 0$. It is a non-linear recurrence. Is there a solution in terms of $a_0=x$, so $a_n=f(x)$ with a 'nice' expression for $f(x)$? Aug 23, 2021 at 23:33
• It is indeed possible to expand a finite continued fraction using its convergents, thanks to its connection with linear fractional transformations. You might want to give this Wikipedia article a read. Aug 24, 2021 at 4:15

Define $$(A_n(x))_{n\geq 0}$$ by

$$A_n(x) = x, \qquad A_{n+1} = x - \frac{1}{A_n(x)}.$$

Then it is easy to check that we can write

$$A_n(x) = \frac{G_{n+1}(x)}{G_n(x)},$$

where

$$G_0(x) = 1, \qquad G_{1}(x) = x, \qquad G_{n+2}(x) = x G_{n+1}(x) - G_n(x).$$

Now note that $$F_n(x) = i^{-n} G_n(i x)$$ satisfies

$$F_0(x) = 1, \qquad F_1(x) = x, \qquad F_{n+2}(x) = x F_{n+1}(x) + F_n(x),$$

which is the (shifted) Fibonacci polynomials. This allows us to find the exact formula for the coefficients of $$G_n(x)$$ in terms of the binomial coefficients.