1 | initial version |
This looks very much like an XY problem. Anyway:
sage: f = -y_0_3^2*y_1_2*y_2_1 + y_0_2*y_1_3*y_2_1^3
sage: R = PolynomialRing(QQ, names=['y_{}_{}'.format(i,j) for i in range(k) for j in range(n)])
sage: [[c] + sum([[SR(R.gen(i))]*e[i] for i in range(R.ngens()) if e[i] != 0], []) for (e,c) in R(f).dict().items()]
[[1, y_0_2, y_1_3, y_2_1, y_2_1, y_2_1], [-1, y_0_3, y_0_3, y_1_2, y_2_1]]