mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
* fix(combinatorics): Improve precision of stirlingS2 Previously the computation of stirlingS2 used the closed form, which suffers numerically by dividing a sum of very large terms by a large factorial, causing roundoff errors for unnecessarily small inputs. This commit switches to using the recurrence relation for the stirling numbers of the second kind, and caching the partial results for future calls. This has the advantage that all intermediate results are smaller than the final value. Also adds tests for much larger values of the stirlingS2 function and of bellNumbers, whose computation depends on stirlingS2. Resolves #2508. * fix(stirlingS2): Correct lint errors.