3
$\begingroup$

I am doing some graphic of roots of the polynomial $f(x)=x^{18}-50x^5-1$. The roots are represented in the complex plane as in figure below:

enter image description here

To do that, I used the command

f[x_] :=x^18-50*x^5-1; ComplexListPlot[x /. Solve[f[x] == 0, x],PlotStyle -> PointSize[Large]]

However, I would like to colour (only) the $5$ inner points in red. Is it possible? Could you please help me?

Thanks in advance.

$\endgroup$

3 Answers 3

4
$\begingroup$
 f[x_] := x^18 - 50*x^5 - 1;

 ComplexListPlot[x /. Solve[f[x] == 0, x], 
  PlotStyle -> PointSize[Large], 
  ColorFunction -> (If[#4 <= .5, Red, Blue] &)] 

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you very much!!! $\endgroup$
    – Jean
    Feb 7, 2022 at 12:57
  • $\begingroup$ @Jean, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Feb 7, 2022 at 13:01
3
$\begingroup$

We can sort the roots by their Abs or Norm and color the first k points in red.

f[x_] = x^18 - 50*x^5 - 1;
 sol = SolveValues[f[x] == 0, x];
pts = SortBy[sol, Abs, NumericalOrder];
k = 5;
ComplexListPlot[{pts[[1 ;; k]], pts[[k + 1 ;; -1]]}, 
 PlotStyle -> {Red, Blue}]

enter image description here

$\endgroup$
2
$\begingroup$

Using RegionMember can be advantageous if a region definition is available.

sol = x /. Solve[f[x] == 0, x] // N
ptsA = ReIm /@ sol // N

Find the points from sol that are inside the region of interest:

pos = RegionMember[Disk[{0, 0}, 0.6], ptsA]
pts01 = Pick[sol, pos]

pts02 = Pick[sol, Not /@ pos]

Plot:

ComplexListPlot[{pts01, pts02}
 , PlotStyle -> {{AbsolutePointSize[8], Red}, {AbsolutePointSize[8], 
    Blue}}
 , Frame -> True
 , Prolog -> {Lighter@Green, Opacity[0.5], Disk[{0, 0}, 0.6]}
 ]

Result:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.