divergent part of a series

I am trying to find a function that gives me the divergent part of series in any case.

The method "Series[]" does not work because Series[42,{n,0,-1}] gives as result 42 (which is not divergent in n)

The method "SeriesCoefficient[]" does not work because I do not know the lowest order, so that SeriesCoefficient[1/n^2 + 1/n + 2 + n^2,{n,0,-1}]only gives 1 (from the 1/n-term) but I loose information about the 1/n^2 term.

-
Can it be that you are looking for Residue? – Alexei Boulbitch Jun 3 '14 at 9:16
Not exactly ... for example: 1/n^2 + 2/n + 1 + n should give back 1/n^2 + 2/n but Residue of that function gives 1. – user14728 Jun 3 '14 at 11:46
This might or might not be reliable: singularPart[f_, x_, p_: 0] := Expand[Normal[Series[(x - p)*f, {x, p, 1}] + O[x - p]]/(x - p)] – Daniel Lichtblau Jun 3 '14 at 15:42
Any help?: (1) Series[expr, {n, 0, -1}] /. {s_SeriesData :> s, _ -> 0} or (2) #2 - (Normal[#] /. n -> Infinity) &[Series[expr, {n, 0, 0}], Series[expr, {n, 0, -1}]]. I don't know what you would want for functions like Sin[1/n]. – Michael E2 Nov 1 '14 at 21:35

You might do as follows:

    singPart[f_] :=
Plus @@ ({Coefficient[f, n, #], #} & /@
Range[-Exponent[f, 1/n], -1] /. {x_, y_} -> x*n^y);


Then if

f = a*n^2 + b*n + e/n^2 + c/n + d + g/n^4;

singPart[f]


returns

(*    g/n^4 + e/n^2 + c/n      *)


Edit: the above function works incorrectly in the case of numeric coefficients. The one below should work in the both cases:

    sing[f_] := Module[{g, lst, cond},
g[{x_, y_}] := x*n^y;
lst[z_] := {Coefficient[z, n, #], #} & /@
Range[-Exponent[z, 1/n], -1];
cond = And @@ (Map[NumberQ, lst[f], {2}] // Flatten);
Plus @@ Map[g, If[cond, Select[lst[f], #[[1]] != 0 &], lst[f]]]
]

-
Thanks for your answer, but - for exapmle - singPart[1/n^2] returns 1 - 2/n – user14728 Jun 3 '14 at 13:35