# Truncate a sum in a 'smart' way

Consider a series like this:

$$\sum_{n=1}^{\infty} (c_n r^{2-n/2}+d_n r^{-n/2})$$

Sum[c[n]r^(2-n/2)+d[n]r^(-n/2),{n,Infinity}]


I want, now, to keep only the terms for which the power of $r$ is negative, i.e., the non diverging terms for $r\rightarrow\infty$, and send to zero all the c[n] and d[n] which correspond to a positive power of $r$.

After this, I would like to keep all the terms of the general sum that go to zero more slowly than $r^{2}$, e.g.the terms with $r^{-1}$, $r^{-1/2}$, with their respective coefficients. Notice that this can come from different $n$, so it is not enough in general to truncate the series.

How can I do this using Series? I can't manage it.

• Like Sum[If[2 - n/2 >= 0, 0, c[n] r^(2 - n/2)] + d[n] r^(-n/2), {n, Infinity}]? – Dr. belisarius Mar 5 '15 at 17:42
• @belisarius This is not practical when I have many different expressions as exponents. In the question I used a toy sum, but in general I would need to impose many more conditions on that If – usumdelphini Mar 5 '15 at 17:47

You can use Piecewise to filter out any components you do not desire:

(* your exclusion conditions *)
conds={2-n/2<0, (* possibly more *) };

filter[c_]:=Piecewise[{{1,And@@c}},0]


and then

Sum[filter[conds] c[n]r^(2-n/2) + filter[conds] d[n]r^(-n/2),{n,Infinity}]


This can easily be expanded for any conditions you might encounter.

• It is a little but uncomfortable because it does not seem to work on the whole series. I mean, unless I multiply filter[cond] individually in front of each term that can give problems, it does not work. – usumdelphini Mar 5 '15 at 21:24
• If for example I have Sum[c[n] r^(1-n/2)+d[n] r^(n/2-1),{n,Infinity}] this will give zero – usumdelphini Mar 5 '15 at 21:26
• @usumdelphini: Sure you will have to filter all your expressions within the sum. I updated the answer accordingly. Were it not for an infinite sum, this would be totally different story. – Jinxed Mar 5 '15 at 22:41