Multivariate Polynomial Ring +1 variable

So the idea is I was first working over

R.<w,x,y,z>=QQ[]

I have a function f and J is the Jacobian of f belonging to the ring above. I do some stuff and I end with a polynomial g in a symbolic ring in variables w,x,z. I want to lift g. So I want to do

q1, q2, q3, q4 = g.lift(J)
q1=1/3 * q1(w,x,y,z).derivative(w)
q2=1/3 *q2(w,x,y,z).derivative(x)
q3=1/3 *q3(w,x,y,z).derivative(y)
q4=1/3*q4(w,x,y,z).derivative(z)
h1=q1+q2+q3+q4

Now, the Symbolic ring has no attribute lift. This can be fixed by moving to Multivariate Polynomiial Ring by doing

g=g.polynomial(QQ)

The issue is, because g is only a function in w,x,z, this moves g to the Multivariate Polynomial Ring of w,x,z. This gives error as the Jacobian and function f is in Multivariate Polynomial Ring of w,x,y,z. I want g to be in the Multivariate Polynomial Ring of w,x,y,z even though there is no y in g. How can I do this? See my 2 attachment. In the attachment, h2 plays the role of g in my explanation above. C:\fakepath\Screenshot (126).pngC:\fakepath\Screenshot (123).png

edit retag close merge delete

Sort by ยป oldest newest most voted

Some data is missing to reproduce your context. So let me simulate one:

sage: var('w,x,y')
(w, x, y)
sage: g = w+2*x+y^2
sage: g
y^2 + w + 2*x
sage: g.parent()
Symbolic Ring

sage: R.<w,x,y,z>=QQ[]

You can directly convert the symbolic expression as an element of the ring:

sage: R(g)
y^2 + w + 2*x
sage: R(g).parent()
Multivariate Polynomial Ring in w, x, y, z over Rational Field

If you have a polynomial with less variables, it is also doable:

sage: g.polynomial(QQ)
y^2 + w + 2*x
sage: g.polynomial(QQ).parent()
Multivariate Polynomial Ring in w, x, y over Rational Field
sage: R(g.polynomial(QQ))
y^2 + w + 2*x
sage: R(g.polynomial(QQ)).parent()
Multivariate Polynomial Ring in w, x, y, z over Rational Field
more

Great thanks.

( 2021-06-03 07:31:58 +0100 )edit

You can do conversion:

R(g)

or

g = R(g)

However it is often better to avoid the symbolic ring altogether, if possible.

more

Great thanks.

( 2021-06-03 07:32:08 +0100 )edit