Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Polynomial ring conversion: potential bug

I am trying to recursively solve a (zero-dimensional) system of polynomial equations in multiple variables by calculating elimination ideals, solving the resulting univariate polynomials algebraically and plugging the roots in to the original equations in order to remove a variable.

For this, it is necessary to observe within Sage that after plugging in a value for one variable, the result is then a polynomial in fewer variables. The following code shows an example where the coercion into a polynomial ring in fewer variables works in the first step but fails in the second (although in both steps the polynomial does not even contain the variable to be eliminated):

R.<x, y, s, t> = QQ[]
g = x * y

f1 = PolynomialRing(QQ, t)(t - 1)
L1.<a1> = QQ.extension(f1)
R1 = PolynomialRing(L1, [x, y, s])
g = g.change_ring(L1)    # allow coefficients in L1
g = g(x, y, s, a1)       # plug in t := a1
g = R1(g)                # regard as polynomial in less variables
assert parent(g) == R1   # works

f2 = PolynomialRing(L1, s)(s - 1)
L2.<a2> = L1.extension(f2)
R2 = PolynomialRing(L2, [x, y])
g = g.change_ring(L2)
g = g(x, y, a2)
g = R2(g)    # fails: "TypeError: not a constant polynomial"

(Note that this is a toy example, my code tries to achieve the same for arbitrary $R$, $f_i$'s and $g$.)

I assume this is a bug within the polynomial ring coercion. Or is the R(...)-coercion not meant for this situation and there is a more robust way of achieving this?

Polynomial ring conversion: potential bug

I am trying to recursively solve a (zero-dimensional) system of polynomial equations in multiple variables by calculating elimination ideals, solving the resulting univariate polynomials algebraically and plugging the roots in to the original equations in order to remove a variable.

For this, it is necessary to observe within Sage that after plugging in a value for one variable, the result is then a polynomial in fewer variables. The following code shows an example where the coercion into a polynomial ring in fewer variables works in the first step but fails in the second (although in both steps the polynomial does not even contain the variable to be eliminated):

R.<x, y, s, t> = QQ[]
g = x * y

f1 = PolynomialRing(QQ, t)(t - 1)
L1.<a1> = QQ.extension(f1)
R1 = PolynomialRing(L1, [x, y, s])
g = g.change_ring(L1)    # allow coefficients in L1
g = g(x, y, s, a1)       # plug in t := a1
g = R1(g)                # regard as polynomial in less fewer variables
assert parent(g) == R1   # works

f2 = PolynomialRing(L1, s)(s - 1)
L2.<a2> = L1.extension(f2)
R2 = PolynomialRing(L2, [x, y])
g = g.change_ring(L2)
g = g(x, y, a2)
g = R2(g)    # fails: "TypeError: not a constant polynomial"

(Note that this is a toy example, my code tries to achieve the same for arbitrary $R$, $f_i$'s and $g$.)

I assume this is a bug within the polynomial ring coercion. Or is the R(...)-coercion not meant for this situation and there is a more robust way of achieving this?

Polynomial ring conversion: potential bug

I am trying to recursively solve a (zero-dimensional) system of polynomial equations in multiple variables by calculating elimination ideals, solving the resulting univariate polynomials algebraically and plugging the roots in to the original equations in order to remove a variable.

For this, it is necessary to observe within Sage that after plugging in a value for one variable, the result is then a polynomial in fewer variables. The following code shows an example where the coercion into a polynomial ring in fewer variables works in the first step but fails in the second (although in both steps the polynomial does not even contain the variable to be eliminated):

R.<x, y, s, t> = QQ[]
g = x * y

f1 = PolynomialRing(QQ, t)(t - 1)
L1.<a1> = QQ.extension(f1)
R1 = PolynomialRing(L1, [x, y, s])
g = g.change_ring(L1)    # allow coefficients in L1
g = g(x, y, s, a1)       # plug in t := a1
g = R1(g)                # regard as polynomial in fewer variables
assert parent(g) == R1   # works

f2 = PolynomialRing(L1, s)(s - 1)
L2.<a2> = L1.extension(f2)
R2 = PolynomialRing(L2, [x, y])
g = g.change_ring(L2)
g = g(x, y, a2)
g = R2(g)    # fails: "TypeError: not a constant polynomial"

(Note that this is a toy example, my code tries to achieve the same for arbitrary $R$, $f_i$'s and $g$.)

I assume this is a bug within the polynomial ring coercion. Or is the R(...)-coercion not meant for this situation and there is a more robust way of achieving this?

Polynomial ring conversion: potential bugconversion error

I am trying to recursively solve a (zero-dimensional) system of polynomial equations in multiple variables by calculating elimination ideals, solving the resulting univariate polynomials algebraically and plugging the roots in to the original equations in order to remove a variable.

For this, it is necessary to observe within Sage that after plugging in a value for one variable, the result is then a polynomial in fewer variables. The following code shows an example where the coercion into a polynomial ring in fewer variables works in the first step but fails in the second (although in both steps the polynomial does not even contain the variable to be eliminated):

R.<x, y, s, t> = QQ[]
g = x * y

f1 = PolynomialRing(QQ, t)(t - 1)
L1.<a1> = QQ.extension(f1)
R1 = PolynomialRing(L1, [x, y, s])
g = g.change_ring(L1)    # allow coefficients in L1
g = g(x, y, s, a1)       # plug in t := a1
g = R1(g)                # regard as polynomial in fewer variables
assert parent(g) == R1   # works

f2 = PolynomialRing(L1, s)(s - 1)
L2.<a2> = L1.extension(f2)
R2 = PolynomialRing(L2, [x, y])
g = g.change_ring(L2)
g = g(x, y, a2)
g = R2(g)    # fails: "TypeError: not a constant polynomial"

(Note that this is a toy example, my code tries to achieve the same for arbitrary $R$, $f_i$'s and $g$.)

I assume this is a bug within the polynomial ring coercion. Or is the R(...)-coercion not meant for this situation and there is a more robust way of achieving this?