Artifical workaround: sage: R.<x,y>=QQ[] sage: w=3*x^2+4*x sage: w.monomials() [x^2, x]
On 29 Kwi, 00:28, tvn <nguyenthanh...@gmail.com> wrote: > Hi, the monimals function you suggested doesn't work for the below case > where I want to extract the terms [x^2,x] from the given expression > 3*x^2+4*x . > > sage: type(x) > <type > 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'> > sage: R.<x,y> = PolynomialRing(QQ,'x,y') > sage: type(x) > <type > 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'> > > sage: R.<x> = PolynomialRing(QQ,'x') > sage: w=3*x^2 + 4*x > sage: w.monomials() > --------------------------------------------------------------------------- > AttributeError Traceback (most recent call last) > > Thhe reason I think is that > > sage: R.<x> = PolynomialRing(QQ,'x') > sage: type(x) > <type > 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint'> > sage: R.<x,y> = PolynomialRing(QQ,'x,y') > sage: type(x) > <type > 'sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular'> > > see the diff type of x . > > What do I do in this case ? > > Thanks, > > /home/tnguyen/Dropbox/code/invgen/<ipython console> in <module>() > > /home/Storage/Src/Devel/SAGE/sage-4.6.2/local/lib/python2.6/site-packages/sage/structure/element.so > in sage.structure.element.Element.__getattr__ > (sage/structure/element.c:2715)() > > /home/Storage/Src/Devel/SAGE/sage-4.6.2/local/lib/python2.6/site-packages/sage/structure/parent.so > in sage.structure.parent.getattr_from_other_class > (sage/structure/parent.c:2841)() > > /home/Storage/Src/Devel/SAGE/sage-4.6.2/local/lib/python2.6/site-packages/sage/structure/parent.so > in sage.structure.parent.raise_attribute_error > (sage/structure/parent.c:2636)() > > AttributeError: > 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' > object has no attribute 'monomials' -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org