(roots)
| 65 | // Numeric real parts of a list of boxed roots, keeping only the (near-)real |
| 66 | // ones. A complex root's `.N()` exposes `.im`; we drop |im| above a tolerance. |
| 67 | function realRootValues(roots) { |
| 68 | const out = []; |
| 69 | for (const r of roots ?? []) { |
| 70 | const v = r.N(); |
| 71 | const re = typeof v.re === 'number' ? v.re : Number(v.toString()); |
| 72 | const im = typeof v.im === 'number' ? v.im : 0; |
| 73 | if (Number.isFinite(re) && Math.abs(im) < 1e-7) out.push(re); |
| 74 | } |
| 75 | return out; |
| 76 | } |
| 77 | |
| 78 | // An `evaluate` result is "unevaluated" if it still carries the operator head |
| 79 | // (Limit/Integrate/Sum) or prints one — i.e. no closed form was found. |
no test coverage detected