I'm working with generative polynomials, and would like to know if there is a faster way to calculate roots. Using the technique below I've managed to cut the time down significantly. However at n=35, it still takes about two and a half minutes to calculate roots. Does anyone know of any ways I could speed this up? The time per polynomial increases rather quickly, and I would like to be able to calculate up to n=50, and I do not have access to a very fast machine.
h = Compile[{{z, _Real}, {m, _Integer}},
Coefficient[Series[1/((1 + l t + z t^2)^2), {t, 0, m}], t^m]];
l = 6.0;
Do[{
roots = z /. {ToRules[Quiet[NRoots[h[z, n] == 0., z]]]},
Print[roots]
}, {n, 2, 35}]
h2[z_, n_] := Coefficient[ Sum[(-1)^k*Expand[(1 + l t + z t^2)^2 - 1]^k, {k, Ceiling[n/2], n}], t^n]
. That avoids theSeries
bottleneck. There are several other ways to do this, as shown in various responses. $\endgroup$