The following light-weight version of what Oscar has suggested might be
sufficient:
>>> def add(s,o):
... assert s.func == o.func
... return s.func(s.lhs+o.lhs,o.rhs+s.rhs)
...
>>> def mul(s,o):
... return s.func(o*s.lhs,o*s.rhs)
...
>>> def rmul(s,o):
... return s.func(o*s.lhs,o*s.rhs)
...
>>> Eq.__add__ = add
>>> Eq.__mul__ = mul
>>> Eq.__rmul__ = rmul
>>>
>>> from sympy import symbols, Eq, expand, simplify, latex, oo, Sum
>>> x, y, p, q, a, j, Aj, Bj = symbols('x y p q a j A_j B_j')
>>> eq1 = Eq(x, y)
>>> eq2 = Eq(p, q)
>>> eq1 + eq2
Eq(p + x, q + y)
>>> a*eq1
Eq(a*x, a*y)
And for the Sums, use IndexedBase otherwise Sum doesn't know that the
symbols depend on j
>>> Aj = IndexedBase("A")[j]>>> Bj = IndexedBase("B")[j]
>>> ex1 = Sum(Aj + Bj, (j, -oo, oo))
>>> ex2 = Sum(Aj - Bj, (j, -oo, oo))
>>> ex1 + ex2
Sum(A[j] - B[j], (j, -oo, oo)) + Sum(A[j] + B[j], (j, -oo, oo))
>>> expand(_)
2*Sum(A[j], (j, -oo, oo)) + Sum(-B[j], (j, -oo, oo)) + Sum(B[j], (j, -oo, oo
))
>>> factor_terms(_)
2*Sum(A[j], (j, -oo, oo))
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/ae75c13d-d888-441f-9742-c3f8c3014506%40googlegroups.com.