| 536 | return { coef: -inner.coef, rest: inner.rest }; |
| 537 | } |
| 538 | if (u.operator === 'Multiply' && u.ops) { |
| 539 | let coef = 1; |
| 540 | const rest: Expression[] = []; |
| 541 | for (const f of u.ops) { |
| 542 | const fr = ratParts(f); |
| 543 | if (fr) coef *= fr[0] / fr[1]; |
| 544 | else rest.push(f); |
| 545 | } |
| 546 | return { |
| 547 | coef, |
| 548 | rest: |
| 549 | rest.length === 0 |
| 550 | ? ce.One |
| 551 | : rest.length === 1 |
| 552 | ? rest[0] |
| 553 | : ce.function('Multiply', rest), |
| 554 | }; |
| 555 | } |
| 556 | return { coef: 1, rest: u }; |
| 557 | } |
| 558 | |
| 559 | /** Rubi SumSimplerAuxQ — recursion over (expanded) sum terms: |
| 560 | * - v a sum: every term of v is rational or aux-simpler wrt u |