(e: Expression, inv: boolean)
| 1287 | u.ops.filter((o) => o.has(x)).length === 1 && |
| 1288 | u.ops.every((o) => !o.has(x) || monomialQ(o, ctx)) |
| 1289 | ); |
| 1290 | return false; |
| 1291 | } |
| 1292 | |
| 1293 | // Rubi SimplerQ — integer < fraction < complex < everything; ties by |
| 1294 | // magnitude; non-numbers by leaf count. |
| 1295 | function simplerQ(u: Expression, v: Expression): boolean { |
| 1296 | if (isLiteralInteger(u)) { |
| 1297 | if (!isLiteralInteger(v)) return true; |
| 1298 | const a = realNum(u)!; |
| 1299 | const b = realNum(v)!; |
| 1300 | if (a === b) return false; |
| 1301 | if (a === -b) return b < 0; |
| 1302 | return Math.abs(a) < Math.abs(b); |
| 1303 | } |
| 1304 | if (isLiteralInteger(v)) return false; |
| 1305 | const ur = ratParts(u); |
| 1306 | const vr = ratParts(v); |
| 1307 | if (ur) { |
| 1308 | if (!vr) return true; |
| 1309 | if (ur[1] === vr[1]) return Math.abs(ur[0]) < Math.abs(vr[0]); |
| 1310 | return ur[1] < vr[1]; |
| 1311 | } |
| 1312 | if (vr) return false; |
| 1313 | return leafCount(u) < leafCount(v); |
| 1314 | } |
| 1315 | |
| 1316 | function leafCount(e: Expression): number { |
| 1317 | if (!e.ops) return 1; |
| 1318 | return 1 + e.ops.reduce((s, op) => s + leafCount(op), 0); |
no test coverage detected