My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3428: tolerance keyword of nsimplify is ignored
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Jan 2013

Restricted
  • Only users with Commit permission may comment.


Sign in to add a comment
 
Project Member Reported by asmeurer@gmail.com, Oct 8, 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).
Oct 10, 2012
#1 eacousin...@gmail.com
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.
Oct 10, 2012
Project Member #2 asmeurer@gmail.com
So it should be straightforward to fix if you understand what's going on in _real_to_rational. 
Labels: EasyToFix
Jan 10, 2013
#3 prasoon9...@gmail.com
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?
Jan 10, 2013
Project Member #4 asmeurer@gmail.com
That sounds basically correct. 
Jan 21, 2013
Project Member #5 smi...@gmail.com
(No comment was entered for this change.)
Status: Fixed
Jan 21, 2013
Project Member #6 smi...@gmail.com
>>> nsimplify(0.5*x**2 - 3.333333*x, tolerance=0.001, rational=True)
x**2/2 - 10*x/3

Mar 5, 2014
Project Member #7 asmeurer@gmail.com
We have moved issues to GitHub https://github.com/sympy/sympy/issues. 
Labels: Restrict-AddIssueComment-Commit
Apr 6, 2014
Project Member #8 skirpic...@gmail.com
Migrated to http://github.com/sympy/sympy/issues/6527
Sign in to add a comment

Powered by Google Project Hosting