Last time we talked about 2[1] and demonstrated how to calculate the approximate value of 2. So what if we want to calculate the square root n of any positive integer n?
When calculating 2, there was a key recursive formula:
2=1+1+21
Careful observation will reveal that 2 is divided into an integer part 1 and a fractional part 1+21.
If we represent the square root n of any positive integer n as both an integer and a fractional part[2]:
n=⌊n⌋+{n}
How can we construct such an equation for n and then recursively substitute it to calculate? We can use the difference of squares formula[3] to assist us:
n−⌊n⌋=n+⌊n⌋n−⌊n⌋2=n−⌊n⌋2n+⌊n⌋1(1)
For a specific n, although we do not yet know the approximate value of n, ⌊n⌋ can be determined[4]. Use your preferred method to solve for ⌊n⌋.
Solution
Let's try to solve 19. It is easy to find that ⌊19⌋=4. Substituting into formula (1),
19−4=319+41=34+{19}+41=38+{19}1
Now focus on the denominator part on the right side of the equation. If we want to continue constructing a continued fraction, then consider
Here are brief answers to some of the questions mentioned in the previous article. If there are any inaccuracies, please bear with me.
Why can an equation be substituted into itself? Is this method correct?
Replacing an equation into itself is essentially the definition of recursion.
For other square root numbers, like 3, how can we construct an equation that is similar to the equation for calculating 2?
This article is the answer.
The form of the continued fraction seems similar to the iterative method for finding the greatest common divisor. What is their relationship?
The iterative method for finding the greatest common divisor essentially breaks down two numbers using smaller numbers continuously. In continued fractions, a similar mechanism operates, as shown in formulas (2) and (3).