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

Function safeSimplify

src/compute-engine/rubi/rubi-utils.ts:425–444  ·  view source on GitHub ↗
(e: Expression)

Source from the content-addressed store, hash-verified

423 q[shift] = q[shift].add(lead);
424 for (let i = 0; i < lc.length; i++)
425 pc[shift + i] = pc[shift + i].sub(lead.mul(lc[i]));
426 pc = trimZeros(pc.slice(0, pc.length - 1));
427 }
428 const X = ce.symbol(x);
429 const toExpr = (cs: Expression[]): Expression => {
430 const terms = cs
431 .map((c, i) => (zeroQ(c) ? null : safeSimplify(c).mul(X.pow(i))))
432 .filter((t): t is Expression => t !== null);
433 if (terms.length === 0) return ce.Zero;
434 if (terms.length === 1) return terms[0];
435 return ce.function('Add', terms);
436 };
437 return [toExpr(q), toExpr(pc)];
438}
439
440// simplify() now respects the engine deadline (ce.timeLimit), so runaway
441// cases (radical-tower polynomial GCD) get interrupted instead of running
442// for minutes. The cap is kept only as a fast-path skip for clearly
443// oversized expressions (raised from the old correctness-trading 120).
444const SIMPLIFY_LEAF_CAP = 500;
445
446// module-level cache hooks, installed per top-level int() call by the
447// driver (see installCaches); fall back to uncached when absent

Callers 15

polyDivideXFunction · 0.85
toExprFunction · 0.85
zeroQFunction · 0.85
rubi-utils.tsFile · 0.85
cmpChainFunction · 0.85
rtExprFunction · 0.85
rtAuxBodyFunction · 0.85
genBinomialPartsXFunction · 0.85
genTrinomialPartsXFunction · 0.85
pseudoBinomialPartsXFunction · 0.85
ltZeroFunction · 0.85
derivativeDividesFunction · 0.85

Calls 7

leafCountFunction · 0.70
toStringMethod · 0.65
getMethod · 0.65
simplifyMethod · 0.65
errorMethod · 0.65
sliceMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected