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

Function collectGenerators

src/compute-engine/boxed-expression/solve.ts:1771–1785  ·  view source on GitHub ↗

Collect the distinct candidate generators `g(x)` occurring in `expr`, * innermost (shortest) first — so `ln x` is tried before `√(ln x)`.

(expr: Expression, x: string)

Source from the content-addressed store, hash-verified

1769 * 1. Isolate one sqrt: √(f(x)) = e - √(g(x))
1770 * 2. Square: f(x) = e² - 2e√(g(x)) + g(x)
1771 * 3. Isolate remaining sqrt: f(x) - e² - g(x) = -2e√(g(x))
1772 * 4. Square again: (f(x) - e² - g(x))² = 4e²·g(x)
1773 * 5. Expand: polynomial equation in x
1774 * 6. Solve and validate roots against original equation
1775 *
1776 * Returns solutions for x, or null if pattern not detected.
1777 */
1778function solveTwoSqrtEquation(
1779 expr: Expression,
1780 variable: string,
1781 trace?: RuleSteps,
1782 stats?: RootStats
1783): Expression[] | null {
1784 if (!isFunction(expr, 'Add')) return null;
1785
1786 const ce = expr.engine;
1787 const ops = expr.ops;
1788 if (ops.length < 2) return null;

Callers 1

Calls 3

walkFunction · 0.70
valuesMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected