[/ Copyright Nick Thompson, 2020 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). ] [section:luroth_expansion Luroth Expansions] #include namespace boost::math::tools { template class luroth_expansion { public: luroth_expansion(Real x); std::vector const & digits() const; Real digit_geometric_mean() const; template friend std::ostream& operator<<(std::ostream& out, luroth_expansion& luroth); }; } The `luroth_expansion` class provided by Boost expands a floating point number into a Lüroth representation, i.e., [$../equations/luroth_expansion.svg] The numbers /d/[sub i] are called digits or denominators; we use the terminology digits, since technically in our notation /d/[sub 0] is not a denominator. Here's a minimal working example: using boost::math::constants::pi; using boost::math::tools::luroth_expansion; auto luroth = luroth_expansion(pi()); std::cout << "π ≈ " << luroth << "\n"; // Prints: // π ≈ ((3; 7, 1, 1, 1, 2, 1, 4, 23, 4, 1, 1, 1, 1, 80, 1, 1, 5)) The class computes denominators while simultaneously computing convergents. Once a convergent is within a few ulps of the input value, the computation stops. /Nota bene:/ There is an alternative definition of the Lüroth representation where every digit is shifted by 1. We follow the definition given in Kalpazidou; with the modification that we do not constrain the input to be in the interval [0,1] and let the first digit be the floor of the input. For almost all real numbers, the geometric mean of the digits converges to a constant which is approximately 2.2001610580. This is "Khinchin's constant" for the Lüroth representation. [heading References] * Kalpazidou, Sofia. "Khintchine's constant for Lüroth representation." Journal of Number Theory 29.2 (1988): 196-205. * Finch, Steven R. Mathematical constants. Cambridge university press, 2003. [endsect]