Skip to content

ContinuedFraction

The regular continued fraction of . Its partial quotients are the run lengths of the rational's Stern–Brocot path, and the -exponents of its matrix — one object under three names.

ContinuedFraction(x)the partial quotients of a rational — compute-engine's own head
SageMathcontinued_fraction(x)SymPylist(continued_fraction(x))
ContinuedFraction(x, n)the first terms, for an irrational — also compute-engine's
FromContinuedFraction(list)back to the rational — compute-engine's own
SageMathcontinued_fraction(list)SymPylist(continued_fraction(list))
SternBrocotPath(p, q)the same data as a word in and
FareySequence(n)every reduced in with , in order
SageMathcontinued_fraction(n)SymPylist(continued_fraction(n))

Domain: The modular group

Details
  • `ContinuedFraction` and `FromContinuedFraction` are compute-engine's, not ours — pass the RATIONAL, not a numerator and denominator, since the two-argument form means "the first terms"
  • The expansion is made unique by never ending in : is rewritten
  • The path is with the LAST exponent one short — the final step is the arrival, not a turn
  • Consecutive Farey fractions satisfy , which is a determinant, which is a group element
  • The Fibonacci fractions alternate , the sense in which is the most irrational number

Examples

See also: ModularWord, IntegerDigits