On Feb 18, 2013, at 1:47 PM, Emmanuel wrote:

> Hello,
> 
> I want to work with multivariate polynomials over a multivariate polynomial 
> ring (see below for the reason I want to do this). 
> 
> K.<a,b>=PolynomialRing(QQ, 2, order='lex')
> QM.<X,Y,Z> = PolynomialRing(K, 3, order='lex')
> 
> However, I have problems when I want to simplify. Consider for example, 
> 
> F=(a*b*X^2*Y*Z + X*Y^3)/Y

In fact, it is precisely the fact that you build a polynomial ring over a 
polynomial ring that causes problems. Look at this example : 

sage: K.<a,b,X,Y,Z> = QQ[]
sage: F = (a*b*X^2*Y*Z + X*Y^3)/Y; F
a*b*X^2*Z + X*Y^2

The simplification is done automatically. But note that the result (F) no 
longer lives in the polynomial ring. Since it is a quotient, it lives in the 
**fraction field** of the ring. This is because Sage does not know in advance 
whether the division is exact or not. Try :

sage: parent(F)
Fraction Field of Multivariate Polynomial Ring in a, b, X, Y, Z over Rational 
Field

If you KNOW that the division is exact, you can do :

sage: F = (a*b*X^2*Y*Z + X*Y^3) // Y
sage: parent(F)
Multivariate Polynomial Ring in a, b, X, Y, Z over Rational Field

This division procedure is not available over your fancier 
ring-on-top-of-a-ring. (Btw, the error message is somewhat not-use-friendly). 
Your problems with monomials can be solved as follows : 

sage: R.<a,b,X,Y,Z> = QQ[]
sage: f = (1+a+b)*X^2*Y+2*b*X*Y^2+a*b+a

sage: K.<a,b> = QQ[]
sage: QM.<X,Y,Z> = K[]

and you can "cast " f into QM :

sage: QM(f).monomials()
[X^2*Y, X*Y^2, 1]

sage: QM(f).coefficients()
[a + b + 1, 2*b, a*b + a]
---
Charles Bouillaguet
http://www.lifl.fr/~bouillaguet/


> 
> This is clearly a*b*X^2*Z + X*Y^2. However, I cannot automatically simplify 
> it since :
> 
> F.simplify()
> 
> returns AttributeError: 
> 'sage.rings.fraction_field_element.FractionFieldElement' object has no 
> attribute 'simplify'  whereas
> 
> F.reduce()
> 
> returns AttributeError: 
> 'sage.rings.fraction_field_element.FractionFieldElement' object has no 
> attribute 'simplify'.
> 
> How can I make the simplification with Sage ?
> 
> Thank you very much for your help!
> 
> NB. The reason why I want to consider multivariate polynomials over a 
> multivariate polynomial ring, and not a multivariate polynomials with more 
> variable is the following  I need to be able to detect monomials in a 
> polynomial, For rexample, I want the monomials of (1+a+b)X^2Y+2bXY^2+ab+a to 
> be (1+a+b)X^2Y, 2bXY^2 and ab+a instead of X^2Y, aX^2Y, bX^2Y, 2bXY^2, ab and 
> a.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to