4
$\begingroup$

I would like to visualize the principal complex logarithm: $f(z)=Log(z)$. I have the following code

Table[ParametricPlot[
  With[{z = u + I v}, {Re[Log[z]], Im[Log[z]]}], {u, -10, 10}, {v, n, 
   10}, PlotRange -> {{-2, 4}, {-0.5, 3.5}}, Mesh -> Automatic, 
  ImageSize -> 300], {n, 0.1, 1.6, 0.5}]

with the result enter image description here

One can see that when the absolute value of the imaginary part is small, the result is far from precise. However, if plot only the image of a single line, it works perfectly well:

ParametricPlot[
 With[{z = u + I 0.1}, {Re[Log[z]], Im[Log[z]]}], {u, -10, 10}, 
 PlotRange -> {{-3, 4}, {-0.5, 3.5}}, Mesh -> Automatic, 
 ImageSize -> 300]

enter image description here

Is there a simple way to fix the first code?

$\endgroup$
3
  • 5
    $\begingroup$ Increase PlotPoints. Try PlotPoints -> 50. $\endgroup$ Commented Sep 17, 2017 at 15:36
  • $\begingroup$ @b3m2a1: that works, thanks! $\endgroup$ Commented Sep 17, 2017 at 15:45
  • 2
    $\begingroup$ Related: demonstrations.wolfram.com/ComplexSlideRule $\endgroup$ Commented Sep 17, 2017 at 15:58

2 Answers 2

3
$\begingroup$

You can do it by using more plot points. I find it takes about 100. Like so.

Column[
  Table[
    ParametricPlot[ReIm[Log[u + I v]], {u, -10, 10}, {v, n, 10}, 
      PlotRange -> {{-2.5, 4}, {-0.5, 3.5}},
      PlotPoints -> 100,
      Mesh -> Automatic,
      ImageSize -> 300],
    {n, 0.1, 1.6, 0.5}]]

plots

Note the simplification of your code.

$\endgroup$
1
  • $\begingroup$ I like the "simplification" part. Thanks! $\endgroup$ Commented Sep 17, 2017 at 15:55
3
$\begingroup$

Thanks to @b3m2a1's comment, I see that one way to fix it is increasing PlotPoints:

Table[ParametricPlot[
  With[{z = u + I v}, {Re[Log[z]], Im[Log[z]]}], {u, -10, 10}, {v, n, 
   10}, PlotRange -> {{-3, 4}, {-0.5, 3.5}}, Mesh -> Automatic, 
  PlotPoints -> 600, ImageSize -> 300], {n, 0.1, 1.6, 0.5}]

which takes a while to run: enter image description here

Alternatively, one may use Show:

Show[Table[
  ParametricPlot[
   With[{z = u + I v}, {Re[Log[z]], Im[Log[z]]}], {u, -10, 10},
   PlotRange -> {{-3, 4}, {-0.5, 3.5}}, Mesh -> Automatic, 
   ImageSize -> 300], {v, 0.1, 10, 0.2}]]

which gives a slightly different result:
enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ If you want the mesh to look more like the last one: ParametricPlot[ReIm[Log[u + I v]], {u, -10, 10}, {v, 1/10, 10}, Axes -> None, Mesh -> Automatic, MeshStyle -> Append[ColorData[97, 1], 1], PlotPoints -> 145, PlotRange -> {{-2.5, 4}, {-0.5, 3.5}}, PlotStyle -> None] $\endgroup$ Commented Sep 17, 2017 at 16:04