Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tolerance keyword of nsimplify is ignored #6527

Closed
asmeurer opened this issue Oct 9, 2012 · 6 comments
Closed

tolerance keyword of nsimplify is ignored #6527

asmeurer opened this issue Oct 9, 2012 · 6 comments
Labels
Bug Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. imported simplify

Comments

@asmeurer
Copy link
Member

asmeurer commented Oct 9, 2012

In [39]: print nsimplify(0.5*x**2 - 3.333333*x, tolerance=0.001, rational=True)
x**2/2 - 3333333*x/1000000

I would have expected a smaller fraction on the x term (no more than 1000 in the denominator).

Original issue for #6527: http://code.google.com/p/sympy/issues/detail?id=3428
Original author: https://code.google.com/u/asmeurer@gmail.com/

@eacousineau
Copy link

I confirm this behavior, running Ubuntu 12.04 amd64, Python 2.7.3.

[ From this discussion: http://stackoverflow.com/a/12792656/170413 ]

I think tolerance isn't used because sympy.simplify.nsimplify() calls sympy.simplify._real_to_rational() if the rational flag is true, but does not pass any tolerance parameters.

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c1
Original author: https://code.google.com/u/108550831992238876765/

@asmeurer
Copy link
Member Author

So it should be straightforward to fix if you understand what's going on in _real_to_rational.

**Labels:** EasyToFix  

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c2
Original author: https://code.google.com/u/asmeurer@gmail.com/

@prasoon2211
Copy link

I think we can modify _real_to_rational to add a tolerance argument to it. Based on that, we can round the real number to given number of digits if the tolerance is provided.
Does that sounds okay? Or is there something else we can do?

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c3
Original author: https://code.google.com/u/102594231986105975028/

@asmeurer
Copy link
Member Author

That sounds basically correct.

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c4
Original author: https://code.google.com/u/asmeurer@gmail.com/

@smichr
Copy link
Member

smichr commented Jan 21, 2013

**Status:** Fixed  

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c5
Original author: https://code.google.com/u/117933771799683895267/

@smichr
Copy link
Member

smichr commented Jan 21, 2013

>>> nsimplify(0.5*x**2 - 3.333333*x, tolerance=0.001, rational=True)
x**2/2 - 10*x/3

Original comment: http://code.google.com/p/sympy/issues/detail?id=3428#c6
Original author: https://code.google.com/u/117933771799683895267/

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Easy to Fix This is a good issue for new contributors. Feel free to work on this if no one else has already. imported simplify
Projects
None yet
Development

No branches or pull requests

5 participants