11
$\begingroup$

Bug introduced in 11.2 or earlier and persisting through 12.2

I'm trying to visualize a simple conformal map using ParametricPlot.

    ParametricPlot[
    Through[{Re,Im}[1/(Exp[u+v I]+1)]],
         {u,-5,5},{v, 0, 2Pi},
       PlotRange->{{-2,2},{-2,2}},
       Mesh->{100,Round[100 2Pi/10]},Axes->False,ImageSize->Large,
       MeshShading->{{Yellow,Orange},{Pink,Red}}
   ]

The result I get has a big white 'tear' down the middle. As far as I can tell, this artifact is shaped as if it is a white region between two kissing large-radius circles. But I can't tell whether it's a limitation/bug in ParametricPlot or an abuse of ParametricPlot or something I'm not seeing in the math. What's going on? I've noticed that when I remove the constant term in the denominator the problem goes away.

I'm using the cloud based Wolfram Development Platform. When I use ParametricPlot3D for this, I don't get an artifact. Neither do I get an artifact if I just trace the individual grid lines.

conformal mapping

Update: We can demonstrate similar problems by using the simpler complex function 1/z. E.g.

ParametricPlot[
    ReIm[1/(u+v I)],
         {u,-5,5},{v, -5, 5},
       PlotRange->{{-2,2},{-2,2}},
       Mesh->100,Axes->False,ImageSize->Large,
       MeshShading->{{Yellow,Orange},{Pink,Red}}
   ]

or the equivalent

ParametricPlot[
    ReIm[(u-v I)/(u^2+v^2)] ,
         {u,-5,5},{v, -5, 5},
       PlotRange->{{-2,2},{-2,2}},
       Mesh->100,Axes->False,ImageSize->Large,
       MeshShading->{{Yellow,Orange},{Pink,Red}}
   ]

The former exhibits the tearing artifact, the latter has problems with mesh coloring.

$\endgroup$
4
  • 1
    $\begingroup$ You can try the option Exclusions -> None but I get something I can't explain, at least without putting in some work I don't have time for right now. $\endgroup$
    – Michael E2
    Commented Jan 29, 2018 at 4:08
  • $\begingroup$ Also, what "old ParametricPlot3D method"? Reference or code? $\endgroup$
    – Michael E2
    Commented Jan 29, 2018 at 4:09
  • 2
    $\begingroup$ Back in the day, before ParametricPlot could plot regions (as opposed to just curves), I would use ParametricPlot3D to plot a region (using 0 as the z coordinate, and VIewpoint->{0,0,Infinity}) $\endgroup$
    – brainjam
    Commented Jan 29, 2018 at 4:54
  • $\begingroup$ If someone knows more about the versions this affects, please update the bugs header (see the tag info for more). $\endgroup$
    – Michael E2
    Commented Jan 30, 2018 at 16:28

2 Answers 2

10
$\begingroup$

Update: A less kludgy workaround, which I thought I had already tried.

ParametricPlot[
 Evaluate@ Simplify@ ComplexExpand@ Through[{Re, Im}[1/(Exp[u + v I] + 1)]],
 {u, -5, 5}, {v, 0, 2 Pi},
 PlotRange -> {{-2, 2}, {-2, 2}}, Mesh -> {100, Round[100 2 Pi/10]}, 
 Axes -> False, ImageSize -> Large, 
 MeshShading -> {{Yellow, Orange}, {Pink, Red}}]

Mathematica graphics

Numerically checking this function with the OP's at a few points throughout the domain show they evaluate to the same numbers. I think this must be a bug.


Original workaround:

Show[
 ParametricPlot[
  Evaluate@ComplexExpand@Through[{Re, Im}[1/(Exp[u + v I] + 1)]],
  {u, -5, 5}, {v, Pi + 0.00001, 2 Pi},
  PlotRange -> {{-2, 2}, {-2, 2}}, 
  Mesh -> {100, Round[0.5 100 2 Pi/10]}, Axes -> False, 
  ImageSize -> Large, MeshShading -> {{Yellow, Orange}, {Pink, Red}}, 
  BoundaryStyle -> None],
 ParametricPlot[
  Evaluate@ComplexExpand@Through[{Re, Im}[1/(Exp[u + v I] + 1)]],
  {u, -5, 5}, {v, 0, Pi}, 
  PlotRange -> {{-2, 2}, {-2, 2}}, 
  Mesh -> {100, Round[0.5 100 2 Pi/10]}, Axes -> False, 
  ImageSize -> Large, MeshShading -> {{Yellow, Orange}, {Pink, Red}}]
 ]
$\endgroup$
8
  • $\begingroup$ Do you think ParametricPlot has a bug? For now I'd probably rather retreat to ParametricPlot3D where I don't have to fight this. $\endgroup$
    – brainjam
    Commented Jan 29, 2018 at 5:33
  • $\begingroup$ Something like ParametricPlot3D[ { Re[1/(Exp[u + v I] + 1)], Im[1/(Exp[u + v I] + 1)], 0}, {u,-5,5},{v,0,2Pi}, PlotRange->{{-2,2},{-2,2},{-.05,.05}}, PlotPoints->{40,40},ViewPoint->{0,0,Infinity}, Mesh->{100,Round[100 2Pi/10]},BoundaryStyle->Automatic, ImageSize -> Large] $\endgroup$
    – brainjam
    Commented Jan 29, 2018 at 5:34
  • $\begingroup$ @brainjam I can't see any explanation except that it's a bug. You should report it to WRI support. $\endgroup$
    – Michael E2
    Commented Jan 29, 2018 at 12:40
  • 1
    $\begingroup$ The bug has been reported and reproduced/acknowledged (very speedy response from WRI, I'm impressed to say). $\endgroup$
    – brainjam
    Commented Jan 30, 2018 at 14:40
  • 1
    $\begingroup$ @BobHanlon, thanks, I found that out from @J.M.'s answer. I got the Through[{Re,Im}][ ] construction from the Wolfram docs on conformal mapping. Now I use ReIm. $\endgroup$
    – brainjam
    Commented Jan 30, 2018 at 21:17
4
$\begingroup$

Here is a workaround that hinges on the built-in LogisticSigmoid[] function:

ParametricPlot[ReIm[LogisticSigmoid[-u - I v]], {u, -5, 5}, {v, 0, 2 Pi}, 
               PlotRange -> 2, Mesh -> {100, Round[100 2 Pi/10]}, Axes -> False, 
               ImageSize -> Large, MeshShading -> {{Yellow, Orange}, {Pink, Red}}]

correct conformal map

That the behavior in the OP is a clear bug can be demonstrated by expanding out the LogisticSigmoid[] function:

ParametricPlot[ReIm[LogisticSigmoid[-u - I v]] // FunctionExpand // Evaluate,
               {u, -5, 5}, {v, 0, 2 Pi}, PlotRange -> 2, Mesh -> {100, Round[100 2 Pi/10]},
               Axes -> False, ImageSize -> Large,
               MeshShading -> {{Yellow, Orange}, {Pink, Red}}]

and the erroneous plot in the OP is reproduced.

$\endgroup$
10
  • $\begingroup$ For whatever reason when I run the first piece code I get this: i.sstatic.net/MoQbA.png $\endgroup$
    – b3m2a1
    Commented Jan 30, 2018 at 5:52
  • $\begingroup$ What version and OS did you use? This seems to work for 11.2. $\endgroup$ Commented Jan 30, 2018 at 6:25
  • $\begingroup$ Mac 10.13.2; Mathematica 11.2 $\endgroup$
    – b3m2a1
    Commented Jan 30, 2018 at 6:28
  • $\begingroup$ For what it's worth, the function I gave is a simplified version of the functions I was working with, and only coincidentally equal to LogisticSigmoid[] (although I appreciate that it's used here not so much as a workaround than as a demonstration of a bug). I've now found that the bug occurs for functions as simple as 1/z (where z is complex). I have a feeling it has something to do with an expression that may have a divide by zero. Meanwhile, I'm happy to discover from this answer that there is ReIm function which can replace the Through[{Re,Im}[]] construction. $\endgroup$
    – brainjam
    Commented Jan 30, 2018 at 14:35
  • 3
    $\begingroup$ Nice to see you again! $\endgroup$
    – Michael E2
    Commented Jan 30, 2018 at 16:29

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.