polycoff(x_+c_, x_) := If(isfree(c,x), coff(c,1));
polycoff(a_*x_, x_) := If(isfree(a,c,x), coff(0,a));
polycoff(a_*x_+c_, x_) := If(isfree(a,c,x), coff(c,a));

polycoff(x_^2+x_, x_) := If(isfree(a,c,x), coff(0,1,1));
polycoff(x_^2+b_*x_, x_) := If(isfree(a,c,x), coff(0,b,1));
polycoff(a_*x_^2+x_, x_) := If(isfree(a,c,x), coff(0,1,a));
polycoff(x_^2+x_+c_, x_) := If(isfree(a,c,x), coff(c,1,1));
polycoff(a_*x_^2+x_+c_, x_) := If(isfree(a,c,x), coff(c,1,a));
polycoff(x_^2+b_*x_+c_, x_) := If(isfree(b,c,x), coff(c,b,1));
polycoff(a_*x_^2+b_*x_+c_, x_) := If(isfree(a,b,c,x), coff(c,b,a));

polycoff(x_^3+b_*x^2_+c_*x_+d_, x_) := If(isfree(b,c,d,x), coff(d,c,b,1));
polycoff(a_*x_^3+x^2_+c_*x_+d_, x_) := If(isfree(a,c,d,x), coff(d,c,1,a));
polycoff(a_*x_^3+b_*x^2_+c_*x_+d_, x_) := If(isfree(a,b,c,d,x), coff(d,c,b,a));

polycoff(x_+y_, x_,y_) := coff(0,1,1);
polycoff(a_*x_+y_, x_,y_) := If(isfree(a, x) and isfree(a, y), coff(0,a,1));
polycoff(x_+b_*y_, x_,y_)  := If(isfree(b, x) and isfree(b, y), coff(0,1,b));
polycoff(a_*x_+b_*y_, x_,y_):=If(isfree(a,b, x) and isfree(a,b, y), coff(0,a,b));
polycoff(x_+y_+c_, x_,y_) := If(isfree(c,x) and isfree(c,y), coff(c,1,1));
polycoff(x_+b_*y_+c_, x_,y_) := If(isfree(b,c,x) and isfree(b,c,y), coff(c,1,b));
polycoff(a_*x_+y_+c_, x_,y_) := If(isfree(a,c,x) and isfree(a,c,y), coff(c,a,1));
polycoff(c_+a_*x_+b_*y_, x_,y_) := If(isfree(a,b,c,x) and isfree(a,b,c,y), coff(c,a,b));