# convert polynomial to polynomial holder polys() or polyroot(); # e.g. topoly(x^2+2x+3) gives polys(1,2,3); # polys() can be activated by activate() or remove its last letter "s"; topoly(x_+c_, x_) := If(isfree(c,x), polys(1,c)); topoly(a_*x_, x_) := If(isfree(a,c,x), polys(a,0)); topoly(a_*x_+c_, x_) := If(isfree(a,c,x), polys(a,c)); topoly(x_^2+c_, x_) := If(isfree(a,c,x), polys(1,0,c)); topoly(a_*x_^2+c_, x_) := If(isfree(a,c,x), polys(a,0,c)); topoly(x_^2+x_, x_) := If(isfree(a,c,x), polys(1,1,0)); topoly(a_*x_^2+x_, x_) := If(isfree(a,c,x), polys(a,1,0)); topoly(x_^2+b_*x_, x_) := If(isfree(a,c,x), polys(1,b,0)); topoly(a_*x_^2+b_*x_, x_) := If(isfree(a,c,x), polys(a,b,0)); topoly(x_^2+x_+c_, x_) := If(isfree(a,c,x), polys(1,1,c)); topoly(a_*x_^2+x_+c_, x_) := If(isfree(a,c,x), polys(a,1,c)); topoly(x_^2+b_*x_+c_, x_) := If(isfree(b,c,x), polys(1,b,c)); topoly(a_*x_^2+b_*x_+c_, x_) := If(isfree(a,b,c,x), polys(a,b,c)); topoly(x_^3+c_, x_) := If(isfree(a,c,x), polys(1,0,0,c)); topoly(a_*x_^3+c_, x_) := If(isfree(a,c,x), polys(a,0,0,c)); topoly(x_^3+x_, x_) := If(isfree(a,c,x), polys(1,0,1,0)); topoly(a_*x_^3+x_, x_) := If(isfree(a,c,x), polys(a,0,1,0)); topoly(x_^3+b_*x_, x_) := If(isfree(a,c,x), polys(1,0,b,0)); topoly(a_*x_^3+b_*x_, x_) := If(isfree(a,c,x), polys(a,0,b,0)); topoly(x_^3+x_+c_, x_) := If(isfree(a,c,x), polys(1,0,1,c)); topoly(a_*x_^3+x_+c_, x_) := If(isfree(a,c,x), polys(a,0,1,c)); topoly(x_^3+b_*x_+c_, x_) := If(isfree(b,c,x), polys(1,0,b,c)); topoly(a_*x_^3+b_*x_+c_, x_) := If(isfree(a,b,c,x), polys(a,0,b,c)); topoly(x_^3+b_*x_^2+c_*x_+d_, x_) := If(isfree(b,c,d,x), polys(1,b,c,d)); topoly(a_*x_^3+x_^2+c_*x_+d_, x_) := If(isfree(a,c,d,x), polys(a,1,c,d)); topoly(a_*x_^3+b_*x_^2+c_*x_+d_, x_) := If(isfree(a,b,c,d,x), polys(a,b,c,d)); topoly(x_^3+x_^2+x_+d_, x_) := If(isfree(d,x), polys(1,1,1,d)); topoly(x_^4+f_, x_) := If(isfree(f,x), polys(1,0,0,0,f)); topoly(x_^4+x_^2+f_, x_) := If(isfree(f,x), polys(1,0,1,0,f)); topoly(x_^4+c_*x_^2_+f_, x_) := If(isfree(c,f,x), polys(1,0,c,0,f)); topoly(a_*x_^4+x_^2+f_, x_) := If(isfree(a,f,x), polys(a,0,1,0,f)); topoly(a_*x_^4+c_*x_^2+f_, x_) := If(isfree(a,c,f,x), polys(a,0,c,0,f)); topoly(x_=a_ and b_, x_) := polys(a and b); topoly(x_=a_ and b_ and c_, x_) := polys(a and b and c); topoly(x_=a_ and b_ and c_ and d_, x_) := polys(a and b and c and d); topoly(a_ and b_, x_) := polys(a and b); topoly(a_ and b_ and c_, x_) := polys(a and b and c); topoly(a_ and b_ and c_ and d_, x_) := polys(a and b and c and d); topoly(y_):=topoly(y,x);