If you suspect that you are working with something that is pretty 
symmetric, something like this can work:

>>> def group_factor(r, *p):
...  a = []
...  for g in p:
...   i,r = r.as_independent(*g)
...   a.append(factor(i))
...  return Add(*a)
...
>>> n,d = [i.expand() for i in E.expand().as_numer_denom()]
>>> pairs = (x1,x2),(y1,y2),(r1,r2)
>>> pprint(group_factor(n,*pairs)/group_factor(d,*pairs))
         2                       /    2     2     2     2\
(x1 - x2) *(y1 + y2) + (y1 - y2)*\- r1  + r2  + y1  - y2 /
----------------------------------------------------------
                          2              2
               2*(x1 - x2)  + 2*(y1 - y2)



-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2e85449f-4d9a-4163-8b14-c1eded8c831a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to