Playing with continued fractions and Khinchin’s constant
Take a real number x and expand it as a continued fraction. Compute the geometric mean of the first n coefficients.
Aleksandr Khinchin proved that for almost all real numbers x, as n a' a the geometric means converge. Not only that, they converge to the same constant, known as Khinchin's constant, 2.685452001". ("Almost all" here mean in the sense of measure theory: the set of real numbers that are exceptions to Khinchin's theorem have measure zero.)
To get an idea how fast this convergence is, let's start by looking at the continued fraction expansion of I. In Sage, we can type
continued_fraction(RealField(100)(pi))
to get the continued fraction coefficient
[3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2, 1, 84, 2, 1, 1, 15, 3]
for I to 100 decimal places. The geometric mean of these coefficients is 2.84777288486, which only matches Khinchin's constant to 1 significant figure.
Let's try choosing random numbers and working with more decimal places.
There may be a more direct way to find geometric means in Sage, but here's a function I wrote. It leaves off any leading zeros that would cause the geometric mean to be zero.
from numpy import exp, mean, logdef geometric_mean(x): return exp( mean([log(k) for k in x if k > 0]) )
Now let's find 10 random numbers to 1,000 decimal places.
for _ in range(10): r = RealField(1000).random_element(0,1) print(geometric_mean(continued_fraction(r)))
This produced
2.661698905352.622806752272.611464636412.585156200642.583966640322.781522976612.559503382052.868788989002.708526124962.52689450535
Three of these agree with Khinchin's constant to two significant figures but the rest agree only to one. Apparently the convergence is very slow.
If we go back to I, this time looking out 10,000 decimal places, we get a little closer:
print(geometric_mean(continued_fraction(RealField(10000)(pi))))
produces 2.67104567579, which differs from Khinchin's constant by about 0.5%.