Simple continued fraction

The sequence can be finite or infinite, resulting in a finite (or terminated) continued fraction like or an infinite continued fraction like Typically, such a continued fraction is obtained through an iterative process of representing a number as the sum of its integer part and the reciprocal of another number, then writing this other number as the sum of its integer part and another reciprocal, and so on.

⁠ has two closely related expressions as a finite continued fraction, whose coefficients ai can be determined by applying the Euclidean algorithm to

The numerical value of an infinite continued fraction is irrational; it is defined from its infinite sequence of integers as the limit of a sequence of values for finite continued fractions.

This way of expressing real numbers (rational and irrational) is called their continued fraction representation.

(It is customary to replace only the first comma by a semicolon to indicate that the preceding number is the whole part.)

In particular, it must terminate and produce a finite continued fraction representation of the number.

[5] When the terms eventually repeat from some point onwards, the continued fraction is called periodic.

This process can be efficiently implemented using the Euclidean algorithm when the number is rational.

For example, Every finite continued fraction represents a rational number, and every rational number can be represented in precisely two different ways as a finite continued fraction, with the conditions that the first coefficient is an integer and the other coefficients are positive integers.

[10][11] The larger a term is in the continued fraction, the closer the corresponding convergent is to the irrational number being approximated.

Other numbers like e have only small terms early in their continued fraction, which makes them more difficult to approximate rationally.

Even-numbered convergents are smaller than the original number, while odd-numbered ones are larger.

When using the Babylonian method to generate successive approximations to the square root of an integer, if one starts with the lowest integer as first approximant, the rationals generated all appear in the list of convergents for the continued fraction.

Specifically, the approximants will appear on the convergents list in positions 0, 1, 3, 7, 15, ... , 2k−1, ... For example, the continued fraction expansion for

The infinite continued fraction provides a homeomorphism from the Baire space to the space of irrational real numbers (with the subspace topology inherited from the usual topology on the reals).

The infinite continued fraction also provides a map between the quadratic irrationals and the dyadic rationals, and from other irrationals to the set of infinite strings of binary numbers (i.e. the Cantor set); this map is called the Minkowski question-mark function.

Roughly speaking, continued fraction convergents can be taken to be Möbius transformations acting on the (hyperbolic) upper half-plane; this is what leads to the fractal self-symmetry.

.Corollary: The infinite continued fraction provides a homeomorphism from the Baire space to

Namely, n/d is a convergent for x if and only if |dx − n| has the smallest value among the analogous expressions for all rational approximations m/c with c ≤ d; that is, we have |dx − n| < |cx − m| so long as c < d. (Note also that |dkx − nk| → 0 as k → ∞.)

The first quotient, supposed divided by unity, will give the first fraction, which will be too small, namely, ⁠3/1⁠.

The demonstration of the foregoing properties is deduced from the fact that if we seek the difference between one of the convergent fractions and the next adjacent to it we shall obtain a fraction of which the numerator is always unity and the denominator the product of the two denominators.

The result being, that by employing this series of differences we can express in another and very simple manner the fractions with which we are here concerned, by means of a second series of fractions of which the numerators are all unity and the denominators successively be the product of every two adjacent denominators.

A non-simple continued fraction is an expression of the form where the an (n > 0) are the partial numerators, the bn are the partial denominators, and the leading term b0 is called the integer part of the continued fraction.

above consisting of cubes uses the Nilakantha series and an exploit from Leonhard Euler.

[21] The numbers with periodic continued fraction expansion are precisely the irrational solutions of quadratic equations with rational coefficients; rational solutions have finite continued fraction expansions as previously stated.

While there is no discernible pattern in the simple continued fraction expansion of π, there is one for e, the base of the natural logarithm: which is a special case of this general expression for positive integer n: Another, more complex pattern appears in this continued fraction expansion for positive odd n: with a special case for n = 1: Other continued fractions of this sort are where n is a positive integer; also, for integer n: with a special case for n = 1: If In(x) is the modified, or hyperbolic, Bessel function of the first kind, we may define a function on the rationals ⁠p/q⁠ by which is defined for all rational numbers, with p and q in lowest terms.

Most irrational numbers do not have any periodic or regular behavior in their continued fraction expansion.

Continued fractions play an essential role in the solution of Pell's equation.

For example, for positive integers p and q, and non-square n, it is true that if p2 − nq2 = ±1, then ⁠p/q⁠ is a convergent of the regular continued fraction for √n.

[23] Continued fractions also play a role in the study of dynamical systems, where they tie together the Farey fractions which are seen in the Mandelbrot set with Minkowski's question-mark function and the modular group Gamma.

Convergents approaching the golden ratio
Best rational approximants for π (green circle), e (blue diamond), ϕ (pink oblong), (√3)/2 (grey hexagon), 1/√2 (red octagon) and 1/√3 (orange triangle) calculated from their continued fraction expansions, plotted as slopes y / x with errors from their true values (black dashes)
The following Maple code will generate continued fraction expansions of pi