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