Exercice 2.1

In [1]:
A.<x,y> = QQ[]
P = x*y^5 + 2*y^4 + 3*y^3*x^3 + 4*x^2*y^2 + 5*x*y^2 + 6*y*x^3 + 7*y
In [2]:
P.degree()
Out[2]:
6
In [3]:
Q = P.polynomial(x)
Q
Out[3]:
(3*y^3 + 6*y)*x^3 + 4*y^2*x^2 + (y^5 + 5*y^2)*x + 2*y^4 + 7*y
In [4]:
Q.parent()
Out[4]:
Univariate Polynomial Ring in x over Univariate Polynomial Ring in y over Rational Field

Une syntaxe équivalente

In [5]:
B = QQ['y']['x']
B
Out[5]:
Univariate Polynomial Ring in x over Univariate Polynomial Ring in y over Rational Field
In [6]:
B(P)
Out[6]:
(3*y^3 + 6*y)*x^3 + 4*y^2*x^2 + (y^5 + 5*y^2)*x + 2*y^4 + 7*y

Une technique alternative, plus flexible

In [7]:
C.<e> = QQ[]
D.<f> = C[]
P(x=e, y=f)
Out[7]:
e*f^5 + 2*f^4 + 3*e^3*f^3 + (4*e^2 + 5*e)*f^2 + (6*e^3 + 7)*f

Exercice 2.2

In [8]:
x.parent()
Out[8]:
Multivariate Polynomial Ring in x, y over Rational Field
In [9]:
P = (x^2 + x*y + x + y)*(x + y)
In [10]:
P
Out[10]:
x^3 + 2*x^2*y + x*y^2 + x^2 + 2*x*y + y^2
In [11]:
P.factor()
Out[11]:
(x + 1) * (x + y)^2
In [12]:
B(P)
Out[12]:
x^3 + (2*y + 1)*x^2 + (y^2 + 2*y)*x + y^2
In [13]:
QQ['x']['y'](P)
Out[13]:
(x + 1)*y^2 + (2*x^2 + 2*x)*y + x^3 + x^2

Exercice 3.1

In [14]:
P = x*y^5 + 2*y^4 + 3*y^3*x^3 + 4*x^2*y^2 + 5*x*y^2 + 6*y*x^3 + 7*y
In [15]:
P
Out[15]:
3*x^3*y^3 + x*y^5 + 6*x^3*y + 4*x^2*y^2 + 2*y^4 + 5*x*y^2 + 7*y
In [16]:
B.<x,y> = PolynomialRing(QQ, order='lex')
B(P)
Out[16]:
3*x^3*y^3 + 6*x^3*y + 4*x^2*y^2 + x*y^5 + 5*x*y^2 + 2*y^4 + 7*y
In [17]:
C = A.change_ring(order='deglex')
C
Out[17]:
Multivariate Polynomial Ring in x, y over Rational Field
In [18]:
C(P)
Out[18]:
3*x^3*y^3 + x*y^5 + 6*x^3*y + 4*x^2*y^2 + 2*y^4 + 5*x*y^2 + 7*y
In [19]:
P.change_ring(A.change_ring(order='degrevlex'))
Out[19]:
3*x^3*y^3 + x*y^5 + 6*x^3*y + 4*x^2*y^2 + 2*y^4 + 5*x*y^2 + 7*y

Exercice 3.4

In [20]:
A.<x,y> = PolynomialRing(QQ, order='lex')
In [21]:
g = x - y
h = x - y^2
p = x*y - x
In [22]:
p.reduce([g, h])
Out[22]:
y^3 - y^2
In [23]:
p.reduce([h, g])
Out[23]:
y^2 - y
In [24]:
p.reduce?
In [25]:
p.mod(h).mod(g)
Out[25]:
y^3 - y^2
In [26]:
p.mod(g).mod(h)
Out[26]:
y^2 - y
In [27]:
g = x^2*y^2 - x
h = x*y^2 + y
p = x^3*y^2 + 2*x*y^4
In [28]:
p.reduce([h, g])
Out[28]:
-x^2*y - 2*y^3
In [29]:
p.reduce([g, h])
Out[29]:
-x^2*y - 2*y^3
In [30]:
p.mod(g).mod(h)
Out[30]:
x^2 + 2*x*y^4

Exercice 5.4

In [31]:
A.<x,y,z> = PolynomialRing(QQ, order='lex')
I = A.ideal(x^2 - 2*x*z + 5, x*y^2 + y*z^3, 3*y^2 - 8*z^3)
In [32]:
I
Out[32]:
Ideal (x^2 - 2*x*z + 5, x*y^2 + y*z^3, 3*y^2 - 8*z^3) of Multivariate Polynomial Ring in x, y, z over Rational Field
In [33]:
I.groebner_basis()
Out[33]:
[x^2 - 2*x*z + 5, x*z^3 + 9/640*z^8 - 3/20*z^7 + 3/16*z^5, y^2 - 8/3*z^3, y*z^3 - 3/80*z^8 + 2/5*z^7 - 1/2*z^5, z^9 - 32/3*z^8 + 80/3*z^6 + 1600/9*z^3]
In [34]:
B.<x,y,z> = PolynomialRing(QQ, order='degrevlex')
J = I.change_ring(B)
In [35]:
J.groebner_basis()
Out[35]:
[y^4 + 16/3*y^3*z + 320/9*y^2, x*y^2 + 3/8*y^3, z^3 - 3/8*y^2, x^2 - 2*x*z + 5]
In [ ]: