# Constraints on polynomial coefficients

Given a polynomial P=(X-a)(X-b)(X-c) over Q[a,b,c][X] , how can I force the coefficients to fullfill constraints such as elementary symetric function a+b+c=0 or abc=2, some polynomial constraint on coefficients.

It is a bit like using coefficients on a number field with the constraint of a minimal polynomial but with different constraints here.

A simple example: if P = ( X - a ) ( X - b ) and a + b = 0 then I want to find P = X^2 - ab

edit retag close merge delete

Sort by » oldest newest most voted

I am not sure to understand your question completely, but usually constraints can be expressed as working modulo some ideal :

sage: R.<x,a,b> = PolynomialRing(QQ)
sage: R
Multivariate Polynomial Ring in x, a, b over Rational Field
sage: P = R((x - a)*(x - b))
sage: P
x^2 - x*a - x*b + a*b
sage: P.mod(a+b)
x^2 - b^2

sage: R.<x,a,b,c> = PolynomialRing(QQ)
sage: P = R((x - a)*(x - b)*(x-c))
sage: P.mod(a+b+c)
x^3 - x*b^2 - x*b*c + b^2*c - x*c^2 + b*c^2
sage: P.mod(a*b*c-2)
x^3 - x^2*a - x^2*b + x*a*b - x^2*c + x*a*c + x*b*c - 2


Does this help ?

EDIT Regarding your answer, you should notice that, when a+b=0 (equivelently b=-a), you have x^2 - b^2 = x^2 + a*b since, you have -b^2 = -b*b = -b*(-a) = a*b !!! So i guess my answer still applies. You can check it as follows:

sage: R.<x,a,b> = PolynomialRing(QQ)
sage: I = R.ideal(a+b)
sage: I
Ideal (a + b) of Multivariate Polynomial Ring in x, a, b over Rational Field
sage: P = R((x - a)*(x - b))
sage: P.mod(I)
x^2 - b^2
sage: P.mod(I) == (x^2+a*b).mod(I)
True


Or, you can work directly in the quotient ring:

sage: Q = R.quotient(I)
sage: Q
Quotient of Multivariate Polynomial Ring in x, a, b over Rational Field by the ideal (a + b)
sage: Q(P)
xbar^2 - bbar^2
sage: Q(P) == Q(x^2+a*b)
True
sage:

more

Observe that the result is " X^2 - b^2 " while in case of " a+b=0", you should obtain " X^2 - a*b ".

Am still trying !

( 2016-02-10 14:29:23 -0500 )edit

Perhaps I wasn't clear at all. I have a polynomial where the coefficients are parameters. I take the example of

P = ( X - a0) * (X -a1) = X^2 + (-a0 - a1)*X + a0 * a1

I want to impose an equation on the parameters who belong to a field ("QQ" here), say "a0 + a1 = 0".

The result must be:

P = X^2 + a0 * a1

A=PolynomialRing(QQ,2,'a')

v=B.gens()

R.<x>=PolynomialRing(A)

P=R( ( X - v[0] ) * ( X - v[1] ) ) ; # P = ( X - a0) * (X -a1)

( 2016-02-11 02:24:16 -0500 )edit

I edited my answer to explain why x^2 - b^2 is as valid as x^2 + a*b.

( 2016-02-11 10:39:53 -0500 )edit

Yes, you are perfectly right. I answered this because I was using coefficients defined on a number field, and the "mod" didn't work because I firstly defined the number field and then the ring. I discovered that if instead you define the ring and then the number field as an extension, the method works, at least for what I tried so far. I didn't have time to explain more my comment in between, and I thank you for your help.

( 2016-02-11 12:07:04 -0500 )edit

When I use several ideals, I don't have commutativity. Is this normal?

R.<x,a,b>=QQ[]

P1=(X-a)*(X-b)

I=R.ideal(a+b)

J=R.ideal(a*b)

A=P.mod(I).mod(J) => X^2 - b^2

B=P.mod(J).mod(I) => X^2

A==B; => False

more