group the structural sum terms of u into (exponent → summed coefficient) * classes; null when some term is not a structural monomial in x
( u: Expression, x: string )
| 1596 | const ops = u.ops; |
| 1597 | if (!ops) return null; |
| 1598 | switch (u.operator) { |
| 1599 | case 'Power': { |
| 1600 | if (ops[1].has(x)) return null; |
| 1601 | if (ops[0].symbol === x) return { coef: ce.One, exp: ops[1] }; |
| 1602 | const k = realNum(ops[1]); |
| 1603 | if (k !== null && Number.isInteger(k)) { |
| 1604 | const m = monoPartsX(ops[0], x); |
| 1605 | if (m !== null) |
| 1606 | return { |
| 1607 | coef: m.coef.pow(k).evaluate(), |
| 1608 | exp: m.exp.mul(k).evaluate(), |
| 1609 | }; |
| 1610 | } |
| 1611 | return null; |
| 1612 | } |
| 1613 | case 'Sqrt': |
| 1614 | if (ops[0].symbol === x) |
| 1615 | return { coef: ce.One, exp: ce.expr(['Rational', 1, 2]) }; |
| 1616 | return null; |
no test coverage detected