
function Elim(C,v,n) u:=-Coefficient(C[n],v,0)/Coefficient(C[n],v,1);
 return [Evaluate(c,v,u) : c in C]; end function;

function clearit(C)
return C*Lcm([Denominator(x) : x in Coefficients(C)]); end function;

_<t,a3,a2,a1,a0,b4,b3,b2,b1,b0,c3,c2,c1,c0>:=PolynomialRing(Rationals(),14);
A:=t^5+a3*t^3+a2*t^2+a1*t+a0;
B:=b4*t^4+b3*t^3+b2*t^2+b1*t+b0;
C:=c3*t^3+c2*t^2+c1*t+c0;
F:=A^2+B;
G:=A^3+3*A*B/2+C;
K:=F^3-G^2;
Y:=3*B^2-8*A*C;
S:=[Coefficient(Y,t,i) : i in [3..7]] cat [Coefficient(K,t,i) : i in [7..18]];
S:=Elim(S,c3,17); S:=Elim(S,c2,16); S:=Elim(S,c1,15); S:=Elim(S,c0,14);
T:=[clearit(s) : s in S | s ne 0];

_<A3,A2,A1,A0,B4,B3,B2,B1,B0>:=PolynomialRing(Integers(),9);
v:=[0,A3,A2,A1,A0,B4,B3,B2,B1,B0,0,0,0,0];
T:=[Evaluate(t,v): t in T];
// [[Degree(t,Parent(B0).i) : t in T] : i in [1..9]];

SetVerbose("Resultant",1);

// T[1];
// T[3];

time r := Resultant(T[1],T[3],A0); // both linear in A0
assert r eq
324*A3^5*B4^5*B3 + 324*A3^4*A2*B4^6 - 324*A3^4*B4^5*B1 - 972*A3^4*B4^4*B3*B2 -
    1188*A3^4*B4^3*B3^3 - 972*A3^3*A2*B4^5*B2 - 2214*A3^3*A2*B4^4*B3^2 +
    756*A3^3*B4^4*B3*B0 + 972*A3^3*B4^4*B2*B1 + 2484*A3^3*B4^3*B3^2*B1 +
    864*A3^3*B4^3*B3*B2^2 + 2052*A3^3*B4^2*B3^3*B2 - 216*A3^2*A2^2*B4^5*B3 +
    486*A3^2*A2*A1*B4^6 + 432*A3^2*A2*B4^5*B0 + 1296*A3^2*A2*B4^4*B3*B1 +
    864*A3^2*A2*B4^4*B2^2 + 3240*A3^2*A2*B4^3*B3^2*B2 + 1026*A3^2*A2*B4^2*B3^4 -
    324*A3^2*A1*B4^5*B1 - 540*A3^2*A1*B4^4*B3*B2 + 1620*A3^2*A1*B4^3*B3^3 +
    81*A3^2*B4^6*B3 - 324*A3^2*B4^4*B1*B0 - 648*A3^2*B4^3*B3*B2*B0 -
    1080*A3^2*B4^3*B3*B1^2 - 864*A3^2*B4^3*B2^2*B1 - 2052*A3^2*B4^2*B3^3*B0 -
    4212*A3^2*B4^2*B3^2*B2*B1 - 216*A3^2*B4^2*B3*B2^3 - 864*A3^2*B4*B3^3*B2^2 +
    540*A3*A2^3*B4^6 - 1512*A3*A2^2*B4^5*B1 + 216*A3*A2^2*B4^4*B3*B2 +
    864*A3*A2^2*B4^3*B3^3 - 1512*A3*A2*A1*B4^5*B2 + 972*A3*A2*A1*B4^4*B3^2 +
    216*A3*A2*B4^4*B2*B0 + 1188*A3*A2*B4^4*B1^2 - 1944*A3*A2*B4^3*B3^2*B0 -
    2160*A3*A2*B4^3*B3*B2*B1 - 216*A3*A2*B4^3*B2^3 - 1080*A3*A2*B4^2*B3^3*B1 -
    972*A3*A2*B4^2*B3^2*B2^2 - 864*A3*A2*B4*B3^4*B2 - 216*A3*A1*B4^4*B3*B0 +
    1080*A3*A1*B4^4*B2*B1 - 1728*A3*A1*B4^3*B3^2*B1 + 648*A3*A1*B4^3*B3*B2^2 -
    1296*A3*A1*B4^2*B3^3*B2 - 162*A3*B4^5*B3*B2 - 81*A3*B4^4*B3^3 +
    432*A3*B4^3*B3*B0^2 - 216*A3*B4^3*B1^3 + 2160*A3*B4^2*B3^2*B1*B0 -
    216*A3*B4^2*B3*B2^2*B0 + 1944*A3*B4^2*B3*B2*B1^2 + 216*A3*B4^2*B2^3*B1 +
    1728*A3*B4*B3^3*B2*B0 + 1728*A3*B4*B3^2*B2^2*B1 - 432*A2^3*B4^5*B2 -
    216*A2^3*B4^4*B3^2 - 648*A2^2*A1*B4^5*B3 + 432*A2^2*B4^4*B3*B0 +
    1296*A2^2*B4^4*B2*B1 + 432*A2^2*B4^3*B3^2*B1 - 432*A2^2*B4^2*B3^3*B2 -
    216*A2^2*B4*B3^5 + 216*A2*A1*B4^5*B0 + 1080*A2*A1*B4^4*B3*B1 +
    972*A2*A1*B4^4*B2^2 - 648*A2*A1*B4^2*B3^4 - 162*A2*B4^5*B3^2 +
    108*A2*B4^4*B0^2 - 864*A2*B4^3*B3*B1*B0 - 432*A2*B4^3*B2^2*B0 -
    1080*A2*B4^3*B2*B1^2 + 648*A2*B4^2*B3^2*B2*B0 - 108*A2*B4^2*B3^2*B1^2 +
    864*A2*B4^2*B3*B2^2*B1 + 864*A2*B4*B3^4*B0 + 864*A2*B4*B3^3*B2*B1 -
    216*A1^2*B4^5*B1 + 648*A1^2*B4^4*B3*B2 - 432*A1^2*B4^3*B3^3 - 81*A1*B4^6*B3
    + 216*A1*B4^4*B1*B0 - 1296*A1*B4^3*B3*B2*B0 - 216*A1*B4^3*B3*B1^2 -
    864*A1*B4^3*B2^2*B1 + 1296*A1*B4^2*B3^3*B0 + 1296*A1*B4^2*B3^2*B2*B1 +
    108*B4^5*B3*B0 - 54*B4^5*B2*B1 + 135*B4^4*B3^2*B1 + 54*B4^4*B3*B2^2 +
    432*B4^2*B3*B2*B0^2 + 216*B4^2*B3*B1^2*B0 + 432*B4^2*B2^2*B1*B0 +
    216*B4^2*B2*B1^3 - 864*B4*B3^3*B0^2 - 1728*B4*B3^2*B2*B1*B0 -
    864*B4*B3*B2^2*B1^2;

time r:=Resultant(T[5], T[6], A3);
assert Length(r) eq 11542;
assert Terms(r)[1 .. 10] eq
[
    -35769102336*A2^12*B4^16,
    266642399232*A2^11*B4^15*B1,
    13598171136*A2^11*B4^14*B3*B2,
    -101368184832*A2^11*B4^13*B3^3,
    137755385856*A2^10*A1*B4^15*B2,
    -69898899456*A2^10*A1*B4^14*B3^2,
    209293590528*A2^10*A0*B4^15*B3,
    -211658489856*A2^10*B4^14*B2*B0,
    -888019697664*A2^10*B4^14*B1^2,
    -13490675712*A2^10*B4^13*B3^2*B0
];




/*

> P<x,y>:=PolynomialRing(Integers(),2);
> Resultant(x*y,x,y);
x
> Resultant(x,x*y,y);
x
> Resultant(3*x,x*y,y);
3*x
> Resultant(3*x + 1,x*y,y);
3*x + 1
> Resultant(3*x + 1,x*y^2,y);
9*x^2 + 6*x + 1
> Resultant(-3*x + 1,x*y^2,y);
9*x^2 - 6*x + 1
> Resultant(-3*x + 1,x*y^2,y);
9*x^2 - 6*x + 1
> Resultant(-3*x + 1,-x*y^2,y);
9*x^2 - 6*x + 1
> Resultant(-x*y^2, -3*x+1, y);
9*x^2 - 6*x + 1
> Resultant(-x*y^2, -3*x+1, y);
9*x^2 - 6*x + 1
> Resultant(-x*y^2, -3*x+1, y);
9*x^2 - 6*x + 1
> Resultant(x, y, y);
x
> Resultant(y,x,y);
x
> Resultant(y^2,x,y);
x^2
> Resultant(x,y^2,y);
x^2

*/
