# Does Mathematica have a problem with sums involving Stirling numbers of the second kind?

In one of my calculations, I run the command:

Sum[(StirlingS2[k - 1, 4] + StirlingS2[k, 4])/6^k, {k, Infinity}]


Surprisingly, Mathematica (run on Wolfram Cloud) does not want to perform this very simple summation, returning the definition of the command.

Even more surprisingly, the function starts returning numerical result if the argument of the first StirlingS2 is changed from k - 1 to k, but it processes the summation still incredibly long (it is just a sum of eight geometric series!).

What is the reason for the problem?

• ListPlot[Table[Sum[(StirlingS2[k-1,4]+StirlingS2[k,4])/6^k,{k,2,j}],{j,2,32}]] strongly hints what the sum out to Infinity might be, unless you need some astonishing precision. Whether you start from 1 to j or 2 to j doesn't seem to make any obvious difference. So maybe the algorithm is fast for modest upper bounds and far slower for Infinite bounds. And maybe an infinite summation isn't as simple as you imagine it to be. – Bill Feb 21 at 3:46
• You should avoid using the bugs tag until your issue is confirmed to be a bug by the community. Simply returning the input probably means that Mathematica doesn't know the answer rather than it encountering some kind of bug. – MassDefect Feb 21 at 4:13
• @Bill Possibly I overestimate Mathematica. For me the result $\sum_{n=0}^\infty x^n=\frac1{1-x}$ for $|x|<1$ does not require long computation. Probably Mathematica does not recognize the sum. And the reason for the problem with the lower limit I cannot even guess. – drer Feb 21 at 7:39
• I would appreciate if the downvoters communicate what they don't like in my question so that I could improve it. – drer Feb 21 at 10:04
• Index shifting leads to joy: Sum[(StirlingS2[k, 4] + StirlingS2[k + 1, 4])/6^(k + 1), {k, 0, ∞}] – J. M.'s torpor Feb 22 at 16:17

## 1 Answer

Clear["Global*"]


As you indicated, the problematic term is the one with StirlingS2[k-1, 4]

sum1 = Sum[#, {k, 1, Infinity}] & /@
Expand[(StirlingS2[k - 1, 4] + StirlingS2[k, 4])/6^k] Translate the index,

eqn1 = Inactive[Sum][StirlingS2[k - 1, 4]/6^k, {k, 1, Infinity}] ==
Inactive[Sum][StirlingS2[k, 4]/6^(k + 1), {k, 0, Infinity}] sum2 = eqn1[[-1]] // Activate

(* 1/720 *)


Adding the partial sums,

sum = sum1[] + sum2

(* 7/720 *)


Checking numerically,

NSum[(StirlingS2[k - 1, 4] + StirlingS2[k, 4])/6^k, {k, 1, Infinity}] //
RootApproximant // Quiet

(* 7/720 *)


EDIT: Timing

Clear["Global*"]

$HistoryLength = 0; Sum[StirlingS2[k, 4]/6^k, {k, Infinity}] // RepeatedTiming (* {0.00014183, 1/120} *) Sum[(StirlingS2[k, 4] + StirlingS2[k, 4])/6^k, {k, Infinity}] // RepeatedTiming (* {0.000171701, 1/60} *)  • Do you have an explanation for this behavior? – drer Feb 21 at 10:09 • For whatever reason, Mathematica does not have a pattern rule that matches StirlingS2[k - 1, 4] and it returns unevaluated. Manual intervention is needed to enable it to find a matching pattern. – Bob Hanlon Feb 21 at 17:19 • Can you clarify why the computation of the sum involving two Stirling numbers is several orders of magnitude slower than that involving a single number? – drer Feb 21 at 18:00 • You don't say which two sums you are comparing so I have no way of guessing. If the sum with two Stirling numbers includes one that doesn't evaluate to a closed form, then I would assume that a lot of time is spent unsuccessfully trying transformations in an effort to find a closed form. – Bob Hanlon Feb 21 at 18:10 • I indicated in my question that the "test" was performed after I replaced$k-1$with$k\$ in the first term. So they both were evaluated. And I compared the timing with the sum involving one of the both terms. It was several orders of magnitude faster. – drer Feb 21 at 18:16