From another question I tried to implement something like:

Sum[r^(1 - l[n]) DD[n], {n, Complement[Range[1, Infinity], {4}]}]

but this does not work because Range does not take infinite limits.

Is there another way to exclude a certain numeric value for the index from an infinite sum?

  • $\begingroup$ Sum[r^(1 - l[n]) DD[n], {n, 1, 3}] + Sum[r^(1 - l[n]) DD[n], {n, 5, Infinity}] $\endgroup$ – Bob Hanlon Mar 5 '15 at 18:12
  • $\begingroup$ Well, this is not very practical if I have many excluded values $\endgroup$ – usumdelphini Mar 5 '15 at 18:35

Since you know your exclusions beforehand, you can proceed like this (for any number of exclusions!):

excl={4,9,14}; (* just an example of more than one exclusion! *)
Sum[r^(1-l[n]) DD[n],{n, Select[Range[1, Max@excl],!MemberQ[excl,#]&]}]+
  Sum[r^(1-l[n]) DD[n],{n,Max@excl+1,Infinity}]

This will filter out all your exclusions in one run.

It will also deal with exclusions you make to avoid the summed expression to become invalid at those points.


An straightforward way to put exclusions into sums is by using KroneckerDelta:

excl = {4, 9, 14};
  Times @@ (1 - Thread[KroneckerDelta[n, excl]]) r^(1 - l[n]) DD[n], 
 {n, 1, Infinity}

$$\sum _{n=1}^{\infty } \text{DD}(n) (1-\delta _{4,n}) (1-\delta _{9,n}) (1-\delta _{14,n}) r^{1-l(n)}$$

To show that this also works when the summand would otherwise be undefined, here is an example:

DD[n_] := 1/(n - 9)^2

 Times @@ (1 - Thread[KroneckerDelta[n, excl]])  DD[n], {n, 1, 

(* ==> (1021301 + 117600 Pi^2)/705600 *)

So the divergent term never gets evaluated because the KroneckerDelta sets it to zero first.

  • $\begingroup$ Nice! One drawback, though: It does not deal with the case, that exclusions are made because of the summed expression is not defined at those points. $\endgroup$ – Jinxed Mar 5 '15 at 22:24
  • $\begingroup$ @Jinxed Actually, it does. I'll give an example in my answer. $\endgroup$ – Jens Mar 5 '15 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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