ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 26 May 2021 01:31:29 +0200polynomial ring over another polynomial ringhttps://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/I'd like to see what one multivariate polynomial $f$ looks like
when another one $g$ vanishes, by rewriting the former
as $f = r + q g$ and setting $g = 0$. In Maple, one could do that
just by computing `r = prem( f, g, x )` where `x` is one of the
indeterminates of `f` and `g`, which is effectively treating `f`
and `g` as univariate polynomials over the ring of polynomials
in the remaining indeterminates. Unfortunately when I try to do
that in Sage it gives me the following error (but perhaps there's
a simpler way?).
Input:
R.<y, z> = QQ['y, z']
S.<x> = PolynomialRing(R, 'x')
a = x^2*y - x - z
a.reduce(Ideal([x*y-z]))
Error:
Error in lines 4-4
Traceback (most recent call last):
File "/cocalc/lib/python3.8/site-packages/smc_sagews/sage_server.py",
line 1230, in execute
exec(
File "", line 1, in <module>
File "sage/structure/element.pyx", line 493,
in sage.structure.element.Element.__getattr__
(build/cythonized/sage/structure/element.c:4703)
return self.getattr_from_category(name)
File "sage/structure/element.pyx", line 506,
in sage.structure.element.Element.getattr_from_category
(build/cythonized/sage/structure/element.c:4815)
return getattr_from_other_class(self, cls, name)
File "sage/cpython/getattr.pyx", line 372,
in sage.cpython.getattr.getattr_from_other_class
(build/cythonized/sage/cpython/getattr.c:2620)
raise AttributeError(dummy_error_message)
AttributeError:
'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'
object has no attribute 'reduce'Tue, 25 May 2021 22:40:18 +0200https://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/Answer by slelievre for <p>I'd like to see what one multivariate polynomial $f$ looks like
when another one $g$ vanishes, by rewriting the former
as $f = r + q g$ and setting $g = 0$. In Maple, one could do that
just by computing <code>r = prem( f, g, x )</code> where <code>x</code> is one of the
indeterminates of <code>f</code> and <code>g</code>, which is effectively treating <code>f</code>
and <code>g</code> as univariate polynomials over the ring of polynomials
in the remaining indeterminates. Unfortunately when I try to do
that in Sage it gives me the following error (but perhaps there's
a simpler way?).</p>
<p>Input:</p>
<pre><code>R.<y, z> = QQ['y, z']
S.<x> = PolynomialRing(R, 'x')
a = x^2*y - x - z
a.reduce(Ideal([x*y-z]))
</code></pre>
<p>Error:</p>
<pre><code>Error in lines 4-4
Traceback (most recent call last):
File "/cocalc/lib/python3.8/site-packages/smc_sagews/sage_server.py",
line 1230, in execute
exec(
File "", line 1, in <module>
File "sage/structure/element.pyx", line 493,
in sage.structure.element.Element.__getattr__
(build/cythonized/sage/structure/element.c:4703)
return self.getattr_from_category(name)
File "sage/structure/element.pyx", line 506,
in sage.structure.element.Element.getattr_from_category
(build/cythonized/sage/structure/element.c:4815)
return getattr_from_other_class(self, cls, name)
File "sage/cpython/getattr.pyx", line 372,
in sage.cpython.getattr.getattr_from_other_class
(build/cythonized/sage/cpython/getattr.c:2620)
raise AttributeError(dummy_error_message)
AttributeError:
'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'
object has no attribute 'reduce'
</code></pre>
https://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/?answer=57275#post-id-57275I assume `f` is `a` and `g` is `x*y - z`?
If so, maybe this does what you want?
sage: R.<x, y, z> = QQ['x, y, z']
sage: f = x^2*y - x - z
sage: g = x*y - z
sage: J = R.ideal(g)
sage: r = J.reduce(f)
sage: r
x*z - x - z
Wed, 26 May 2021 01:14:29 +0200https://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/?answer=57275#post-id-57275Comment by Tim02130 for <p>I assume <code>f</code> is <code>a</code> and <code>g</code> is <code>x*y - z</code>?</p>
<p>If so, maybe this does what you want?</p>
<pre><code>sage: R.<x, y, z> = QQ['x, y, z']
sage: f = x^2*y - x - z
sage: g = x*y - z
sage: J = R.ideal(g)
sage: r = J.reduce(f)
sage: r
x*z - x - z
</code></pre>
https://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/?comment=57278#post-id-57278Not quite; your solution eliminated y, but what if I want to eliminate x? Since as I understand it Sage uses degrevlex order by default, I would've expected it to do that? But in any case, what I want to be able to do is control what gets eliminated, which is easy to do if one treats the polynomial ring Q[x,y,z] as Q[y,z][x] (if we want to eliminate x). Which is want I was trying to do, though Sage choked on it for some reason.Wed, 26 May 2021 01:31:29 +0200https://ask.sagemath.org/question/57274/polynomial-ring-over-another-polynomial-ring/?comment=57278#post-id-57278