# Vanishing order of a power series (or polynomial) [duplicate]

Is there a simple and efficient way to compute the vanishing order of a power series, i.e. the degree of its smallest nonzero coefficient?

It seems like this is a basic operation that should be built-in. (Exponent[] computes the largest coefficient.)

Ideally, this would be simple, readable, and work if called on a polynomial instead of a power series.

The best I've come up with so far is

(1+FirstPosition[CoefficientList[#, x], Except[0], 1, 1, Heads -> False])&


Which isn't great. An alternative, which seems ill-advised, is to force conversion to a power series and reach into the SeriesData representation.

(With[{ser = # + O[x]^20}, ser[[4]]/ser[[6]]]) &


Is there a better approach?

• Try using Asymptotic, e.g., Asymptotic[Cos[x]/Sin[2 x]^3, x -> 0] Nov 16, 2021 at 16:34
• For a polynomial one can use Exponent[poly,x,Min] Nov 16, 2021 at 17:05
• @CarlWoll While this is a nice method there is an issue lurking. To wit, it will most likely use Series and apparently this is what the poster wishes to avoid. Nov 16, 2021 at 17:08
• @DanielLichtblau Thanks so much. This is exactly what I was looking for! Nov 16, 2021 at 17:51

I'll quote my answer from this question, which solves your problem on the way to a different one:

The leading-order power in your series should be the limit as $$x \to 0$$ of $$x f'(x)/f(x)$$. So you could do something like

leadcoeff = Limit[x func'[x]/func[x], x->0]

• Thanks! Unfortunately, my power series are complicated. I wouldn't want to compute their derivatives, reciprocals, and then multiply them out, just to compute the vanishing order. Nov 16, 2021 at 14:49
• @user825383860: Could you try it out and let me know how long it takes? I would expect that Mathematica could take the derivative of a power series fairly quickly, and I would be surprised if it doesn't have L'Hopital-like tricks programmed in to find the limits of the ratios of polynomials and/or power series. Nov 16, 2021 at 14:56
• Also, if you want a solution that works well with your particular problem, it would be helpful to include code that generates the particular expressions you're working with. Nov 16, 2021 at 14:57
• I am trying to increase the performance of a power series algorithm by taking vanishing orders into account. This answer is unhelpful. Nov 16, 2021 at 15:21
• @user825383860: With all due respect, it's hard to be helpful without more information about the problem you're trying to solve. I would again encourage you to edit your question to provide more information about what you're trying to do; providing sample code would be ideal. Without that, I suspect the responses you get here will be off the mark like mine apparently is. Nov 16, 2021 at 15:51

Here is a solution that works for a simple example

poly = Sum[a[i] x^i, {i, 3, 11}]
(* x^3 a[3] + x^4 a[4] + x^5 a[5] + x^6 a[6] + x^7 a[7] +
x^8 a[8] + x^9 a[9] + x^10 a[10] + x^11 a[11] *)


The built in Exponent returns the exponent of the highest order in x

Exponent[poly, x]
(* 11 *)


A simple change of variable, can give the lowest order in x

Block[{x = 1/z}, -Exponent[poly, z]]
(* 3 *)