MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / walk

Function walk

src/compute-engine/rubi/rubi-utils.ts:1289–1315  ·  view source on GitHub ↗
(e: Expression, inv: boolean)

Source from the content-addressed store, hash-verified

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.
1295function 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
1316function leafCount(e: Expression): number {
1317 if (!e.ops) return 1;
1318 return 1 + e.ops.reduce((s, op) => s + leafCount(op), 0);

Callers 3

rtFactorsFunction · 0.70
deactivateTrigFunction · 0.70

Calls 9

polyDegreeXFunction · 0.85
trigArgMonomialExponentFunction · 0.85
fractionalLinearInnerQFunction · 0.85
isSameMethod · 0.65
_fnMethod · 0.65
negMethod · 0.65
mapMethod · 0.65
functionMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected