Continued Fraction Generator
Continued Fraction Generator computes the continued fraction representation of a number and its convergents, visualizing how they approximate the input number.
Continued Fraction Overview
A continued fraction represents a number as a sequence of integers \\( [a_0; a_1, a_2, \dots] \\), where \\( a_0 \\) is the integer part and \\( a_n \\) are the terms of the continued fraction. Convergents are rational approximations \\( p_n/q_n \\) derived from the terms.
Formula: \\( x = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{\ddots}}} \\)
Convergent Calculation:
Numerator: \\( p_n = a_n p_{n-1} + p_{n-2} \\)
Denominator: \\( q_n = a_n q_{n-1} + q_{n-2} \\)
Where:
- \\( x \\): Input number (rational or irrational)
- \\( a_n \\): Continued fraction terms (integers)
- \\( p_n/q_n \\): Convergent (rational approximation)
Example Calculations
Example 1: Pi (π ≈ 3.14159)
Continued Fraction: \\( [3; 7, 15, 1, 292, \dots] \\)
Convergents: \\( 3/1, 22/7, 333/106, 355/113, \dots \\)
\\( 355/113 \approx 3.14159292 \\)
Example 2: Rational Number (13/11 ≈ 1.181818)
Continued Fraction: \\( [1; 5, 2] \\)
Convergents: \\( 1/1, 6/5, 13/11 \\)
\\( 13/11 = 1.181818 \\)
Example 3: Square Root of 2 (√2 ≈ 1.414213)
Continued Fraction: \\( [1; 2, 2, 2, \dots] \\)
Convergents: \\( 1/1, 3/2, 7/5, 17/12, \dots \\)
\\( 17/12 \approx 1.416667 \\)