Recognizing numbers

Python’s sympy has a function called nsimplify that can do this:

>>> from sympy import *
>>> nsimplify(4.242640687119286)
3*sqrt(2)
>>> nsimplify(pi, tolerance=1e-7)
exp(141/895 + sqrt(780631)/895)

It finds closed form approximations to numbers. This looks like a lot of fun (and is potentially useful).
Original source: Recognizing numbers with SymPy nsimplify

So, can Mathematica do this?

Cheers,
Mike

Built in function

RootApproximant[4.242640687119286]
Out = 3*Sqrt[2]

works, and so does the Wolfram|Alpha query with quite a few results:

http://www.wolframalpha.com/input/?i=4.242640687119286

Recent post at Wolfram Blog From Close to Perfect—A Triangle Problem just discussed this very issue.

Hope that helps.

Very nice. Thank you.

BTW the same function was used to recover some of the Ramanujan lost equations, as discussed in this latest Wolfram Blog**: After 100 Years, Ramanujan Gap Filled** . Below is the image from his “lost notebook” showing some incomplete equations. Click on the link or the image to read the full blog.

Hello Mike,

One of the very first posts on Mathematica.SE was on a similar topic:

http://mathematica.stackexchange.com/questions/16/can-mathematica-propose-an-exact-value-based-on-an-approximate-one

Be sure to look at all answers (not just highly voted ones), and follow the links. I asked a similar question on MathGroup a few years ago which also has interesting answers:

https://groups.google.com/d/msg/comp.soft-sys.math.mathematica/vq-MBdu51RI/lvNoiwHUPv8J

It was inspired by Maple’s identify() function.

Thanks for the replies everyone :slight_smile: