When I try to define this simple function
getCoeff[SeriesData[_, _, coeff_, _, _, _]] := coeff[[2]]
I get an error:
SeriesData: Coefficient specification coeff_ in SeriesData[_,_,coeff_,_,_,_] is not a list.
Can someone explain what's wrong with this? My understanding was that SetDelayed shouldn't complain about such things because until I actually evaluate an expression containing getCoeff it shouldn't try to evaluate Part[coeff,2].
There is no error thrown for the similar function
f[g[_, _, x_, _, _, _]] := x[[2]]
and furthermore getCoeff works as expected:
getCoeff@Series[E^(\[Pi] x), {x, 0, 3}]
outputs $\pi$.
I know the "right" way to manipulate SeriesData, I'd just like to understand this case for its own sake.
getCoeff[Unevaluated[SeriesData[_, _, coeff_, _, _, _]]] := coeff[[2]];ThengetCoeff@Series[E^(\[Pi] x), {x, 0, 3}] = \[Pi]. – Shredderroy Sep 21 '19 at 21:10