# Need to take infinite sum of residues, is there a way to choose the order of operations for ReleaseHold?

I'm computing an infinite sum of residues. I want to do something like this:

Sum[Sum[(-1)^n (2 π I) Residue[(w^(I nu + n/2) ws^(I nu - n/2))/(I nu + n/2)^2, {nu, I n/2 + I m}], {n, 1, ∞}], {m, 0, ∞}]


Evaluated like that, this gives zero. However, if I choose a specific value of m, specifically m=0,

Sum[(-1)^n (2 π I) Residue[(w^(I nu + n/2) ws^(I nu - n/2))/(I nu + n/2)^2, {nu, I n/2}], {n, 1, ∞}]


I get a nonzero result. The problem is that for generic m,

Sum[(-1)^n (2 π I) Residue[(w^(I nu + n/2) ws^(I nu - n/2))/(I nu + n/2)^2, {nu, I n/2 + I m }], {n, 1, ∞}]


is zero. It's only nonzero for $m=0$.

I thought that I could make this work by using Hold, holding evaluation of the residue and releasing it outside the infinite sum. But it appears that applying ReleaseHold there doesn't fix the problem, it still evaluates the Residue for the generic case before fitting in the specific ones.

Is there a way to make this work, and get the correct answer out of the infinite sum over m?

(By the way, I know that in this case, all terms besides $m=0$ will be zero. I need the infinite sum because the same setup needs to treat cases where some of those terms are nonzero.)

• I would say it's a bug. Dec 31, 2013 at 8:00
• I don't think it's fair to say it's a bug, Mathematica just has a fixed way it handles order of operations. But there should be a way around it, no?
– Matt
Dec 31, 2013 at 18:37

It seems that Residue (and Series on which it is based) is unable to analyze all the cases in which the formula for the residue might vary. Reduce can do it, within its limitations, if we reduce the system 1/function == 0 && nu == pole.

Here's the OP's example.

fn = (w^(n/2 + I nu) ws^(-(n/2) + I nu))/(n/2 + I nu)^2;


We need to add some conditions on the system. The result has an unnecessary complication of C, but we can deduce that the only cases for which there is a pole is m == 0 && n >= 0:

Reduce[1/fn == 0 && nu == I n/2 + I m &&
m >= 0 && m ∈ Integers && n >= 1 && n ∈ Integers && w != 0 && ws != 0,
{m, n, nu, w, ws}]
(*
C ∈ Integers && w != 0 && ws != 0 && C >= 1 && m == 0 &&
n == C && nu == (I n)/2
*)


Hence we need just one sum:

Block[{m = 0}, Sum[(-1)^n (2 π I) Residue[fn, {nu, I n/2 + I m}], {n, 1, ∞}]]
(*  -((2 (π Log[w] + π Log[ws]))/(1 + ws))  *)


Here's another, albeit similar, example with two special values of m.

fn2 = (w^(n/2 + I nu) ws^(-(n/2) + I nu))/((n/2 + I nu)^2 (2 + n/2 + I nu)^2);

Reduce[1/fn2 == 0 && nu == I n/2 + I m &&
m >= 0 && m ∈ Integers && n >= 1 && n ∈ Integers && w != 0 && ws != 0,
{m, n, nu, w, ws}]
(*
C ∈ Integers && w != 0 && ws != 0 && C >= 1 &&
((m == 0 && n == C && nu == (I n)/2) ||
(m == 2 && n == C && nu == -(1/2) I (-4 - n)))
*)


We can see that there are two cases, m == 0 && n >= 1 and m == 2 && n >= 1.

Block[{m = 0}, Sum[(-1)^n (2 π I) Residue[fn2, {nu, I n/2 + I m}], {n, 1, ∞}]]
Block[{m = 2}, Sum[(-1)^n (2 π I) Residue[fn2, {nu, I n/2 + I 2}], {n, 1, ∞}]]
(*
(π - π Log[w] - π Log[ws])/(2 (1 + ws))
(-π - π Log[w] - π Log[ws])/(2 w^2 ws^2 (1 + ws))
*)


Add these to get the sum over all m >= 0.

If all the use-cases exhibit the same pattern, one could write code to process the results of Reduce and set up the summations.