Something like this might work, then:

    >>> from sympy.utilities.iterables import cart
    >>> terms = [x, x+y, x-y]
    >>> for e in cartes(terms, ["+","-"], terms):
    ...  expr = ' '.join([str(x) for x in e])
    ...  ans = S(expr)
    ...  print expr,';',ans
    ...
    x - y + x - y ; 2*x - 2*y
    x - y + x ; 2*x - y
    x - y + x - 2*y ; 2*x - 3*y
    x - y - x - y ; -2*y
    x - y - x ; -y
    x - y - x - 2*y ; -3*y
    x + x - y ; 2*x - y
    x + x ; 2*x
    x + x - 2*y ; 2*x - 2*y
    x - x - y ; -y
    x - x ; 0
    x - x - 2*y ; -2*y
    x - 2*y + x - y ; 2*x - 3*y
    x - 2*y + x ; 2*x - 2*y
    x - 2*y + x - 2*y ; 2*x - 4*y
    x - 2*y - x - y ; -3*y
    x - 2*y - x ; -2*y
    x - 2*y - x - 2*y ; -4*y

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