I only looked at this very quickly: I get
>>> from sympy import * >>> pg00 = Symbol('pg00') >>> pg01 = Symbol('pg01') >>> eq1 = sympify(pg01**2/pg00**2) >>> eq2 = sympify(1.0 - 2*pg01/pg00) >>> eq3 = sympify(pg01*(1.0 - pg01/pg00)) >>> eq = [eq1,eq2,eq3] >>> print eq [pg01**2/pg00**2, 1.0 - 2*pg01/pg00, pg01*(1.0 - pg01/pg00)] >>> (red,rep) = cse(eq) >>> red [(x0, -pg01/pg00)] >>> rep [pg01**2/pg00**2, 1.0 - 2*pg01/pg00, pg01*(x0 + 1.0)] after changing ndiv to be def ndiv(a, b): """if b divides a in an extractive way (like 1/4 divides 1/2 but not vice versa, and 2/5 does not divide 1/3) then return the integer number of times it divides, else return 0. """ if a not in (S.Infinity, S.NegativeInfinity) and \ (not b.q % a.q or not a.q % b.q): return int(a/b) return 0 But it could be that the better fix is to not have infinity pulled out -- by breakup? Hopefully that can get someone started. /c -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.