Пошаговые инструкции
Identify Your Number and Initialize
Begin with the number `x` for which you want to find the continued fraction. Calculate the first partial quotient `a_0` by taking the floor of `x`: `a_0 = floor(x)`. This `a_0` is the integer part of your number.
Iteratively Calculate Subsequent Partial Quotients
For each subsequent partial quotient `a_n`, you first calculate a new `x_n` value. Start with `x_1 = 1 / (x - a_0)`. Then, for `n >= 1`, compute `a_n = floor(x_n)`. If `x_n - a_n` is not zero, calculate the next `x` value as `x_{n+1} = 1 / (x_n - a_n)`. Repeat this step until the remainder `x_n - a_n` is zero (for rational numbers) or you have enough partial quotients for irrational numbers.
Construct the Convergents (Rational Approximations)
Once you have your partial quotients `a_0, a_1, a_2, ...`, use the recursive formulas to find the numerators (`p_n`) and denominators (`q_n`) of the convergents. Initialize with `p_{-2}=0, p_{-1}=1, q_{-2}=1, q_{-1}=0`. Then, for `n >= 0`, calculate `p_n = a_n * p_{n-1} + p_{n-2}` and `q_n = a_n * q_{n-1} + q_{n-2}`. Each `C_n = p_n / q_n` is a rational approximation.
Review and Understand the Output
The sequence `[a_0; a_1, a_2, ...]` is the continued fraction expansion. The sequence of `C_n` values are the convergents, which provide increasingly accurate rational approximations of your original number `x`. Observe how these convergents oscillate around `x` while getting progressively closer.
Continued fractions offer a unique way to represent real numbers, providing a sequence of increasingly accurate rational approximations. They are particularly valuable in number theory, approximation theory, and for understanding the properties of irrational numbers. This guide will walk you through the manual process of deriving a continued fraction expansion, identifying its partial quotients, and constructing its convergents.
Prerequisites
To effectively follow this guide, you should have a solid understanding of:
- Basic Arithmetic: Addition, subtraction, multiplication, and division.
- Reciprocals: Understanding that the reciprocal of
xis1/x. - Floor Function: The floor function, denoted
floor(x)or⌊x⌋, gives the greatest integer less than or equal tox. For example,floor(3.14) = 3andfloor(5) = 5.
Understanding the Continued Fraction Formula
A continued fraction represents a real number x in the form:
x = a_0 + 1/(a_1 + 1/(a_2 + 1/(a_3 + ...)))
Where a_0 is an integer, and a_1, a_2, a_3, ... are positive integers (called partial quotients). This can be compactly written as [a_0; a_1, a_2, a_3, ...]. The process to find these a_i values is an iterative algorithm:
a_0 = floor(x)x_1 = 1 / (x - a_0)a_1 = floor(x_1)x_2 = 1 / (x_1 - a_1)a_2 = floor(x_2)...and so on. The process continues until the remainderx_n - a_nis zero (for rational numbers) or indefinitely (for irrational numbers).
Constructing Convergents (Rational Approximations)
The convergents are the rational numbers obtained by truncating the continued fraction at various points. They provide the "best" rational approximations of the original number. We can calculate the numerator (p_n) and denominator (q_n) of the n-th convergent (C_n = p_n / q_n) using the following recursive formulas:
-
Base Cases:
p_{-2} = 0, p_{-1} = 1q_{-2} = 1, q_{-1} = 0
-
Recursive Step: For
n >= 0p_n = a_n * p_{n-1} + p_{n-2}q_n = a_n * q_{n-1} + q_{n-2}
Worked Example: Calculating the Continued Fraction of √2
Let's find the continued fraction expansion and first few convergents for x = √2 (approximately 1.41421356...).
Step 1: Find a_0 and x_1
a_0 = floor(√2) = floor(1.41421...) = 1x_1 = 1 / (√2 - a_0) = 1 / (√2 - 1)To simplifyx_1, multiply the numerator and denominator by the conjugate(√2 + 1):x_1 = 1 / (√2 - 1) * (√2 + 1) / (√2 + 1) = (√2 + 1) / (2 - 1) = √2 + 1So,x_1 = √2 + 1(approximately 2.41421...)
Step 2: Find a_1 and x_2
a_1 = floor(x_1) = floor(√2 + 1) = floor(2.41421...) = 2x_2 = 1 / (x_1 - a_1) = 1 / ((√2 + 1) - 2) = 1 / (√2 - 1)Notice thatx_2is the same asx_1! This means the sequence of partial quotients will repeat from here.
Step 3: Find a_2 and x_3 (and beyond)
a_2 = floor(x_2) = floor(√2 + 1) = 2x_3 = 1 / (x_2 - a_2) = 1 / ((√2 + 1) - 2) = 1 / (√2 - 1) = √2 + 1
The partial quotients are [1; 2, 2, 2, ...]. This is an infinite, periodic continued fraction.
Step 4: Calculate the First Few Convergents for √2
Using the recurrence relations p_n = a_n * p_{n-1} + p_{n-2} and q_n = a_n * q_{n-1} + q_{n-2} with p_{-2}=0, p_{-1}=1, q_{-2}=1, q_{-1}=0:
-
n = 0 (using
a_0 = 1):p_0 = a_0 * p_{-1} + p_{-2} = 1 * 1 + 0 = 1q_0 = a_0 * q_{-1} + q_{-2} = 1 * 0 + 1 = 1C_0 = 1/1 = 1
-
n = 1 (using
a_1 = 2):p_1 = a_1 * p_0 + p_{-1} = 2 * 1 + 1 = 3q_1 = a_1 * q_0 + q_{-1} = 2 * 1 + 0 = 2C_1 = 3/2 = 1.5
-
n = 2 (using
a_2 = 2):p_2 = a_2 * p_1 + p_0 = 2 * 3 + 1 = 7q_2 = a_2 * q_1 + q_0 = 2 * 2 + 1 = 5C_2 = 7/5 = 1.4
-
n = 3 (using
a_3 = 2):p_3 = a_3 * p_2 + p_1 = 2 * 7 + 3 = 17q_3 = a_3 * q_2 + q_1 = 2 * 5 + 2 = 12C_3 = 17/12 ≈ 1.41666...
As you can see, the convergents 1, 1.5, 1.4, 1.41666... quickly approach the value of √2 ≈ 1.41421....
Common Pitfalls
- Rounding Errors: When dealing with irrational numbers, it's crucial to maintain exact fractional forms or algebraic expressions (like
√2 - 1) as long as possible. Rounding too early will lead to inaccurate partial quotients and convergents. - Incorrect Reciprocal Calculation: Ensure you correctly calculate
1 / (x_n - a_n). A common mistake is to miscalculatex_n - a_nor its reciprocal. - Forgetting the Floor Function: The
a_nvalues must always be the integer part ofx_n. Forgetting to apply thefloor()function is a frequent error. - Terminating Too Early: For irrational numbers, the process is infinite. You'll never reach a remainder of zero. Decide on a desired number of partial quotients or precision level beforehand.
When to Use a Continued Fraction Calculator
While understanding the manual process is fundamental, a dedicated continued fraction calculator offers significant advantages for:
- Long Expansions: Calculating many partial quotients and convergents manually becomes tedious and prone to error quickly.
- High Precision: For numbers requiring many decimal places, a calculator can maintain precision that is difficult to achieve by hand.
- Complex Numbers: For numbers involving more intricate algebraic forms, a calculator can handle the computations efficiently.
- Verification: After performing a manual calculation, a calculator can quickly verify your results.
For straightforward cases and to grasp the underlying mechanics, manual calculation is invaluable. For efficiency and accuracy in advanced scenarios, leveraging a calculator is the professional approach.