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

Function isPolynomialForm

src/compute-engine/boxed-expression/factor.ts:136–145  ·  view source on GitHub ↗

* Is `expr` a polynomial (no radicals, and every power has a non-negative * integer exponent)? Used to gate the square-root extraction so it never * introduces `Sqrt`/`Abs`/`Root` or fractional powers — e.g. `√(x³) = x·√x` * is rejected (ROADMAP B4).

(expr: Expression)

Source from the content-addressed store, hash-verified

134 * yields the LCD (product / gcd **is** the LCD), so no separate LCD pass is
135 * needed.
136 *
137 * Used by the `Together` **operator** only. The same-denominator simplify rule
138 * calls `together()` directly and deliberately keeps the unreduced result: it
139 * runs inside the simplify fixpoint, where output stability and cost matter
140 * more than presentation.
141 *
142 * IMPORTANT: does not call `.simplify()` — `cancelCommonFactors` is itself
143 * reachable from simplification rules.
144 */
145export function togetherReduced(op: Expression): Expression {
146 const t = together(op);
147 if (!isFunction(t, 'Divide')) return t;
148

Callers 2

perfectSquareRootFunction · 0.85
extractSquareRootFunction · 0.85

Calls 1

isFunctionFunction · 0.90

Tested by

no test coverage detected