# plotting – Condense code to graph the roots of Littlewood polynomials

I am a newbie using Mathematica. I wrote this code to graph the roots of Littlewood polynomials, based on the structure of other programming languages. But I’m sure Mathematica has tools to do it in a more condensed and efficient way. Could you guide me how to do it?

``````poly(exp_, var_) :=
Times @@@ Tuples(var^Range(0, exp)) //
Tuples({1, -1}, Length@#).# &;

aux(num_) := lista((num));

pts = List();

For(i = 1, i < 15, i++, lista = poly({i}, {x});
For(j = 1, j < Length(lista) + 1, j++,
pts = Join(pts, ({Re(#1), Im(#1)} &) /@ (x /.
NSolve(aux(j) == 0, x)));
)
);

graphi = ListPlot(puntos,
PlotRange -> {{-2.2, 2.2}, {-2.2, 2.2}},
AspectRatio -> Automatic,
PlotStyle -> {PointSize(0.0000001),
Opacity(0.05),
Yellow
},
Axes -> False,
Background -> Black,
ImageSize -> 1000,
GridLines -> {{-2, -1, 0, 1, 2}, {-2, -1, 0, 1, 2}}
);

Export("/Animaciones/Littlewood/14.png", graphi);
``````

Use `aux(num_):=lista((num));` because `({Re(#1), Im(#1)} &) /@ (x /.NSolve(lista((j)) == 0, x))` gave me an error, and `pts=List();` to have an empty list. As seen in the first `For` this code generates the roots of the Littlewood polynomials with n = 14

Also, is it normal for Mathematica on Linux (ubuntu 20.04) to use only one thread at a time in its calculations? I think a lot of processing power is wasted.