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

Function complexAt

scripts/rubi/benchmark.ts:133–157  ·  view source on GitHub ↗
(
  expr: BoxedExpression,
  x: string,
  value: number | C
)

Source from the content-addressed store, hash-verified

131}
132
133type C = { re: number; im: number };
134
135function complexAt(
136 expr: BoxedExpression,
137 x: string,
138 value: number | C
139): C | null {
140 const xv =
141 typeof value === 'number' ? value : expr.engine.number(value);
142 // Each point runs inside a `withTimeLimit` span and throws
143 // CancellationError when a single evaluation runs too long (a slow
144 // ₂F₁/Appell point); treat that as an unusable point (null), not a harness
145 // error. The span is required: the engine has no ambient time limit (the
146 // `ce.timeLimit` property was retired), so an unwrapped N() is unbounded.
147 let v: BoxedExpression;
148 try {
149 v = expr.engine.withTimeLimit(
150 { ms: POINT_TIME_LIMIT_MS, label: 'rubi:benchmark:point' },
151 () => expr.subs({ [x]: xv as any }).N()
152 );
153 } catch (e) {
154 if (e instanceof Error && e.constructor.name === 'CancellationError')
155 return null;
156 throw e;
157 }
158 if (!isNumber(v)) return null;
159 const re = v.re;
160 const im = v.im;

Callers 3

atFunction · 0.85
checkPointFunction · 0.85
runProblemFunction · 0.85

Calls 5

isNumberFunction · 0.90
numberMethod · 0.65
NMethod · 0.65
subsMethod · 0.65
isFiniteMethod · 0.45

Tested by

no test coverage detected