Given a real number $r$ and a non-negative integer $n$, is there a way to accurately find the $n^{th}$ (with the integer being the $0^{th}$ number in the continued fraction. If this can not be done for all $r$ what are some specific ones, like $\pi$ or $e$. I already now how to do this square roots.
2026-03-30 14:25:04.1774880704
On
Nth number of continued fraction
424 Views Asked by user9413 https://math.techqa.club/user/user9413/detail At
2
There are 2 best solutions below
3
On
You can do it recursively: $$\eqalign{f_0(r) &= \lfloor r \rfloor\cr f_{n+1}(r) &= f_n\left( \frac{1}{r - \lfloor r \rfloor}\right)\cr}$$ Of course this may require numerical calculations with very high precision. Actually, if $r$ is a rational number but you don't know it, no finite precision numerical calculation will suffice.
For arbitrary real numbers, there's no better method known than the 'abstract' one of simply extracting the digits through the usual recurrence relation; even for non-quadratic algebraic numbers — even for a number as simple as $\sqrt{2}+\sqrt{3}$! — nothing is known about any structure to the coefficients.
By contrast, if the goal is to take a number known to some precision and churn out an appropriate number of coefficients for its continued fraction, then there are excellent algorithms for doing that - and that might be enough to find some structure in the coefficients which can then be proven in a non-algorithmic fashion (for instance, the patterns in the continued fraction coefficients of $e$, or of quadratic surds, or in the Liouville numbers). The simplest way is to take a rational approximation $\frac ab$ to your number $r$ (for instance, if you have a decimal expansion $r=d_0.d_1d_2d_3d_4\ldots d_n$ to n digits of precision, then set $a=d_0d_1d_2\ldots d_n$ and $b=10^n$) and then run the extended Euclidean algorithm for the GCD on $a$ and $b$; the 'partial quotients' found along the way are precisely the coefficients of the continued fraction. See http://en.wikipedia.org/wiki/Euclidean_algorithm#Continued_fractions for the basics of the method; if you're interested in more details, volume 2 of Knuth's Art Of Computer Programming (specifically, section 4.5.3, problem 47 within that section and the references there) is an excellent next step.