On Sun, Mar 18, 2012 at 10:57 PM, Alan Bromborsky <[email protected]>wrote:

> If a1 is commutative and e1 and e2 are not then
>
> (a1*e1*e2).args_cnc() = [[a1], [e1, e2]]
>
> and
>
> (a1*e1*e1).args_cnc() = [[a1], [e1**2]]
>
> is there anyway to make
>
> (a1*e1*e1).args_cnc() = [[a1], [e1,e1]]
>
> or in general to convert
>
> e1**r to [e1,e1,...,e1] r-times
>
>
No general function that I know of but

    >>> c,nc=(x*A**2*(A*B)**2*B**-3).args_cnc()
    >>> newnc = []
    >>> newnc=[]
    >>> for i in nc:
    ...  b, e = i.as_base_exp()
    ...  if e.is_Integer:
    ...   if e < 0:
    ...     newnc.extend([b**-1]*abs(e))
    ...   else:
    ...    newnc.extend([b]*e)
    ...  else:
    ...    newnc.append(i)
    ...
    >>> newnc
    [A, A, A*B, A*B, B**(-1), B**(-1), B**(-1)]
    >>> nc
    [A**2, (A*B)**2, B**(-3)]

/c

-- 
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.

Reply via email to