# Element-wise SeriesCoefficient for matrix [duplicate]

I have a matrix expression which, when expanding with the Series[] command, returns

$$\left( \begin{array}{cc} 1-\frac{1}{2}t^2+\frac{1}{8}t^4-O[t^5] & t-\frac{1}{4}t^3+O[t^5] \\ -t+\frac{1}{4}t^3+O[t^5] & 1-\frac{1}{2}t^2+\frac{1}{8}t^4-O[t^5] \end{array} \right)$$

I would like to use the SeriesCoefficient[] command on this matrix to return the element-wise series coefficients in matrix form - i.e.:

$$n=0~\rightarrow~ \left(\begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array}\right)$$

$$n=1~\rightarrow~ \left(\begin{array}{cc} 0 & 1 \\ -1 & 0 \end{array}\right)$$

$$n=2~\rightarrow~ \left(\begin{array}{cc} -\frac{1}{2} & 0 \\ 0 & -\frac{1}{2} \end{array}\right)$$

and so on. How would I do this? Simply running SeriesCoefficient[Matrix[t],n] doesn't give me anything.

• Try this: Table[1/n! D[Series[mat, {t, 0, 4}] // Normal, {t, n}] /. t -> 0, {n, 0, 4}]. (I know this is a duplicate of a recent question. Let me see if I can find it.) Commented Jul 26, 2016 at 15:33
• @march, don't forget to scale by the factorial. ;) Commented Jul 26, 2016 at 15:33
• @J.M. Right you are! (I'm going to find that duplicate, in any case.) Commented Jul 26, 2016 at 15:34
• A related question. Commented Jul 26, 2016 at 15:35
• @J.M. While that wasn't the one I was thinking of, that is certainly a good candidate for marked-as-duplicate. It even has the answer by Jens that I quoted here (I have seen Jens use it before, and I learned it from them anyway). Commented Jul 26, 2016 at 15:40

Seems easy enough:

m = {
{ 1 - 1/2 t^2 + 1/8 t^4 - O[t]^5, t - 1/4 t^3 + O[t]^5           },
{ -t + 1/4 t^3 + O[t]^5,          1 - 1/2 t^2 + 1/8 t^4 - O[t]^5 }
};

Table[
n -> Map[SeriesCoefficient[#, n] &, m, {2}],
{n, 0, 2}
]

{0 -> {{1, 0}, {0, 1}}, 1 -> {{0, 1}, {-1, 0}}, 2 -> {{-(1/2), 0}, {0, -(1/2)}}}


More playfully:

Map[Thread @ SeriesCoefficient[#, {0, 1, 2}] &, m, {2}] ~Transpose~ {3, 2, 1}

• SeriesCoefficient[m, {t, 0, 3}] works directly in M9+, no need to use Map. Commented Jun 1, 2017 at 1:06
• @CarlWoll Thank you. Commented Jun 1, 2017 at 1:14