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

Function rewrite

src/compute-engine/boxed-expression/solve.ts:1530–1546  ·  view source on GitHub ↗
(node: Expression)

Source from the content-addressed store, hash-verified

1528 *
1529 * Returns the roots of the resulting sqrt-free equation (to be validated by the
1530 * caller against the original), or `null` when `expr` does not contain exactly
1531 * one distinct x-dependent square root, contains another radical of x, or is not
1532 * a polynomial in that root.
1533 */
1534function solveSingleSqrtEquation(
1535 expr: Expression,
1536 variable: string,
1537 trace?: RuleSteps,
1538 stats?: RootStats
1539): ReadonlyArray<Expression> | null {
1540 const ce = expr.engine;
1541
1542 // Collect the distinct x-dependent radicals. Bail on anything other than a
1543 // single `Sqrt` (a second sqrt is the two-sqrt case; `Root` is unhandled).
1544 const sqrtKeys = new Set<string>();
1545 let sqrtTerm: Expression | undefined;
1546 let radicand: Expression | undefined;
1547 let otherRadical = false;
1548 const scan = (node: Expression): void => {
1549 if (!node.has(variable)) return;

Callers 2

expandLaurentFunction · 0.85

Calls 9

isSymbolFunction · 0.90
isFunctionFunction · 0.90
asSmallIntegerFunction · 0.90
rationalExponentFunction · 0.85
powMethod · 0.65
hasMethod · 0.65
negMethod · 0.65
functionMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected