| 1356 | if (u.symbol === x) return true; |
| 1357 | if (u.operator === 'Power' && u.ops) |
| 1358 | return u.ops[0].symbol === x && !u.ops[1].has(x); |
| 1359 | if (u.operator === 'Multiply' && u.ops) |
| 1360 | return ( |
| 1361 | u.ops.filter((o) => o.has(x)).length === 1 && |
| 1362 | u.ops.every((o) => !o.has(x) || monomialQ(o, ctx)) |
| 1363 | ); |
| 1364 | return false; |
| 1365 | } |
| 1366 | |
| 1367 | // Rubi SimplerQ — integer < fraction < complex < everything; ties by |
| 1368 | // magnitude; non-numbers by leaf count. |
| 1369 | function simplerQ(u: Expression, v: Expression): boolean { |