# Equating coefficients of multivariate polynomials

Here is a simple question, and despite looking at answers to other questions I cannot find how to proceed. I would be extremely grateful for any help.

We have a polynomial Pol in several variables (with rational coefficients, if it helps). Its coefficients involve some parameters. And I would like to find values of these parameter so that Pol is the zero polynomial. Here's some code that does not work but capture what I've tried to do.

var('a0,a1') ; R.<x,y> = QQ[] ; Pol = (a1*x+a0)*(1-x*y)-5*y*x ;


ad then I would like to solve (in the variables a0, a1) the system of coefficients equated to 0:

WA = [SR(Pol).coefficient({x:0,y:0})==0,
SR(Pol).coefficient({x:2,y:1})==0,
SR(Pol).coefficient({x:1,y:1})==0,
SR(Pol).coefficient({x:1,y:0})==0
].solve(SR(a0),SR(a1)); WA

edit retag close merge delete

Sort by » oldest newest most voted

Whe you write :

sage: var('a0,a1') ; R.<x,y> = QQ[] ;
sage: Pol = (a1*x+a0)*(1-x*y)-5*y*x ;


The product a1*x (and the other elementary operations) is done using coercion, that is Sage first searches the common parent between the symbolic ring and the bivariate rational polynomials in x,y. It turns out that it is the symbolic ring itself. Hence, what you get is and element of the symbolic ring:

sage: Pol.parent()
Symbolic Ring


In particular, you lose the polynomial structure in x,y.

The first approach is to let Sage consider a0 and a1 a possible coefficients for polynomials in x,y, by declaring the polynomial ring R to be defined over the symbolic ring SR:

sage: var('a0,a1') ; R.<x,y> = SR[]
(a0, a1)
sage: Pol = (a1*x+a0)*(1-x*y)-5*y*x
sage: Pol
(-a1)*x^2*y + (-a0 - 5)*x*y + a1*x + a0
sage: Pol.parent()
Multivariate Polynomial Ring in x, y over Symbolic Ring


Then you can extract the nonzero coefficients:

sage: Pol.coefficients()
[-a1, -a0 - 5, a1, a0]
sage: solve(Pol.coefficients(),[a0,a1])
[]


There is of course no solution since a0 should be both equal to 0 and -5.

Another approach is to let the coefficients be elements of another polynomial ring S, that will be the ring over which R will be defined:

sage: S.<a0,a1> = QQ[] ; S
Multivariate Polynomial Ring in a0, a1 over Rational Field
sage: R.<x,y> = S[] ; R
Multivariate Polynomial Ring in x, y over Multivariate Polynomial Ring in a0, a1 over Rational Field
sage: Pol = (a1*x+a0)*(1-x*y)-5*y*x
sage: Pol
(-a1)*x^2*y + (-a0 - 5)*x*y + a1*x + a0
sage: Pol.parent()
Multivariate Polynomial Ring in x, y over Multivariate Polynomial Ring in a0, a1 over Rational Field


Now, the common zeroes of the coeficients of Pol (which are polynomials, elements of S), is nothing but the variety of an ideal:

sage: Pol.coefficients()
[-a1, -a0 - 5, a1, a0]
sage: S.ideal(Pol.coefficients())
Ideal (-a1, -a0 - 5, a1, a0) of Multivariate Polynomial Ring in a0, a1 over Rational Field
sage: I = S.ideal(Pol.coefficients())
sage: I.variety()
[]


Which is empty as well.

more

Thank you so much for this detailed answer, this is perfect! (Yes in this simple example there is no solution, my actual application has lots of variables and a higher degree so it would have been clumsy to show here).