Reverse engineer numerical results to fractions of remarkable numbers? Numerical methods output decimal numbers that oftentimes result from the division of two (or more) numbers:


*

*$1.5708... = \frac{\pi}{2}$

*$0.3679... = \frac{1}{e}$

*$0.7071... = \frac{\sqrt2}{2}$

*$0.7501315 ... = \frac{{e}^{\frac{\pi}{12}}}{\sqrt{3}}$ (maybe this one is pushing it a little)


What is a good way to "reverse engineer" a decimal point number to the fraction it might have originated from?
Of course, maintaining a lookup table of values for most commonly encountered decimal numbers and their fractions of "remarkable numbers" is feasible to some extent, but is there a better way?
Side question: what is the proper jargon to succinctly describe this problem?
 A: If you're happy with just a Python library, take a look at the identify() function of mpmath and its documentation.
Its source is available at mpath's identification.py and refers to Ferguson's PSLQ Integer Relation Algorithm (the paper is available online).
A: It's too hard to give a method of reverse engineering decimal notations of all sorts of definable numbers so I will give just a method on how to do so for all rational numbers, with your brain alone not using Python. Given any rational number expressed in decimal notation ending with a line over a string of digits to indicate that that string of digits starts repeating for ever from then on, let's call $m$ the number of digits in the written notation after the decimal point and before the overline and $n$ the number of digits with an overline in the notation. To determine its mixed fraction notation, first you have to recognize that the number is a multiple of $\frac{1}{10^m \times (10^n - 1)}$. Let $p$ be the number the string of digits after the decimal point but before the overline represents and $q$ be the number the string of digits with the overline represents. Then the real part of the given number is $\frac{(p \times (10^n - 1)) + q}{10^m \times (10^n - 1)}$. There's an easy way to compute the greatest common factor of the numerator and denominator of that expression then divide the numerator and denominator by the greatest common factor to reduce it to lowest terms.
