Continued Fraction Calculator

Enter a decimal value and expansion depth to compute the continued fraction [a0; a1, a2, …], best rational approximation, and full convergents table.
Luis GonzalezCreated by Luis GonzalezLast updated:

How to Use This Calculator

  1. 1

    Enter Decimal Value

    Input the decimal number you wish to expand into a continued fraction (e.g., 3.14159 for Pi or 1.61803 for the Golden Ratio).

  2. 2

    Specify Depth (Max Terms)

    Enter the maximum number of partial quotients (terms) you want the calculator to compute. A higher depth yields a more precise approximation, typically between 1 and 20.

  3. 3

    Review Your Results

    Examine the continued fraction representation, the best rational approximation, its decimal value, and the absolute error at each step.

Example Calculation

A mathematician wants to find the continued fraction representation of Pi (3.14159) up to 6 terms.

Decimal Value

3.14159

Depth (Max Terms)

6

Results

[3; 7, 15, 1, 29, 4, 1]

Tips

Identify Rational Approximations

The convergents of a continued fraction provide the 'best' rational approximations for an irrational number, meaning they are closer to the actual value than any other fraction with a smaller denominator.

Recognize Patterns for Irrationals

For certain irrational numbers, like the square root of non-square integers, the continued fraction expansion is periodic. Recognizing these patterns can reveal deep mathematical properties.

Use for Diophantine Equations

Continued fractions are a powerful tool for solving linear Diophantine equations, particularly when finding integer solutions to equations of the form ax + by = c.

Exploring Rational Approximations with the Continued Fraction Calculator

The Continued Fraction Calculator transforms any decimal into its continued fraction representation, revealing a sequence of increasingly accurate rational approximations.

This tool is fundamental in number theory, allowing mathematicians and students to visualize how irrational numbers like Pi or the Golden Ratio can be precisely approximated.

Understanding continued fractions is critical for applications ranging from cryptography to the design of electronic filters, where precise rational approximations are essential.

Applications of Continued Fractions in Number Theory

Continued fractions hold a significant place in number theory, offering powerful methods for understanding and approximating real numbers.

They are especially valuable for irrational numbers, providing a sequence of "best" rational approximations—fractions that are closer to the irrational number than any other fraction with a smaller denominator.

This property is exploited in algorithms for solving Diophantine equations, which seek integer solutions, and in the study of quadratic irrationals, whose continued fractions exhibit a repeating pattern.

Beyond theoretical applications, continued fractions underpin algorithms in computer science, such as those for arbitrary-precision arithmetic and in the design of efficient search algorithms.

The Algorithm for Continued Fraction Expansion

The process of expanding a decimal into a continued fraction involves repeatedly extracting the integer part and taking the reciprocal of the fractional part.

For a given number x, the steps are:

  1. Find the integer part a₀ = floor(x).
  2. Calculate the fractional part f₀ = x - a₀.
  3. If f₀ is 0, the process terminates. Otherwise, set x₁ = 1 / f₀.
  4. Repeat steps 1-3 for x₁, x₂, and so on, to find a₁, a₂, etc.

This iterative process generates the sequence [a₀; a₁, a₂, a₃, ...], which represents the continued fraction.

💡 Continued fractions can be used to approximate square roots. For a direct calculation, our Roots Table Tool provides instant values for various numbers.

Expanding Pi (3.14159) to a Continued Fraction

Let's expand the decimal value 3.14159 to a Continued Fraction with a Depth of 6 terms.

  1. Term 0 (a₀): floor(3.14159) = 3. Remainder: 0.14159.
  2. Term 1 (a₁): 1 / 0.14159 ≈ 7.0625. floor(7.0625) = 7. Remainder: 0.0625.
  3. Term 2 (a₂): 1 / 0.0625 ≈ 15.99. floor(15.99) = 15. Remainder: 0.99.
  4. Term 3 (a₃): 1 / 0.99 ≈ 1.00. floor(1.00) = 1. Remainder: 0.00.
  5. Term 4 (a₄): 1 / 0.00... ≈ 29.20. floor(29.20) = 29. Remainder: 0.20.
  6. Term 5 (a₅): 1 / 0.20... ≈ 4.99. floor(4.99) = 4. Remainder: 0.99.
  7. Term 6 (a₆): 1 / 0.99... ≈ 1.00. floor(1.00) = 1.

The Continued Fraction is [3; 7, 15, 1, 29, 4, 1].

The best rational approximation at this depth is 355/113, which equals 3.1415929..., very close to Pi.

💡 For algebraic problems that might arise from Diophantine equations or number theory, our System of Linear Equations Solver (2 Variables) can help find exact solutions.

From Ancient Greece to Modern Math: The History of Continued Fractions

The concept of continued fractions has a rich history, with its roots tracing back to ancient Greece.

Euclid's algorithm for finding the greatest common divisor (GCD) implicitly contained the method for generating continued fractions, although it wasn't explicitly formalized as such.

Indian mathematicians also explored similar concepts.

The formal study of continued fractions truly began in the 17th century with European mathematicians like Pietro Cataldi, who used them for approximating square roots.

It was Leonhard Euler in the 18th century who extensively developed the theory, demonstrating their properties and applications, including their connection to the constant e.

Later, Joseph-Louis Lagrange proved that the continued fraction expansion of any quadratic irrational is periodic, solidifying their importance in number theory and paving the way for modern applications in fields like cryptography and computational mathematics.

Frequently Asked Questions

What is a continued fraction in mathematics?

A continued fraction is an expression obtained through an iterative process of representing a real number as the sum of its integer part and the reciprocal of another number, which is then itself written as the sum of its integer part and another reciprocal, and so on. It provides a way to approximate real numbers, especially irrationals, with rational numbers.

How are continued fractions used to approximate irrational numbers?

Continued fractions generate a sequence of rational approximations, called convergents, that get progressively closer to the original irrational number. These convergents are often the 'best' possible rational approximations for their size, meaning no other fraction with a smaller denominator is closer to the true value.

What is the significance of the terms (a₀, a₁, a₂) in a continued fraction?

The terms a₀, a₁, a₂, and so on, are called partial quotients or coefficients. a₀ is the integer part of the number, and subsequent terms a₁, a₂, etc., are positive integers derived from the reciprocals of the fractional parts. These terms uniquely define the continued fraction and its convergents.

Can all real numbers be represented as a continued fraction?

Yes, every real number can be represented as a continued fraction. Rational numbers have finite continued fractions, while irrational numbers have infinite continued fractions. For quadratic irrationals (e.g., √2), the continued fraction is eventually periodic, a significant property in number theory.