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
nsimplify with tolerance doesn’t work with functions with numerical arguments #15589
Comments
The doc for
I'm not really sure what the rationale for that behaviour is but does match what you see. Your two cases differ because In [17]: (1e-16*f(x)).free_symbols
Out[17]: {x}
In [18]: (1e-16*f(0)).free_symbols
Out[18]: set() Per the doc-string you can get the same effect in the no free symbols case by setting In [19]: nsimplify(1e-16*f(0), tolerance=1e-10, rational=True)
Out[19]: 0 |
Indeed. I read this but misunderstood it (or my brain autocorrected it to something more intuitive). In this case, I would make this a feature request for a more intuitive behaviour. |
What exactly would the feature request be? Does Can you explain what you're using |
The dependence on the presence of free symbols is not what I expected. Thinking about it, I think the idea is that if you have no free symbols, you most likely want the entire expression to be represented by a number, but that does not make sense in the presence of undefined functions.
I am using it to check terms for identity whose composition involves floats and thus floating-point inaccuracies. |
I also wouldn't have expected it to depend on free symbols. I read https://en.wikipedia.org/wiki/Free_variables_and_bound_variables and from there I'm not sure why |
SymPy doesn't consider functions to be symbols for the purposes of free symbols. But the check really should be |
Would you consider making that change to |
This and #14761 are duplicate issues |
Consider the following example:
Only the last assertion fails – which it shouldn’t unless I am completely mistaken.
The text was updated successfully, but these errors were encountered: