| 274 | if (r.property !== 'Poles') continue; |
| 275 | if (r.assumptions != null || r.condition != null) continue; |
| 276 | if (r.value == null || r.argIndex == null) continue; |
| 277 | // A record describes one arity of the operator (`["Gamma", "z"]`); it |
| 278 | // says nothing about another arity with the same name. The incomplete |
| 279 | // gamma function Γ(s, x) is entire in s for x ≠ 0, so the poles of |
| 280 | // Γ(s) at s = 0, −1, −2, … are not poles of Γ(s, x). |
| 281 | if (Array.isArray(r.expr) && r.expr.length - 1 !== ops.length) continue; |
| 282 | const arg = ops[r.argIndex]; |
| 283 | if (arg !== undefined && isOnPoleSet(ce, arg, r.value)) return true; |
| 284 | } |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Pole-aware numeric evaluation. When `operator(ops...)` is evaluated |
| 290 | * numerically and an operand lands on a known pole, the value is |
| 291 | * `ComplexInfinity`. Only a result the kernel could not resolve (NaN or |
| 292 | * still-symbolic) is overridden — a kernel that already returns a finite value |
| 293 | * or a directed/complex infinity is kept untouched (so e.g. `Gamma`'s `~oo` |
| 294 | * and `Zeta(1)`'s `+oo` are preserved, while `Digamma(-2).N()`'s NaN becomes |
| 295 | * `~oo`). Called by `BoxedFunction._computeValue` under `numericApproximation`. |
| 296 | */ |
| 297 | export function applyPoleOverride( |
| 298 | ce: IComputeEngine, |
| 299 | operator: string, |
| 300 | ops: ReadonlyArray<Expression>, |
| 301 | result: Expression |
| 302 | ): Expression { |
| 303 | if (!POLE_OPERATORS.has(operator)) return result; |
| 304 | const needsOverride = |