# Series expansion to lowest non trivial order over a list [duplicate]

I would like to imply Series to a list of experssions in such a way so that it expands each element of the list to the lowest non-trivial order

Example

ld={1/r, (r^2 + 4 y^2)/(4 - 2 M r + r^2)^2, 0, 4 - 4 y^2}


and what I want to do in an easy way is

Normal@{Series[ld[[1]], {r, Infinity, 1}],
Series[ld[[2]], {r, Infinity, 2}],
Series[ld[[3]], {r, Infinity, 0}],
Series[ld[[4]], {r, Infinity, 0}]}


which produces

{1/r, 1/r^2, 0, 4 - 4 y^2}

• See also the elegant method (posted by an incredibly modest user) in Series with a specified number of terms. Aug 9, 2017 at 15:52
• Hahah, I like that answer too. The titles of the questions made me believe they are not related, even though I saw them Aug 10, 2017 at 12:13

Often times it's most straightforward in Mathematica to start by automating exactly what you would do by hand, then see what type of adverse use-cases pop up.

In this case, you could try the lowest order and work up. Series expand to the $n$-th order with $n=0$. See if it worked and, if not, increasing n++ until you get somewhere.

Something like this:

    firstNTSeries[expr_, {var_, var0_}] := Module[{n = 0, res},
res =expr;
While[expr =!= 0 &&
Normal[res = Series[expr, {var, var0, n}]] === 0,
n++];
res // Normal]


Usage:

    firstNTSeries[#, {r, \[Infinity]}] & /@ ld


If you're getting bogged down by speed, (consider above applied to $(r^{10^{13}}+r^{10^{14}})^{-1}$), you can optimize at the cost of trusting Series' ability to guess the first nontrivial step. I.e. use the output of Series to change how fast you should be advancing $n$. Something like:

    firstNTSeriesV2[expr_, {var_, var0_}] :=
Module[{n = 0, res},
res = expr;
While[expr =!= 0 &&
Normal[res = Series[expr, {var, var0, n}]] === 0,
n = res[[5]];
];
res // Normal
]

• Thank you very much, I was thinking of doing something like that, but with If checks and it looked too cumbersome Aug 9, 2017 at 10:53

ld = {1/r, (r^2 + 4 y^2)/(4 - 2 M r + r^2)^2, 0, 4 - 4 y^2};

{1/r, 1/r^2, 0, 4 - 4 y^2}
powerlist = Map[Exponent[RootReduce[#], r] &, ld] /.{ -\[Infinity] -> 0,, _?Negative -> 1}