2

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?

usumdelphini
  • 996
  • 4
  • 14

2 Answers2

3

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

excl = {4, 9, 14};
Sum[
  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

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

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

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

Jens
  • 97,245
  • 7
  • 213
  • 499
  • 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. – Jinxed Mar 05 '15 at 22:24
  • @Jinxed Actually, it does. I'll give an example in my answer. – Jens Mar 05 '15 at 22:49
1

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.

Jinxed
  • 3,753
  • 10
  • 24