Remove a variable from a polynomial ring k(a,b)[x1,x2,x0] where a,b are parameters

I am trying to homogenize polynomials using variable x0 in a polynomial ring k(a,b)[x1,x2] defined as follows:

R.<a,b>    = PolynomialRing( QQ, order='degrevlex' )
K = FractionField( R )
RK.<x1,x2> = PolynomialRing( K, order='degrevlex' )

After homogenization, I define the new polynomial ring with block order:

RKH.<x1,x2,x0>=PolynomialRing(K,order='degrevlex(2),degrevlex(1)')

Then in my program, I need to dehomogenize my polynomials by setting x0=1, and remove the variable x0 from the polynomial ring. This works fine in a polynomial ring without the parameter fraction field. For example

P.<x,y,z>=PolynomialRing(QQ,order='degrevlex(2),degrevlex(1)')
fp=x^2+x*y+4*z^2
R=P.remove_var(z,order='degrevlex');R
R(fp(z=1)).parent()
Multivariate Polynomial Ring in x, y, z over Rational Field
Multivariate Polynomial Ring in x, y over Rational Field
Multivariate Polynomial Ring in x, y over Rational Field

However, with the fraction field k(a,b), the same method does not work any more:

R.<a,b>    = PolynomialRing( QQ, order='degrevlex' )
K = FractionField( R )
RK.<x1,x2> = PolynomialRing( K, order='degrevlex' )
RKH.<x1,x2,x0>=PolynomialRing(K,order='degrevlex(2),degrevlex(1)')
pf=a*x1^2-b*x1*x2+x0^2
RKHn=RKH.remove_var(x0,order='degrevlex')
pfn=pf(x0=1)
RKHn(pfn)
Multivariate Polynomial Ring in x1, x2, x0 over Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field
Error in lines 11-11
TypeError: not a constant polynomial

I didn't copy down the whole error message so it doesn't look so long. Is there a way to fix this? Thank you for your help!

edit retag close merge delete

Sort by » oldest newest most voted

That seems like an error to me that should be reported. In the mean time, a workaround:

sage: phi=Hom(RKH,RKHn)([RKHn.0,RKHn.1,1])
sage: phi(pfn)
a*x1^2 + (-b)*x1*x2 + 1
sage: parent(phi(pfn))
Multivariate Polynomial Ring in x1, x2 over Fraction Field of Multivariate Polynomial Ring in a, b over Rational Field
more