2
$\begingroup$

I am currently completing a project which involves various numerical sums, and I am trying to use Mathematica to evaluate them and obtain simple analytic results. For example, one such sum is $$f_{(s,k)}=\sum_{l=0}^s(-1)^l\binom{s}{l}^2(s+k-l)!(s-k+l)!$$ for positive integers $s$ and $k$ satisfying $s\geq k$. When I enter the following code into Mathematica

FullSimplify[Sum[(-1)^l (Binomial[s, l])^2*(s + k - l)!*(s + l - k)!, {l, 0, s}], {Element[s, Integers], Element[k, Integers], s >= k}]

it either outputs some ridiculously complicated difference equation, or throws a "Expression Csc[k\ [Pi]] simplified to ComplexInfinity" error. However, I know (or rather suspect, from trialing different values of $s$ and $k$ and making an ansatz) that the analytic result for the above sum is actually $$f_{(s,k)}= (-1)^{s+k}s!s!~,$$ which is very simple.

This happens every time when I try to compute similar kinds of sums. Is there a way to alter the above code to make Mathematica spit out this simple analytical result? Or perhaps Mathematica is not the best program for doing such sums, and there is another program that is better suited?

$\endgroup$
1
  • $\begingroup$ Maybe a Maple ? $\endgroup$ Commented Dec 2, 2022 at 16:10

1 Answer 1

7
$\begingroup$
$Version

(* "13.1.0 for Mac OS X x86 (64-bit) (June 16, 2022)" *)

Clear["Global`*"]

f[s_, k_] := 
 Sum[(-1)^l (Binomial[s, l])^2*(s + k - l)!*(s + l - k)!, {l, 0, s}] /; 
  s >= k

Use FindSequenceFunction

f2[s_, k_] = FindSequenceFunction[
   FunctionExpand[
      FindSequenceFunction[#, s]] & /@
    Table[{s, f[s, k]}, {k, 1, 6}, {s, k, 12}],
   k] /. Gamma[x_] :> (x - 1)!

(* (-1)^(k + s) (s!)^2 *)

Check,

And @@ Table[And @@ Table[f[s, k] == f2[s, k], {s, k, 20}], {k, 1, 20}]

(* True *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.