Glen Whitney 1ca208cd6d
fix(simplify): Collect like factors, and cancel like terms, in sums (#2388)
* fix(simplify): Collect like factors in sums and cancel like terms in sums

  Since polynomials like `x*(2x+x^2)` are usually written out as polynomials
  `2x^2+x^3`, adds rules to be more eager to move factors into sums to
  collect like factors. To complement this, adds a rule extracting
  negative powers from a sum. Together, these accomplish canceling
  a common factor in numerator and denominator:
  (a*k + b*k^2)/k^4 -> k^-4*(a*k + b*k^2) -> a*k^-3 + b*k^-2 -> k^-3*(a + k*b)
  -> (a + k*b)/k^3

  Resolves #1423.

* fix(simplify): Adjust for #2394

* chore: Rebase and mark rules with assumptions

  This commit should update this PR to be fully compatible with the
  current development mainline. Will remove 'WIP'.

* chore(simplify): Additional test cases from PR review

Co-authored-by: Jos de Jong <wjosdejong@gmail.com>
2022-02-28 11:05:07 +01:00
..