# Is it possible to align roots to plot consistently?

I made a routine to find roots of the equation for a specific range of input angle. For this model, usually total number of roots is 10, however at some angles total number of roots is 8. Because of this, a table with a list of roots has some rows misaligned roots. When plotting, I end up with zig-zagging line instead some curve. For this case, see row 11th for example. It has 8 roots. By looking at the numbers (see first column of the same row) , I can see 8th root should be 10th, 7th root should be 9th and 6th root should be 8th. And the empty columns for 11th row should be 6 and 7. Is it possible to do root finding thouroughly and alligned properly so that plot can be made consistently?

f[a_]:=Sin[a]*Cos[a]+Sin[a]*x^2-Cos[a]*x^4+(Sin[a]-Cos[a])*x^6-(Sin[2*a]-Cos[2*a])*x^8+(Sin[1*a]-Cos[1*a])*x^10;
roots = Table[x /. NSolve[f[angle] == 0], {angle, 0, 2*Pi, Pi/40}];
roots // TableForm


WolfMath V9

• similar to this I think.. mathematica.stackexchange.com/q/83906/2079 ( not exactly a dup but you may find something useful there ) Jun 19, 2017 at 15:51
• If you only need plots you might end run the issue by avoiding "special" values of angle that make coefficients exactly zero. For example make your table from 0.001,2 Pi , 0.05 Jun 19, 2017 at 16:00

f[a_] := Sin[a] Cos[a] + Sin[a] x^2 - Cos[a] x^4 + (Sin[a] - Cos[a]) x^6 -