Is there a simple method to (attempt to) rationalize all numeric values in an expression within a given delta, much like Rationalize[] in Mathematica?
An example in Mathematica:
In[25]:= Rationalize[0.5 x^2 - 3.333333 x, 10^-4]
Out[25]= x^2/2-(10 x)/3
I see the nsimplify() function, but that seems like overkill.
I don’t see how
nsimplifyis over kill.nsimplifydoes exactly what you want, because you can pass it a SymPy expression, and it will rationalize the terms in the expression(the tolerance keyword doesn’t seem to work, which I guess is a bug).