# Speed up MinimalPolynomial

My Mathematica code runs slowly

MinimalPolynomial[Sqrt[2] + Sqrt[3]+ Sqrt[5]+ Sqrt[7]+ Sqrt[11]+ Sqrt[13], x]


runs slowly, but the Maple version

evala(Norm(convert(x-(sqrt(2)+sqrt(3)+sqrt(5)+sqrt(7)+sqrt(11)+sqrt(13)), RootOf)));


runs quite fast Is there a faster way do this in Mathematica?

-
What is the answer in maple? – Apple Mar 29 '14 at 15:21

You're after the Swinnerton-Dyer Polynomials. Take a look and compare with OEIS (which, BTW cites our friend Roman E. Maeder. Programming in Mathematica, Addison-Wesley, 1990, page 105):

MinimalPolynomial[Sum[Sqrt[Prime[i]], {i, #}], x] & /@ Range@5


gives the same results shown in the OEIS page, but MinimalPolynomial can't calculate sixth term within a reasonable time frame.

So here are two ways of calculating the coefficients.The first one is from the OEIS page.

SwinnertonDyerP[0, x_] := x;
SwinnertonDyerP[n_, x_] :=
Module[{sd, srp = Sqrt[Prime[n]]},
sd[y_] = SwinnertonDyerP[n - 1, y];
Expand[sd[x + srp] sd[x - srp]]];
row[n_] := CoefficientList[SwinnertonDyerP[n, x], x^2];
row[6]


This second one was posted by @chyaong and then deleted after some criticism in comments:

s[n_] := Sum[x@i, {i, n}];
t[n_] := Table[x[i]^2 - Prime[i], {i, n}]
First@GroebnerBasis[Join[{s[#] - x}, t[#]], x, Array[x, #]] &@6


Here is the result:

-
The criticism might or might not have been misguided. That GroebnerBasis computation is a reasonable way to generate a Swinnerton-Dyer polynomial. It is not a way to generate a minimal polynomial in general. I guess I do not know which notion was intended. – Daniel Lichtblau Aug 19 '15 at 15:37
@DanielLichtblau Sorry for my lack of precision. I wasn't criticizing the critics, but just trying to explain to those with less than 10K rep (that can't see the deleted answer) that I'm copying a previously posted way. Your were right to be suspicious without further prove. – Dr. belisarius Aug 19 '15 at 16:21
Now that you mention, I notice the deleted response also has a down vote. While I had a comment to the effect that it was not a general method, I'm pretty sure the down vote was not mine (I wouldn't do that to a response given in good faith, as that one was). It's a tough crowd.. – Daniel Lichtblau Aug 19 '15 at 17:38