It would be better if this function returned a tuple of tuples of Polys, like `((u1*p1 - a*z2*p2), denom), (z1*p2 - z2*p1), denom))` (where denom does not call `as_expr`). As I've said before, avoid as_expr at all costs, unless the only place the result is going to be used is to return it to the user from `risch_integrate`.