I consider polynomials of the form $P=\prod_i (1-1/y_i)$, where each $y_i$ is a Laurent monomial with unit coefficient in variables $x_1,\ldots,x_k, q_1,q_2,q_3,m$.
I'm interested in taking ratios of the form $P_1 / (P_2 \prod_{n=1}^k x_n)$ of such polynoimals, and would like to know what the fastest way is to cancel common factors using sagemath.
An example, where numerator and denominator have already been factored (quickly) by sage:
(q1*q2*x0 - x1)*(q1*q2*x0 - x2)*(q1*q2*x0 - x3)*(q1*q2*x0 - 1)*(q1*q3*x0 - x1)*(q1*q3*x0 - x2)*(q1*q3*x0 - x3)*(q1*q3*x0 - 1)*(q2*q3*x0 - x1)*(q2*q3*x0 - x2)*(q2*q3*x0 - x3)*(q1*q2*x1 - x0)*(q1*q2*x1 - x2)*(q1*q2*x1 - x3)*(q1*q2*x1 - 1)*(q1*q3*x1 - x0)*(q1*q3*x1 - x2)*(q1*q3*x1 - x3)*(q1*q3*x1 - 1)*(q2*q3*x1 - x0)*(q2*q3*x1 - x2)*(q2*q3*x1 - x3)*(q1*q2*x2 - x0)*(q1*q2*x2 - x1)*(q1*q2*x2 - x3)*(q1*q2*x2 - 1)*(q1*q3*x2 - x0)*(q1*q3*x2 - x1)*(q1*q3*x2 - x3)*(q1*q3*x2 - 1)*(q2*q3*x2 - x0)*(q2*q3*x2 - x1)*(q2*q3*x2 - x3)*(q1*q2*x3 - x0)*(q1*q2*x3 - x1)*(q1*q2*x3 - x2)*(q1*q2*x3 - 1)*(q1*q3*x3 - x0)*(q1*q3*x3 - x1)*(q1*q3*x3 - x2)*(q1*q3*x3 - 1)*(q2*q3*x3 - x0)*(q2*q3*x3 - x1)*(q2*q3*x3 - x2)*(q2*q3 - x0)*(q2*q3 - x1)*(q2*q3 - x2)*(q2*q3 - x3)*(m - x0)*(m - x1)*(m - x2)*(m - x3)*(x0 - x1)^2*(x0 - x2)^2*(x0 - x3)^2*(x1 - x2)^2*(x1 - x3)^2*(x2 - x3)^2/((q1*q2*q3*x0 - x1)*(q1*q2*q3*x0 - x2)*(q1*q2*q3*x0 - x3)*(q1*q2*q3*x0 - 1)*(q1*q2*q3*x1 - x0)*(q1*q2*q3*x1 - x2)*(q1*q2*q3*x1 - x3)*(q1*q2*q3*x1 - 1)*(q1*q2*q3*x2 - x0)*(q1*q2*q3*x2 - x1)*(q1*q2*q3*x2 - x3)*(q1*q2*q3*x2 - 1)*(q1*q2*q3*x3 - x0)*(q1*q2*q3*x3 - x1)*(q1*q2*q3*x3 - x2)*(q1*q2*q3*x3 - 1)*(q1*x0 - x1)*(q1*x0 - x2)*(q1*x0 - x3)*(q1*x0 - 1)*(q2*x0 - x1)*(q2*x0 - x2)*(q2*x0 - x3)*(q3*x0 - x1)*(q3*x0 - x2)*(q3*x0 - x3)*(q1*x1 - x0)*(q1*x1 - x2)*(q1*x1 - x3)*(q1*x1 - 1)*(q2*x1 - x0)*(q2*x1 - x2)*(q2*x1 - x3)*(q3*x1 - x0)*(q3*x1 - x2)*(q3*x1 - x3)*(q1*x2 - x0)*(q1*x2 - x1)*(q1*x2 - x3)*(q1*x2 - 1)*(q2*x2 - x0)*(q2*x2 - x1)*(q2*x2 - x3)*(q3*x2 - x0)*(q3*x2 - x1)*(q3*x2 - x3)*(q1*x3 - x0)*(q1*x3 - x1)*(q1*x3 - x2)*(q1*x3 - 1)*(q2*x3 - x0)*(q2*x3 - x1)*(q2*x3 - x2)*(q3*x3 - x0)*(q3*x3 - x1)*(q3*x3 - x2)*(q2 - x0)*(q2 - x1)*(q2 - x2)*(q2 - x3)*(q3 - x0)*(q3 - x1)*(q3 - x2)*(q3 - x3)*x0*x1*x2*x3)
If I try to factor() this, it takes forever, maybe it's using maxima? ideally, I'd like to use singular.