* Walk a Multiply/Power tree and collect factors that contain the variable. * Numeric constants are ignored since they don't contribute variable-containing factors. * Identical factors (by .isSame()) are merged with accumulated multiplicities.
(expr: Expression, variable: string)
| 780 | |
| 781 | if (!coef.isOne) { |
| 782 | lhs.div(coef); |
| 783 | rhs.div(coef); |
| 784 | } |
| 785 | |
| 786 | if (!common.isSame(1)) { |
| 787 | // We have some symbolic factor in common ("x", etc...) |
| 788 | if (common.isPositive) { |
| 789 | lhs.div(common); |
| 790 | rhs.div(common); |
| 791 | } else if (common.isNegative) { |
| 792 | lhs.div(common.neg()); |
| 793 | rhs.div(common.neg()); |
| 794 | flip = !flip; |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | if (flip) [lhs, rhs] = [rhs, lhs]; |
| 799 | |
| 800 | return expr.engine.function(h, [lhs.asExpression(), rhs.asExpression()]); |
| 801 | } |
| 802 | |
| 803 | if (isFunction(expr, 'Negate')) return factor(expr.op1).neg(); |
| 804 |
no test coverage detected