Confirmed Bug: Why does Eliminate fail while Solve succeeds?

OP EDIT: Wolfram Technical Support got back to me and confirmed this is a bug. But the Answers below provided good workarounds.

I have two polynomials respectively in {z,c} and in {r,z,c}. I'd like to eliminate z and get a tidy expression in {r,c}. For some reason, Eliminate[] never completes this simple task, while Solve[] quickly succeeds at the harder task of finding r as a function of c. But the Solve[] result is messy, so I'd like to know how to get just Eliminate[] to work.

Edit: I believe the solution should be a fairly simply polynomial in {r,c}.

The first three lines of code just generate and display my two polynomials.

w[n_, z_, c_] := If[n > 0, w[n - 1, z, c]^2 + c, z];
p1 = PolynomialQuotient[w[4, z, c] - z, w[2, z, c] - z, z]
p2 = 2^4; Do[p2 = p2*w[i, z, c], {i, 0, 3}]; p2
Solve[{p1 == 0, p2 == r}, r, {z}]
Eliminate[{p1 == 0, p2 == r}, {z}]

• Are you looking for real solutions? – Ulrich Neumann Jul 28 '19 at 8:24
• @UlrichNeumann No, all of the variables are complex. I'm hoping for a polynomial in {r,c} simpler than the expression for r(c) that Solve[] returned. – Jerry Guern Jul 28 '19 at 8:39

I'm not sure what the hang-up for Eliminate[] is. This is fast:

GroebnerBasis[{p1, p2 - r}, {c, r}, {z}]
(*
{4096 + 8192 c^2 + 12288 c^3 + 12288 c^4 + 12288 c^5 + 4096 c^6 -
768 r - 256 c^2 r + 256 c^3 r + 256 c^4 r + 48 r^2 - 16 c^2 r^2 - r^3}
*)

• Yep, that does exactly what I wanted. Thank you. I didn't know that function existed. Do more current versions of MMa also hang up when you use Eliminate[]? Might this be a bug? – Jerry Guern Jul 28 '19 at 18:16
• @JerryGuern I'm using V12 and it hangs. I don't know about other versions. – Michael E2 Jul 28 '19 at 18:17
• Wolfram Tech Support confirmed it's a bug in Eliminate[], but this workaround was perfect. – Jerry Guern Aug 10 '19 at 2:33

I offer the following approach. Let

soln = Solve[{p1 == 0, p2 == r}, r, {z}]


Then find the polynomial that has these roots:

0 == Times @@ ((r - Last[#]) & /@ Flatten[soln]) //
Collect[#, r, Simplify] &
(* 0 == -4096 (1 + 2 c^2 + 3 c^3 + 3 c^4 + 3 c^5 + c^6) -
256 (-3 - c^2 + c^3 + c^4) r + 16 (-3 + c^2) r^2 + r^3 *)

• A bit ghetto but clever and effective! Thank you. I'd still like to know what's wrong with Eliminate[] though. – Jerry Guern Jul 28 '19 at 18:10

It is not necessary to solve for r!

Elimination of z:

solz== Solve[p2 == 0, z]
(*{{z -> 0}, {z -> -Sqrt[-Sqrt[-Sqrt[-c] - c] - c]}, {z -> Sqrt[-Sqrt[-Sqrt[-c] - c] - c]}, ...}*)


gives 15 solutions z[c]

Complex Solutions (15! ) r[c] follow to

r=p1 /. solz // FullSimplify
(*{1 + c^2 (1 + c) (2 + c) (1 + c^2),1 + Sqrt[-Sqrt[-Sqrt[-c] - c] - c] Sqrt[-Sqrt[-c] - c] +Sqrt[-Sqrt[-c] - c] Sqrt[-c],
1 - Sqrt[-Sqrt[-Sqrt[-c] - c] - c] Sqrt[-Sqrt[-c] - c] +Sqrt[-Sqrt[-c] - c] Sqrt[-c],...*)


Perhaps the first result is the simple polynomial solution you're looking for!

Further evaluation needs knowledge about parameter c!

• No, p2 has to equal r. – Jerry Guern Jul 28 '19 at 8:16
• Sorry, my fault... – Ulrich Neumann Jul 28 '19 at 8:19