Hi Ondrej, thanks for your suggestion.
>take an expression:
>In [1]: L1 = S("x0 + w*x1 + w^2*x2")
I haven't known sympy expressions as S("....") until now. This is useful.
>In [3]: e = (L1**3).expand()
> 3*w*x1*x0**2 + 3*x0*w**2*x1**2 + 3*x0*w**4*x2**2 + 3*x1*w**5*x2**2 +
> 3*x2*w**2*x0**2
>+ 3*x2*w**4*x1**2 + x0**3 + w**3*x1**3 + w**6*x2**3 + 6*x0*x1*x2*w**3
and 0==1+w+w^2: in consequence
w**2==-(1+w) == (-1-w)
w**3==-(w+w**2) == -w - w**2 == -w + (1+w) == 1
w**4== w
w**5== w**2 == (-1-w)
w**6== 1
So, I can substitute w**2, ... w**6 for upper right terms manually and
calculate the express as below
>In [11]: e.subs(1+w+w**2, 0)
S('3*w*x1*x0**2 + 3*x0*(-1-w)*x1**2 + 3*x0*w*x2**2 + 3*x1*(-1-w)*x2**2 +
3*x2*(-1-w)*x0**2 + 3*x2*w*x1**2 + x0**3 + 1*x1**3 + 1*x2**3 +
6*x0*x1*x2*1').expand()
===============================
6*x0*x1*x2 - 3*x0*x1**2 - 3*x1*x2**2 - 3*x2*x0**2 - 3*w*x0*x1**2 - 3*w*x1*x2**2
- 3*w*x2*x0**2 + 3*w*x0*x2**2 + 3*w*x1*x0**2 + 3*w*x2*x1**2 + x0**3 + x1**3 +
x2**3
This expression is the one that I wanted.
thanks a lot.
--
Kenji Kobayashi
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---