Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world.

Luroth Expansions

```#include <boost/math/tools/luroth_expansion.hpp>
namespace boost::math::tools {

template<typename Real, typename Z = int64_t>
class luroth_expansion {
public:
luroth_expansion(Real x);

std::vector<Z> const & digits() const;

Real digit_geometric_mean() const;

template<typename T, typename Z_>
friend std::ostream& operator<<(std::ostream& out, luroth_expansion<T, Z_>& luroth);
};
}
```

The `luroth_expansion` class provided by Boost expands a floating point number into a Lüroth representation, i.e.,

The numbers di are called digits or denominators; we use the terminology digits, since technically in our notation d0 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<long double>());
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.

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.
 Copyright © 2006-2020 Nikhar Agrawal, Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde, Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle Walker and Xiaogang Zhang 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)