CoefficientArrays¶
Returns sparse arrays of polynomial coefficients indexed by total degree.
$ wo 'Normal[CoefficientArrays[3 x^2 y + 2 x - 7, {x, y}]]'
{-7, {2, 0}, {{0, 0}, {0, 0}}, {{{0, 3}, {0, 0}}, {{0, 0}, {0, 0}}}}
Any non-arithmetic expression can serve as a variable: