k;c;d;e;f;g;junk2;junk3;b;h;j;a;z;x2;x3;x4;x1;

allocatemem(20*10^6);
do(P,Q)=my(v=variable()); substvec(polresultant(P,Q), v, vector(#v,i,i));

P = Pol([k,c,d,e,f,g]);
Q = P';
do(P,Q)

P = Pol([1,b,c,d,e]);
Q = Pol([1,g,h,k,j]);
do(P,Q)

P = x^7 + x^3 + b*x^2 + c*x + d;
Q = x^7 + x^3 + f*x^2 + g*x + h;
do(P,Q)

P = x^20 + a*x^5 + b;
Q = x^20 + c*x^5 + d;
do(P,Q)

P = (x+a)^8;
Q = (x+z)^8;
do(P,Q)

P = x^50 + 5*a*x^40 + 4*a*x^30 + a*x^20 + 2*a*x^10 + 3*a;
Q = x^45 + 2*b*x^35 + b*x^25 + 4*b*x^15 + 5*b*x^5 + 6*b;
do(P,Q)

P = polcyclo(31); P = subst(P, x, a*x);
Q = polcyclo(29); Q = subst(Q, x, a*x);
do(P,Q)

P = 1 + Polrev( vector(101, j, b^(101-j)) );
Q = 1 + Polrev( vector(101, j, b^(j-1)) );
do(P,Q)

P = 1 + Polrev( vector(301,i,1) );
Q = 1 + Polrev( vector(201,i,i-1) );
do(P,Q)

P = 1 + Polrev( vector(301,j, (j-1)^5) );
Q = 1 + Polrev( vector(301,j, (j-1)^4) );
do(P,Q)

n = 110;
polrandom(d, fudge) = x^d + Polrev(vector(d+1, i, round(2^32*sin(i+fudge))));
P = polrandom(n,0);
Q = polrandom(n,1/2);
do(P,Q)

polresultant(-27673*x^2+322883101*x-1876122109136,x^4+4503599627370517)
P=-27673*x^2+322883101*x-1876122109136;
for(n=2,3,for(l=1,3,print(polresultant(P*x^l+1,n*x^4+4503599627370517))))

polresultant(z^1746-1, polcyclo(1973, z))

for(i=1,15,if(rnfequation(polcyclo(17,'y),x+y^i,1)[2]^17!=1,print("error",i)))

\\ #1233
polresultantext(x^2+1, x^2-1)
\\ #1234
polresultant(x^4+x^2+1, x^4-y, x, 0)

p1=x2*(x3-x4);p2=x2*(x3-2*x4);polresultant(p1,p2,x1)
polresultant(x,x,y)

A = x*y; B = (x+y)^2;
polresultant(A, B)
polresultantext(A, B, y)
polresultantext(1,x)

\\ #1509
polresultantext(y^3+y,3*y^2+1,y)
poldisc(x^3 + Mod(2,3)*x^2)
poldisc(x^3 + Mod(2,3)*x^2+1)

norm(Mod(Pol(Mod(0,2)), 3*x))

polresultantext(x+1, x^2)
\\#1614
polresultant(1+x*z^2,1+y*z^4,z)

polcompositum(x^5-5,x^4-2,2)
polcompositum(x-1, x^2+x+1, 1)
polcompositum(x-1, x, 1)
my(p=nextprime(2^31));polcompositum(p*x^2+x+1,p*x^3+x+1)
my(p=nextprime(2^63));polcompositum(p*x^2+x+1,p*x^3+x+1)
polcompositum(x^2+x/3+1,x^2+x/3+1)
polcompositum(x^2+x/3+1,x^2+x/3+1,2)

polresultant(x^2+1,z,x)

P=polcyclo(101);Q=P';
polresultant(P*Mod(1,3),Q)
polresultant(P*Mod(1,2^127-1),Q)

P=polcyclo(2003);Q=P';
polresultant(P*Mod(1,3),Q)
polresultant(P*Mod(1,2^127-1),Q)

polresultant(Mod(1,3)*x*y*z,Mod(1,3)*(x^2+1)*y*z)

polresultant(x,2)
polresultant(x^2,2)
polresultant(x^2,y)

polresultant(y^2+1/x, y/x+1, y)

check(P,Q)=
{
  my(d=poldegree(P),e=poldegree(Q));
  if(polresultant(P,Q)*y^(d*e)!=polresultant(subst(P,x,'x/y)*y^d,subst(Q,'x,x/y)*y^e),error(P));
}
test(a)=check(a^0*x^6+(a^9+a^8+a^7+a^6+a^4+a^3+a)*x+(a^9+a^8+a^7+2*a^6+a^4+a^2),a^0*x^7+(a^8+a^7+a^6+a^4+a^3+a)*x+(a^9+a^7+2*a^6+a^4+a^2));
test(ffgen(2^10,'a));
test(ffgen(3^10,'a));
test(ffgen([nextprime(2^100),5],'a));
test(Mod(Mod(1,2),ffinit(2,5,'a)));
test(Mod(Mod(1,3),ffinit(3,5,'a)));
my(p=nextprime(2^100)); test(Mod(Mod(1,nextprime(2^100)),ffinit(p,3,'a)));

polresultant(x^2+y*x+y^4,(3*x^4+(y+5)*x^3+(2*y+1)*x^2+y*x+y^3)/x,y)
polresultant(x^2+y*x+y^4,(x^4+(y+5)*x^3+(2*y+1)*x^2+y*x+y^3)/x,y)
polresultant(-y^7 + x*y^2 + x^4,(624*y^10 + 832*x^3*y^8 - 156*x*y^5 - 117*x^2 )/y)

a=ffgen([2,2],'a);
f=x^6 + (y^5 + (a + 1));
g=(a*x^11+a*x^10+(a*y^2+(a+1)*y+(a+1))*x^9+((a+1)*y^3+(a+1)*y^2+y)*x^8+(y^3+a*y^2+a)*x^7+(y^4+y^3+y+a)*x^6+(a*y^3+y^2+(a+1)*y+1)*x^5+((a+1)*y^3+a*y^2+y+(a+1))*x^4+(a*y^3+y^2+(a+1)*y+a)*x^3+((a+1)*y^3+a*y)*x^2+(a*y^3+a*y^2+a*y+a)*x+((a+1)*y^4+y+1))/(a*x^3+(a+1));
polresultant(f,g,'y)
