1 | initial version |
Your example is a bit messy, but I suggest you to try combine() and denominator() functions:
http://www.sagemath.org/doc/reference/sage/symbolic/expression.html#sage.symbolic.expression.Expression.combine http://www.sagemath.org/doc/reference/sage/symbolic/expression.html#sage.symbolic.expression.Expression.denominator