Maple simplify a polynomial without using functions that uses gcd.

101 Views Asked by At

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)$

2

There are 2 best solutions below

0
On

If p is your polynomial, then q := subs(1/(y-1)=z, p); will abstract out 1/(y-1) as z. Then you can manipulate it just like a polynomial, with all the usual tools. For example collect 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, the x^5 term is

y^3*z + y^2*z - y^2 - y*z - 2*y - z - 1

which isn't going to be 0 unless z = 1/(y-1).

0
On

A helper routine to get this sort of denominator out of individual terms in the sum. (Not bulletproof but works here.)

getdenom:=proc(u)
  local T,TT;
  if u::`*` then
    T:=[op(u)];
    TT:=select(type,T,And(`^`,satisfies(p->op(2,p)::numeric
                                           and op(2,p)<0)));
    TT:={op(map(p->op(1,p)^(-op(2,p)),TT))};
  else
    return {1};
  end if;
end proc:

The original expression.

expr:=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:

Now extract all the denominators of terms in the sum, uniquify in a set, and multiply together.

LL:=[op(expr)]:

`union`(op(map(getdenom,LL)));

                       {1, y - 1}

GG:=`*`(op(%));

                      GG := y - 1

Multiply all terms in the sum by that value, and expand each (fortuitously getting desired cancellation, for this particular example), then divide by that value.

RR:=map(expand@`*`,LL,GG):

ans:=map(`/`,`+`(op(RR)),GG):

This result matches the requested target.

lprint(ans);

y^8/(y-1)+2*x^3*y^3/(y-1)+2*x^2*y^4/(y-1)+2*x*y^5/(y-1)
+y^6/(y-1)+4*x^3*y^2/(y-1)+2*x^2*y^3/(y-1)
+2*x*y^4/(y-1)+2*y^5/(y-1)-2*x^3*y/(y-1)+2*x^2*y^2/(y-1)
-4*x^3/(y-1)-2*x^2*y/(y-1)+2*x*y^2/(y-1)-4*x^2/(y-1)
-2*x*y/(y-1)+y^2/(y-1)-4*x/(y-1)-2*y/(y-1)-3/(y-1)