Skip to content

Sum of kⁿ·rᵏ/k! over k ≥ a is eʳ times the Touchard polynomial (Dobiński's formula e·Bₙ at r = 1) minus the terms below a, and a polynomial over k! is the sum of its terms - #577

Open
enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:dobinski-sums

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

Sum(k^3/k!, k = 1..∞) is 5e, Sum(k^2·x^k/k!, k = 0..∞) is (x² + x)·eˣ, Sum((k^2 + k)/k!, k = 0..∞) is 3e. Fixes #576

Rules (library/utils.ts):

  • touchardSeries(coeff, ratio, n, a), called from the factorialDen entry of namedSeriesClosedForm when kPower = n ≥ 1 (it returned undefined for any kPower ≠ 0): Σ_{k≥a} c·kⁿ·rᵏ/k! = c·(eʳ·Tₙ(r) − Σ_{k=1}^{a−1} kⁿ·rᵏ/k!), Tₙ(r) = Σⱼ S(n, j)·rʲ with the Stirling numbers of the second kind by their recurrence on bigints. The k = 0 term is 0 for n ≥ 1. At r = 1 it is Dobiński's formula, Tₙ(1) = Bₙ. The sum is entire in r: no guard, and a free r stays symbolic.
  • A polynomial over k! (infiniteSumClosedForm): a body (p₁ + p₂ + …)/k! is the sum of the closed forms of its terms when every term has one (the sum is entire, so the pieces add with no convergence condition). It is tried only for the denominator k!, so no geometric or p-series piece with a guard is added up.
  • Cap: TOUCHARD_LIMIT = 200 for n and for the lower bound a (B₂₀₀ is exact on bigints; the polynomial in a free r has 200 terms). Past it, and for a negative power of k (Σ 1/(k·k!), which involves Ei), undefined, and the sum is what it was.

evaluate() and simplify() give the closed form (the same route); .N() evaluates it at the working precision (13.5914091422952261768, where the summed series gave 13.591409142296198). Sum over an infinite range is not compiled to a closed form: the compiled loop is unchanged.

Wolfram agrees on every value above.

Tests: test/compute-engine/dobinski-sums.test.ts (new): Σ kⁿ/k! for n = 1…7 from k = 0 and k = 1 against the Bell numbers (e, 2e, 5e, 15e, 52e, 203e, 877e); Σ k³/k! under evaluate(), simplify() and .N(); ratios 1, 2, 1/2, lower bounds 0, 1, 2, 3 against the first 40 terms; Σ_{k≥2} k²/k! = 2e − 1; a free x ((x³ + 3x² + x)·eˣ); a coefficient; a polynomial numerator (3e, e); n = 150 exact; Σ 1/(k·k!) stays a sum. No existing test changed; the 190-odd test files that name Sum with Factorial, ∞ or Infinity pass.

Overlap with the open PRs. None.

…ski's formula e·Bₙ at r = 1) minus the terms below a, and a polynomial over k! is the sum of its terms; add regression tests. Fix cortex-js#576
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Sum of kⁿ/k! and kⁿ·rᵏ/k! over an infinite range is unevaluated (Dobiński's formula)

1 participant