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

Function buildCore

benchmarks/runners/run_wolfram_batch.mjs:62–85  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

60// per-call cost includes the WL parse — parity with the SymPy runners, which
61// re-`sympify` their source each call.
62function buildCore(t) {
63 const e = t.expr, e2 = t.expr2, v = t.var || 'x';
64 const realAsm = spec.real ? `Element[${v}, Reals]` : '';
65 const asmSimplify = realAsm ? `, ${realAsm}` : '';
66 const asmInt = realAsm ? `, Assumptions -> ${realAsm}` : '';
67 switch (t.op) {
68 case 'factor': return `Factor[${e}]`;
69 case 'expand': return `Expand[${e}]`;
70 case 'expandconst': return `Expand[${e}]`; // constant expansion, graded by mantissa/exponent
71 case 'simplify': return `FullSimplify[${e}${asmSimplify}]`;
72 case 'gcd': return `PolynomialGCD[${e}, ${e2}]`;
73 case 'resultant': return `Resultant[${e}, ${e2}, ${v}]`;
74 case 'integrate': return `Integrate[${e}, ${v}${asmInt}]`;
75 case 'defint': return `Integrate[${e}, {${v}, ${t.a}, ${t.b}}${asmInt}]`;
76 // `D` takes no Assumptions, so a non-holomorphic derivative like d/dx|x| stays
77 // an unevaluated `Abs'[x]` that won't numericize. Under a real variable,
78 // ComplexExpand resolves it (→ Sqrt[x^2]/x = Sign[x]) and leaves ordinary
79 // derivatives untouched — the parity of SymPy's `symbols(var, real=True)`.
80 case 'diff': return spec.real ? `ComplexExpand[D[${e}, ${v}]]` : `D[${e}, ${v}]`;
81 case 'limit': return `Limit[${e}, ${v} -> ${t.point}${asmInt}]`;
82 case 'solve': return `Solve[${e} == 0, ${v}]`;
83 default: return null;
84 }
85}
86
87// Split tasks into runnable (valid op) and ones we reject up front.
88const wlTasks = [];

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected