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

math.simplify reorders operations #933

Closed
LightWarrior opened this issue Aug 25, 2017 · 4 comments
Closed

math.simplify reorders operations #933

LightWarrior opened this issue Aug 25, 2017 · 4 comments

Comments

@LightWarrior
Copy link

LightWarrior commented Aug 25, 2017

math.simplify('x + y + a', [{l: 'n+-c', r: 'n-c'}], {a: -1}).toString()

gives

"x - 1 + y"

The order of operations gets changed. Is it an issue?
Is there any way to just simplify signs ('+-n' => '-n', '--n' => 'n') without node tree getting rearranged so drastically (and get x + y - 1 in my example)?

firepick1 added a commit that referenced this issue Aug 25, 2017
@firepick1
Copy link
Collaborator

firepick1 commented Aug 25, 2017

I have no idea why the legacy simplify does what you saw, but I added your sensible simplification to simplifyCore since it can be done in a single pass. I added a new test that replicated your output and fixed it as suggested. I think the optimization is benign since the precedence of binary + and - are the same--but I'm only 98.1% sure. 😄

4787237
e9fa999

firepick1 added a commit that referenced this issue Aug 25, 2017
@LightWarrior
Copy link
Author

Nice! Thank you!

@firepick1
Copy link
Collaborator

@jos will determine next steps.

@josdejong
Copy link
Owner

This should be fixed now in v3.16.3, thanks @firepick1 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants