Rubi SumSimplerAuxQ — recursion over (expanded) sum terms: * - v a sum: every term of v is rational or aux-simpler wrt u * - u a sum: some term of u is aux-simpler wrt v * - both terms: v ≠ 0, same non-numeric factors, and the numeric-factor * ratio nf(u)/nf(v) < −1/2 (or = −1/2 with nf(u) < 0
(u: Expression, v: Expression)
| 517 | function ratParts(e: Expression): [number, number] | null { |
| 518 | if (!isLiteralRational(e)) return null; |
| 519 | const num = e.numerator.re; |
| 520 | const den = e.denominator.re; |
| 521 | if (typeof num !== 'number' || typeof den !== 'number') return null; |
| 522 | return [num, den]; |
| 523 | } |
| 524 | |
| 525 | /** Rubi NumericFactor/NonnumericFactors split of a term: the leading |
| 526 | * rational coefficient and the remaining (non-numeric) factors. */ |
| 527 | function splitNumericFactor(u: Expression): { |
| 528 | coef: number; |
| 529 | rest: Expression; |
| 530 | } { |
| 531 | const ce = u.engine; |
| 532 | const r = ratParts(u); |
| 533 | if (r) return { coef: r[0] / r[1], rest: ce.One }; |
no test coverage detected