Currently trying to find a way to simplify a polynomial in $x,y$ without using functions that uses gcd, eg. simplify(). And failing spectacularly.
$2 + 3*x + 3*x^3*y + 3*x*y - x^4*y^3 - x^3*y^4 - x^2*y^5 - x*y^6 - 3*x^4*y^2 - 2*x^3*y^2 - 2*x^2*y^3 - 2*x*y^4 + 2*y - 3*x^4*y + y^6/(y - 1) - x^5/(y - 1) - x^4/(y - 1) - x^3/(y - 1) - x^2/(y - 1) - x/(y - 1) - 1/(y - 1) + x^3*y^3/(y - 1) - x^5*y/(y - 1) + x^2*y^4/(y - 1) + x*y^5/(y - 1) - 2*y^5 - x^4 - y^2/(y - 1) - 2*y/(y - 1) - x^5*y^2 + 3*x^2*y + y^8/(y - 1) + 2*y^7/(y - 1) - 3*x^3*y^3 - 3*x^2*y^4 - 3*x*y^5 - 2*x^5*y + x^5*y^3/(y - 1) + x^4*y^4/(y - 1) + x^3*y^5/(y - 1) + x^2*y^6/(y - 1) + x*y^7/(y - 1) + x^5*y^2/(y - 1) + 2*x^4*y^3/(y - 1) + 2*x^3*y^4/(y - 1) + 2*x^2*y^5/(y - 1) + 2*x*y^6/(y - 1) - 2*x^4*y/(y - 1) - x^3*y^2/(y - 1) - 2*x^3*y/(y - 1) - x^2*y^2/(y - 1) - 2*x^2*y/(y - 1) - x*y^2/(y - 1) - 2*x*y/(y - 1) - x^5 - 2*y^6 + 3*x^3 + 3*x^2$
has degree 5 in x when in this form but should simplify to degree 3 with this form:
$y^6/(y - 1) - 4*x^3/(y - 1) - 4*x^2/(y - 1) - 4*x/(y - 1) - 3/(y - 1) + 2*x^3*y^3/(y - 1) + 2*x^2*y^4/(y - 1) + 2*x*y^5/(y - 1) + y^8/(y - 1) + 2*y^5/(y - 1) + 4*x^3*y^2/(y - 1) + 2*x^2*y^3/(y - 1) + 2*x*y^4/(y - 1) + 2*y^2*x^2/(y - 1) + 2*y^2*x/(y - 1) - 2*y/(y - 1) - 2*y*x^3/(y - 1) + y^2/(y - 1) - 2*x*y/(y - 1) - 2*y*x^2/(y - 1)$
If
p
is your polynomial, thenq := subs(1/(y-1)=z, p);
will abstract out1/(y-1)
asz
. Then you can manipulate it just like a polynomial, with all the usual tools. For examplecollect
is very useful.After playing around with it a lot, I'm pretty sure that you won't be able to obtain the above form without using some amount of gcd. For example, for
q
as above, thex^5
term iswhich isn't going to be 0 unless
z = 1/(y-1)
.