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

Comments

Projects
None yet
3 participants
@LightWarrior

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

This comment has been minimized.

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

This comment has been minimized.

LightWarrior commented Aug 26, 2017

Nice! Thank you!

@firepick1

This comment has been minimized.

Collaborator

firepick1 commented Aug 26, 2017

@jos will determine next steps.

@josdejong

This comment has been minimized.

Owner

josdejong commented Aug 28, 2017

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

@josdejong josdejong closed this Aug 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment