Ask Your Question
0

changing a variable in the ring of polynomials

asked 2024-06-16 01:17:08 +0100

hamouda gravatar image

updated 2024-06-16 01:30:25 +0100

In the ring $\mathbb{Z}[x,y]$ , I want to add the new variable z:=xy, and show it in the polynomial $p=(ex+y)^2$ so that $p=(ex)^2+2ez+y^2$. My attempt is to define the rings and the polynomial $p$

S.<e>=ZZ['e'];
R.<x,y,z>=S['x, y, z'];
p=(e*x+y)^2

and to set $xy=z$, we define the ideal $I=(xy-z)R $ and the quotient $Q=R/I$

I=(x*y-z)*R; Q=R.quo(I)

to reduce the polynomial $p$ modulo the ideal $I$ we use

q=Q(p)

So far, I have a problem such that sagemath outputs an error ' Can only reduce polynomials over fields.' I want to know where is the problem ?? and solve it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-06-16 09:34:41 +0100

Emmanuel Charpentier gravatar image

$\mathbb{Z}[e]$ is not a field : $\exists x,y\in\mathbb{Z}[e] ,\,\displaystyle{\frac{x}{y}}\not\in\mathbb{Z}[e]$. Use its fraction field instead :

sage: S=FractionField(ZZ['e'])
sage: R.<x,y,z>=S['x, y, z'];
sage: p=(e*x+y)^2
sage: I=(x*y-z)*R; Q=R.quo(I)
sage: q=Q(p)
sage: q
e^2*xbar^2 + ybar^2 + 2*e*zbar

whuch is, up to a lift :

sage: q.parent()
Quotient of Multivariate Polynomial Ring in x, y, z over Fraction Field of Univariate Polynomial Ring in e over Integer Ring by the ideal (x*y - z)

the result you sought.

Alternative, using symbolic variables (and Sympy's subs, which is recursive) :

sage: reset()
sage: var("x, y, z, e")
(x, y, z, e)
sage: import sympy
sage: ((e*x+y)^2)._sympy_().expand().subs(sympy.sympify({x*y:z}))._sage_()
e^2*x^2 + y^2 + 2*e*z

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-06-16 01:17:08 +0100

Seen: 150 times

Last updated: Jun 16