# Evaluating a summation while suppressing zero raised to a negative power

I want to compute the following multiple summation.

m=1;
n=1;

output =
Sum[
Sum[
Sum[
Sum[
Sum[
(m-l)!/(k-l+l1)! c^(k+l1-l) a^(m-k-l1) b^l1 (l)!/(l-k+x1)! f^(l-k+x1) d^(k-x1) 1/(i-x1)! g^(i-x1) e^x1,
{i,0,n-l}],
{x1,0,k}],
{l1,0,m-k}],
{l,0,m}],
{k,0,m}]

(*a + b c + d + c e + b f + a g + b c g *)


Now declaring the value of $$b,c,e,f,g$$,

b=0;
c=0;
e=0;
f=0;
g=0;


the output becomes $$a+d$$. However, I want to evaluate the summation after declaring the value of $$b,c,e,f,g$$ which results in showing error due to quantities like $$0^{-1}$$ appear in the summand.

I want to see if mathematica can simplify the summation in form of known special function under the condition $$b=c=e=f=g=0$$ for general $$m, n$$.

• You can just use one Sum and then include all iteration variable definitions in a series making this better to read. – gwr Jan 21 at 7:22

Use Block. Like so:

m = 1;
n = 1;

b = 0;
c = 0;
e = 0;
f = 0;
g = 0;

output =
Block[{a, b, c, d, e, f, g},
Sum[
Sum[
Sum[
Sum[
Sum[
(m - l)!/(k - l + l1)! c^(k + l1 - l) a^(m - k - l1) b^l1 (l)!/(l - k + x1)! f^(l - k + x1) d^(k - x1) 1/(i - x1)! g^(i - x1) e^x1,
{i, 0, n - l}],
{x1, 0, k}],
{l1, 0, m - k}],
{l, 0, m}],
{k, 0, m}]]


a + d

The natural way to work with formulas (symbolic) and values (numeric) is to use rules:

m = 1;
n = 1;
parameters = {b, c, e, f, g};
parameterValues = Thread[ parameters -> ConstantArray[0, Length @ parameters] ];

term = Sum[
(m - l)!/(k - l + l1)! c^(k + l1 - l) a^(m - k - l1) b^l1 (l)!/(l - k + x1)!
f^(l - k + x1) d^(k - x1) 1/(i - x1)! g^(i - x1) e^x1,
(* sequence of summation: i - x1 - l1 - l - k *)
{k, 0, m},
{l, 0, m},
{l1, 0, m - k},
{x1, 0, k},
{i, 0, n - l}
];

term /. parameterValues


a + d