I want to define a function myLO
that gives me the leading order of a series expansion in Mathematica (the whole term, not just the coefficent).
My idea is, given that any series expansion in Mathematica has de form SeriesData[x, x0, {a0, a1, ...}, nmin, nmax, den]
I can use this structure to construct my function. I did it the following way:
myLO[SeriesData[x_,x0_,coefs_List,nmin_Integer,nmax_Integer,den_Integer]]:=First@coefs Power[(x-x0),nmin/den]
And it works OK, e.g.
serie = Series[ Exp[x-1]/Sqrt[x-1],{x,1,3}]
myLO[serie]
(* 1/Sqrt[-1 + x] *)
But in the definition it gives me an error:
SeriesData::sdatc: "Coefficient specification coefs_List in SeriesData[x_,x0_,coefs_List,nmin_Integer,nmax_Integer,den_Integer] is not a list."
I don't understand this error, I am specifying that the header of lcoefs
must be List
, but the function seems to do not notice it. I can write {a__}
instead, and it won't trigger (but it will complain about the integers), but I want to handle the list as a whole.
How can I avoid this? Or how can I improve this definition?