I’ve observed a puzzling behaviour of `Coefficient[]`

for negative exponents and I’m wondering if I was always just relying on undefined behaviour or if there is a bug in recent versions of Mathematica.

So far, if I had an expression of the form

`expr = a/x + b/(1+x) + c `

and ran

`Coefficient[expr,x,-1] `

I’ve always gotten

`a `

as the answer, which made a lot of sense to me. I’ve tried this with a number of different versions of Mathematica (all on Linux if that matters) that I had access to and the behaviour described above is true for 8.0.0, 8.0.1, 8.0.4, 9.0.0, 9.0.1, 10.0.0, 10.0.1, 10.4.0, 10.4.1, 11.0.0 and 11.0.1.

With 11.1.0, 11.1.1, 11.3.0 and 12.0.0 I got the answer

`a + b/(1+x) `

which I find a bit weird, but maybe I can come up with a rationale behind this.

Finally, with 12.1.1 I get

`a/(1+x) + b/(1+x) + c/(1+x) `

which makes absolutely no sense at all to me.

My question is: Is this a bug in the newer versions of Mathematica or was the answer of 8.0.0 to 11.0.1 always just undefined behaviour? And is there a workaround, which would allow me to extract the coefficient `a`

from expressions like the one above (i.e. after partial fractioning a rational function, take only the term that is multiplied by `x^k`

with `k`

a negative integer)? If this is indeed undefined behaviour, shouldn’t Mathematica issue a warning or something like that in this case?