1

I have a multivariate polynomial in sympy and I'd like to get a list of all the coefficients with the exponent tuples, i.e., for

import sympy

X = [sympy.Symbol(f"x{k}") for k in range(4)]
p = sympy.poly(5 * X[0] ** 2 * X[3] - 2 * X[1] ** 4, X)

# p.all_coeffs()  # not possible

I'd want

[(5, (2, 0, 0, 1)), (-2, (0, 4, 0, 0))]

Any hint on how to achieve this?

Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
  • 2
    [best-way-to-isolate-one-coefficient-of-a-multivariate-polynomial-in-sympy](https://stackoverflow.com/questions/36818025/best-way-to-isolate-one-coefficient-of-a-multivariate-polynomial-in-sympy) – JohanC May 26 '20 at 12:32
  • @JohanC Thanks, that's it! I'm voting to close as dup. – Nico Schlömer May 26 '20 at 12:34
  • Some explicit examples to give the form like you requested is added to that duplicate answers. – smichr May 26 '20 at 14:13

0 Answers0