I have the following function:

B[z_]=((z*(z – 0.5)*(z + 0.5))/((1 – 0.5*z)*(1+0.5*z)))

I want to plot the roots this polynomial according to angel like below the picture with Mathematica.

=================

1

this polynomial Which one? The one on the top or the one in the bottom?

– Nasser

Jun 16 ’14 at 7:16

Are you expecting all the roots to be unitary (|z|= 1) ? Otherwise they cannot be points lying on the unit circle

– mastrok

Jun 16 ’14 at 7:31

This question is written wrong by me. I want to plot the roots B(z)=1. I know that the roots of this equation on the unit disc

– user2444

Jun 16 ’14 at 7:40

@embla please edit your question if it’s not what you intended. Flagging a moderator to delete when there are already upvoted answers is not fair on the people who worked on those answers.

– Verbeia♦

Jun 18 ’14 at 11:20

=================

4 Answers

4

=================

I post this exploration just for fun. Setup:

B[z_] := ((z*(z – 0.5)*(z + 0.5))/((1 – 0.5*z)*(1 + 0.5*z)))

sol = Quiet[{Re[#], Im[#], 0} & /@ (z /. Solve[B[z] == 1, z])];

sol2 = Quiet[{Re[#], Im[#]} & /@ (z /. Solve[B[z] == 1, z])];

Visualizing:

Show[Plot3D[Abs[B[x + I y]] – 1, {x, -3, 3}, {y, -3, 3},

MeshFunctions -> (Abs[B[#1 + I #2]] – 1 &), Mesh -> {{0}}],

Graphics3D[{{Red, Point[sol]}, {FaceForm[None], Polygon[sol]}}]]

The mesh is the unit circle, the red points are the roots of the rational function.

In 2D:

ContourPlot[Abs[B[x + I y]] == 1, {x, -3, 3}, {y, -3, 3},

Epilog -> {{Red, Point[sol2]}, {EdgeForm[Black], FaceForm[None],

Polygon[sol2]}}, GridLines -> {{0}, {0}}]

A “prettier” version:

ContourPlot[Log[1 + Abs[B[x + I y] – 1]], {x, -3, 3}, {y, -3, 3},

Contours -> 200, ContourLines -> False,

ColorFunction -> “BrassTones”,

Epilog -> {{Red, Point[sol2]}, {EdgeForm[Black], FaceForm[None],

Polygon[sol2]}}, GridLines -> {{0}, {0}}]

Showing the zeroes and poles in 3D (using Abs[B[z]-1]):

Show[Plot3D[Abs[B[x + I y] – 1], {x, -3, 3}, {y, -3, 3},

MeshFunctions -> {(Abs[B[#1 + I #2]] – 1 &),

Abs[B[#1 + #2 I] – 1] &}, Mesh -> {{0}, 10},

MeshStyle -> {Red, Black}],

Graphics3D[{{Red, Point[sol]}, {FaceForm[None], Polygon[sol]}}]]

Anyway we neglect poles points. Most important thing for us, these lines merging points must not intersect with another. To obtain this aim, we can draw these lines in anti-clockwise for example when B[z_] = ((z*(z – 0.5)*(z + 0.5)*(z + 0.3))/((1 – 0.5*z)*(1 + 0.5*z)*(1 + 0.3*z))), what will we do?

– user2444

Jun 16 ’14 at 12:37

I want to plot the roots B(z)=1. I know that the roots of this equation on the unit disc

How about this:

ClearAll[z]

b = ((z*(z – 0.5)*(z + 0.5))/((1 – 0.5*z)*(1 + 0.5*z)))

sol = z /. NSolve[b == 1, z];

data = {Re[#], Im[#]} & /@ sol;

Graphics[

{

Circle[{0, 0}, 1],

First@ListPlot[data, PlotStyle -> Directive[Red, PointSize[.03]]],

Arrow[{{0, 0}, #} & /@ data]

}, Axes -> True

]

update: to add line between each point:

ClearAll[z]

b = ((z*(z – 0.5)*(z + 0.5))/((1 – 0.5*z)*(1 + 0.5*z)))

sol = z /. NSolve[b == 1, z];

data = {Re[#], Im[#]} & /@ sol;

Graphics[

{

Circle[{0, 0}, 1],

First@ListPlot[data, PlotStyle -> Directive[Red, PointSize[.03]]],

Line[Join[data, {First@data}]]

}, Axes -> True

]

Update

For many more roots, to display by angle order:

roots = RandomReal[{-1, 1}, {6, 2}]; (*these from above,roots using NDSolve*)

data = Sort[Thread[ArcTan[#1, #2]] & @@@ roots](*sort by angle*)

data = {Cos[#], Sin[#]} & /@ data;(*build x,y,now sorted*)

p = ListPlot[Tooltip[#, #] & /@ data, PlotStyle -> Directive[Red, PointSize[.03]]];

Graphics[

{

Circle[{0, 0}, 1],

Line[Join[data, {First@data}]],

First@p (*keep last one, for Tooltip to work*)

}, Axes -> True

]

Is this what you mean?

I have done it before but I couldnt merge these points according to argument small to large. For example in this algorithm, the point z=-0.625 + 0.780625i the point with z=1 must be combine, similarly the point -0.625 + 0.780625i with the point z= -0.625 – 0.780625i. In other words, triangle be there.

– user2444

Jun 16 ’14 at 9:03

So you just want a line added to join the 3 points? ok, will add that. see if this what you mean.

– Nasser

Jun 16 ’14 at 9:09

After rearranging argument of data small to large, can we draw these lines in anti-clockwise? There isnt any problem this example but if we have 4 points, these lines will intersect each other.

– user2444

Jun 16 ’14 at 12:02

1

Sure. You can sort first. Sorting the numbers by the angle will do it. Posting example…

– Nasser

Jun 16 ’14 at 16:17

Since the OP’s graphic appears to also show the poles I would add those

B[z_] = ((z*(z – 0.5)*(z + 0.5))/

((1 – 0.5*z)*(1 + 0.5*z))) //

Rationalize[#, 0] & // Simplify;

roots = {Re[z], Im[z]} /.

Solve[B[z] == 1, z];

poles = {Re[z], Im[z]} /.

Solve[Denominator[B[z]] == 0, z];

Graphics[{AbsolutePointSize[8],

{Lighter[Gray], Circle[]},

{Blue, Line[Join[roots, {roots[[1]]}]],

Tooltip[Point[#], #] & /@ roots},

{Red, Tooltip[Point[#], #] & /@ poles}},

Frame -> True,

FrameLabel -> {“Re[z]”, “Im[z]”},

PlotLabel -> (“Roots of ” <>

ToString[B[z] == 1, TraditionalForm] <> “\n”)]

For more complicated cases to avoid crossing lines use ListCurvePathPlot (new in v7)

B[z_] = ((z*(z – 0.5)*(z + 0.5)*(z + 0.3))/

((1 – 0.5*z)*(1 + 0.5*z)*(1 + 0.3*z))) //

Rationalize[#, 0] & // FullSimplify;

roots = {Re[z], Im[z]} /.

Solve[B[z] == 1, z];

poles = {Re[z], Im[z]} /.

Solve[Denominator[B[z]] == 0, z];

Graphics[{AbsolutePointSize[8],

{Lighter[Gray], Circle[]},

{Blue, Tooltip[Point[#], #] & /@ roots},

First@ListCurvePathPlot[roots, PlotStyle -> Blue],

{Red, Tooltip[Point[#], #] & /@ poles}},

Frame -> True,

FrameLabel -> {“Re[z]”, “Im[z]”},

PlotLabel -> (“Roots of ” <>

ToString[B[z] == 1, TraditionalForm] <> “\n”)]

Anyway we neglect poles points. Most important thing for us, these lines merging points must not intersect with another. To obtain this aim, we can draw these lines in anti-clockwise for example when B[z_] = ((z*(z – 0.5)*(z + 0.5)*(z + 0.3))/((1 – 0.5*z)*(1 + 0.5*z)*(1 + 0.3*z))), what will we do?

– user2444

Jun 16 ’14 at 12:41

2

@embla For more complicated cases to avoid crossing lines use ListCurvePathPlot (new in v7). See above

– Bob Hanlon

Jun 16 ’14 at 13:05

Mathematica loves to work with complex numbers–except when it comes to graphing! Adopting the principle that what starts as complex should stay as complex, we may directly graph the complex roots without splitting each into its real and imaginary parts. To do that, we employ David Park’s Presentations add-on (http://home.comcast.net/~djmpark/DrawGraphicsPage.html).

b[z_] := z (z – 0.5) (z + 0.5)/((1 – 0.5 z) (1 + 0.5 z));

solns = z /. NSolve[b[z] == 1, z];

<< Presentations` Draw2D[{ ComplexCircle[0, 1], Blue, ComplexLine[Append[solns, First@solns]], Red, PointSize[0.035], ComplexPoint /@ solns }, Axes -> True]

For a somewhat fancier graphic that includes tooltips showing the exact values of the roots, begin by rationalizing the given function and computing the roots exactly:

solns = z /. Solve[Rationalize[b[z]] == 1, z];

Draw2D[{

Dashed, ComplexCircle[0, 1],

Dashing[{}], Blue, ComplexLine[Append[solns, First@solns]],

Red, Thickness[0.008],

Map[

Through[Tooltip[ComplexCirclePoint[#, 5, Brown, LightGreen]&, Identity][#]] &,

solns]

},

Axes -> True, Background -> Legacy@Linen]