KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesContinued Fraction Expansion of Real NumbersEngineering · Engineering MathematicsLesson 718/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Jogincontinued fractionsconvergentsquadratic irrationalDiophantine approximation
On this page

Ask about this page

KEVOS AIContinued Fraction Expansion of Real Numbers

KEVOS knowledge first · trusted web sources when needed

Euclidean Algorithms and Congruences

Continued Fraction Expansion of Real Numbers

Continued fractions, convergents as best rational approximations, and the periodic expansion of quadratic irrationals.

Engineering / MathematicsEuclidean Algorithms and Congruences2 min readKV-MATH-0517

Continued fractions are the Euclidean algorithm applied to real numbers. They produce the best rational approximations available for a given denominator, and for quadratic irrationals they become periodic — which is the key to real quadratic field computation.

The expansion

x = a_0 + 1/(a_1 + 1/(a_2 + 1/(a_3 + ...)))The partial quotients a_i are obtained by repeatedly taking the integer part and inverting the remainder.

Computing the expansion

  1. Take integer partThe floor of the current value is the next partial quotient.
  2. SubtractRemove the integer part, leaving a value in the unit interval.
  3. InvertTake the reciprocal and repeat.

Note

For a rational number this is exactly the Euclidean algorithm, and it terminates. For an irrational it continues forever.

Convergents

Truncating the expansion gives the convergents, computed by a simple recurrence on numerators and denominators.

p_n = a_n p_(n-1) + p_(n-2), q_n = a_n q_(n-1) + q_(n-2)Started from the conventional initial values.

Key point

Every convergent is a best approximation: no fraction with a smaller denominator is closer. This optimality is what makes continued fractions the right tool for recognising a rational number from a floating-point approximation.

Quadratic irrationals

The expansion of a quadratic irrational is eventually periodic, and for the square root of a non-square integer it is purely periodic after the first term with a palindromic structure.

Why periodicity matters computationally
PropertyConsequence
PeriodicityThe expansion can be computed and stored exactly
Palindromic periodHalves the work; the second half mirrors the first
Period end detectionSignals a solution to the Pell equation
Convergents at period endGive the fundamental unit of the real quadratic field

Key point

This is the classical route to the fundamental unit of a real quadratic field — see the fundamental unit. It is also the mechanism behind CFRAC, where the convergents supply small quadratic residues.

Precision

Pitfall

Computing the expansion of a quadratic irrational in floating point loses accuracy rapidly, and the partial quotients become wrong without warning. Use the exact integer recurrence on the surd representation instead — it is both exact and faster.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 1.3.5. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Related pages

  • Reduction of Indefinite Forms and the Cycle Structure
  • The Fundamental Unit of a Real Quadratic Field
  • The Continued Fraction Factorisation Method
  • Chinese Remainder Theorem Algorithms
  • Structure of the Unit Group Modulo n

Continue learning

Chinese Remainder Theorem AlgorithmsArticle · Engineering MathematicsNEXT LESSON →Structure of the Unit Group Modulo nArticle · Engineering MathematicsThe Extended Euclidean Algorithm and Bezout CoefficientsArticle · Engineering MathematicsLegendre, Jacobi and Kronecker Symbol ComputationArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®