-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(simplify): Improve collection of nonconstant like terms (#2384)
The key is that the rule-matching engine is optimized for finding matches on the lefts of terms, but the central term-collection rule `n1*n3 + n2*n3 -> (n1+n2)*n3` was written with the key common term rightmost. Reversing this rule to `n3*n1 + n3*n2 -> n3*(n1+n2)` therefore does most of the work of improving like-term collection. It also better corresponds to typical mathematical presentation: common terms tend to be pulled out to the left in common practice. Floating constants to the right of a product initially (before they are moved back to the left for human-preferred output) and ensuring that negations are subsumed into constants whenever possible did the rest. Also, rule context was not being propagated into the simplification engine; this commit corrects that. Resolves #1179. Resolves #1290. Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
- Loading branch information
Showing
2 changed files
with
22 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters