1

I would like to get the coefficients of a multivariate polynomial including the zero coefficients (in their correct positions). I have found a similar answer as regards a polynomial f of two variables x,y

Now, I would like to extend this solution for a multivariate polynomial of n variables [xo,x1,...xn-1] The polynomial is defined with the following code: (Note: q=next_prime(10000))

A1 = [(', '.join('x%i'%i for i in [0.. n-1]))]; ### construct a suitable multivariate ring
        V = var(A1[0])                               ### define a str variable
        x=vector(list(V)) ### convert to vector                                                                            
        P1=PolynomialRing(GF(q),V)

How can I do that?

Community
  • 1
  • 1

1 Answers1

3

As a start, given a polynomial g, you can do P1.monomial_all_divisors(lcm(g.monomials())) to get a list of the relevant monomials. You may want to sort that list – I can't tell what order it is in by default – but then you can do this:

sage: P1.<x0, x1, x2> = PolynomialRing(GF(7)) # my simple setup
sage: g = 3*x0*x1 - x1^2 + 2*x1*x2

sage: [(m, g.monomial_coefficient(m)) for m in P1.monomial_all_divisors(lcm(g.monomials()))]
[(x0, 0),
 (x1, 0),
 (x0*x1, 3),
 (x1^2, 6),
 (x0*x1^2, 0),
 (x2, 0),
 (x0*x2, 0),
 (x1*x2, 2),
 (x0*x1*x2, 0),
 (x1^2*x2, 0),
 (x0*x1^2*x2, 0)]
John Palmieri
  • 1,531
  • 8
  • 13