You could just use CoefficientList
. Here is an example:
poly =
Sum[a[i, j, k] x[1]^i x[2]^j x[3]^k, {i, 0, 2}, {j, 0, 2}, {k, 0, 2}]
(*
==> a[0, 0, 0] + a[1, 0, 0] x[1] + a[2, 0, 0] x[1]^2 +
a[0, 1, 0] x[2] + a[1, 1, 0] x[1] x[2] + a[2, 1, 0] x[1]^2 x[2] +
a[0, 2, 0] x[2]^2 + a[1, 2, 0] x[1] x[2]^2 +
a[2, 2, 0] x[1]^2 x[2]^2 + a[0, 0, 1] x[3] + a[1, 0, 1] x[1] x[3] +
a[2, 0, 1] x[1]^2 x[3] + a[0, 1, 1] x[2] x[3] +
a[1, 1, 1] x[1] x[2] x[3] + a[2, 1, 1] x[1]^2 x[2] x[3] +
a[0, 2, 1] x[2]^2 x[3] + a[1, 2, 1] x[1] x[2]^2 x[3] +
a[2, 2, 1] x[1]^2 x[2]^2 x[3] + a[0, 0, 2] x[3]^2 +
a[1, 0, 2] x[1] x[3]^2 + a[2, 0, 2] x[1]^2 x[3]^2 +
a[0, 1, 2] x[2] x[3]^2 + a[1, 1, 2] x[1] x[2] x[3]^2 +
a[2, 1, 2] x[1]^2 x[2] x[3]^2 + a[0, 2, 2] x[2]^2 x[3]^2 +
a[1, 2, 2] x[1] x[2]^2 x[3]^2 + a[2, 2, 2] x[1]^2 x[2]^2 x[3]^2
*)
Extract[CoefficientList[poly, Array[x, {3}]], {2, 0, 1} + 1]
(* ==> a[2, 0, 1] *)
This shows that the coefficient of the powers $x[1]^2x[3]$ is a[2,0,1]
. In the Extract
command, the powers {2,0,1}
are turned into indices by adding 1
to all of them.
This approach is especially suitable if you want to extract more than one coefficient, because you can construct the CoefficientList
once and store it for future use.
polynom
. $\endgroup$