On 2017-10-22 17:27, Jianrong Li wrote:
> Let $r=x_{1}^{4} + 2 \, x_{1}^{3} x_{2} + 4 \, x_{1}^{2} x_{2}^{2} + 2
> \, x_{1}
> x_{2}^{3} + x_{2}^{4} + 2 \, x_{1}^{3} x_{3} + 2 \, x_{2}^{3} x_{3} + 4
> \, x_{1}^{2} x_{3}^{2} + 4 \, x_{2}^{2} x_{3}^{2} + 2 \, x_{1} x_{3}^{3}
> + 2 \, x_{2} x_{3}^{3} + x_{3}^{4}$.
>
> 1. How to return the list of exponents of the monomials in $r$ in Sage?
>
> The result I want is $[(4,0,0), (3,1,0), \ldots]$.
>
> 2. How to list of terms in Sage?
>
> The result I want is $[x_{1}^{4}, 2 \, x_{1}^{3} x_{2}, \ldots]$.
>
> For Question 1, I used
>
> R.<x1,x2,x3> = PolynomialRing(QQbar, 3)
>
> r.exponents()
In SageMath 8.0 the following works:
sage: R.<x1,x2,x3> = PolynomialRing(QQbar, 3)
sage: r = x1*x2 + 2*x3
sage: r.exponents()
[(1, 1, 0), (0, 0, 1)]
sage: r.monomials()
[x1*x2, x3]
sage: list(r)
[(1, x1*x2), (2, x3)]
> This works. But when I tried to use op for Question 2. It is said that
>
> AttributeError: 'MPolynomial_polydict' object has no attribute 'op'
Can you copy/paste the code you type to reproduce this error?
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.