@neauoire A few years ago I came up with a neat algorithm for this for a floating-point number, including support for expressions with square roots and multiples of pi. It works by trying to deduce a repeated fraction for the number (similar to how the golden ratio is constructed). The code is here: https://gist.github.com/nakst/f8a70fd69724b8a239138c3f03dd1b75 I looked around the internet for a while to see if anyone had described this algorithm, but I couldn't find anything :(
@nakst thanks :)