9
$\begingroup$

This stuff always trips me up. I'm trying to plot a function and I think that the plot looks good in one region and isn't really what I'm expecting in another:enter image description here The right side of the plot is what I am expecting but the lines cut off on the left side. What is the way to ensure that the correct branch of the square root is taken to ensure the lines do not get cut off? Or is there a different mistake I am making?

Block[{f, \[Lambda], l},
 l = 2;
 \[Lambda] = 2.0;
 f[z_] := (1 + \[Lambda])/(2 z) (z + 1) (z + 1 + 
      Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1;
 {ComplexContourPlot[ReIm[z], {z, -l - l I, l + l I}, PlotLabel -> z, 
   Contours -> 20],
  Show[ComplexContourPlot[ReIm[f[z]], {z, -l - l I, l + l I}, 
    PlotLabel -> f[z], Contours -> 20],
    Graphics[Circle[]]],
  Show[ComplexPlot[f[z], {z, -l - l I, l + l I}, PlotLabel -> f[z]],
    Graphics[Circle[]]]}
 ]
$\endgroup$
2
  • $\begingroup$ Reduce[FunctionSingularities[f[z], z, Complexes], z] shows you have branch discontinuities along two rays (and a pole). If a point continuously moving in the domain goes around one of the two branch points z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda]) == 0, the function value changes discontinuously. To get the function value to change continuously, you have to change the sign on the Sqrt[]. But as the point goes around again or goes around the other point, you have to change the sign again. There is no way to choose the sign to get rid of the discontinuity if you show just one branch. $\endgroup$
    – Michael E2
    May 14 at 18:35
  • $\begingroup$ This might illustrate the discontinuity better: Contours -> {Union[Range[-10, 11], Range[-1, 1, 1/16]]}. It does not fix your problem. $\endgroup$
    – Michael E2
    May 14 at 18:36

2 Answers 2

5
$\begingroup$

Maybe this shows what is desired:

Sheet #1:

Block[{f, g, \[Lambda], l},
 l = 2;
 \[Lambda] = 2;
 f[z_] := 
  ConditionalExpression[#, Abs[z] < 1 || Re[z] > -1/3] & /@ 
   ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 - 
        Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
 g[z_] := 
  ConditionalExpression[#, Abs[z] > 1 && Re[z] < -1/3] & /@ 
   ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 + 
        Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
 Show[ComplexContourPlot[
   Evaluate@Flatten@{f[z], g[z]}, {z, -l - l I, l + l I}, 
   Contours -> {Range[-1., 1, 1/16]; 20}, 
   PlotRange -> {{-l, l}, {-l, l}, {-1, 1}}],
  Graphics[Circle[]],
  ComplexContourPlot[
   z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda]) // 
    ReIm, {z, -l - l I, l + l I}, ContourStyle -> {Purple, Red}, 
   Contours -> {{0}}]]]

enter image description here

Sheet #2:

Block[{f, g, \[Lambda], l},
 l = 2;
 \[Lambda] = 2;
 f[z_] := 
  ConditionalExpression[#, Abs[z] > 1 && Re[z] < -1/3] & /@ 
   ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 - 
        Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
 g[z_] := 
  ConditionalExpression[#, Abs[z] < 1 || Re[z] > -1/3] & /@ 
   ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 + 
        Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
 Show[ComplexContourPlot[
   Evaluate@{f[z], g[z]}, {z, -l - l I, l + l I}, 
   Contours -> {Range[-10, 11, 1/2]}, 
   PlotRange -> {{-l, l}, {-l, l}, {-10, 11}}],
  Graphics[Circle[]],
  ComplexContourPlot[
   z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda]) // 
    ReIm, {z, -l - l I, l + l I}, ContourStyle -> {Purple, Red}, 
   Contours -> {{0}}]]]

enter image description here

I added a red/purple plot to highlight the branch points. The branch cuts run along the vertical red line, outside the circle.

$\endgroup$
2
  • $\begingroup$ Super cool, thank you! Indeed the plot #2 is the one I was looking for. $\endgroup$
    – Diffycue
    May 14 at 19:15
  • $\begingroup$ @Diffycue You're welcome. Note that it only masks the discontinuities I mentioned in the comments. You might want to inspect the tooltip values on the contour plot to make sure it is what you need. $\endgroup$
    – Michael E2
    May 14 at 19:24
1
$\begingroup$

A minor generalization of Michael E2's excellent answer, just to show the final result (I solve for the vertical cut so that $\lambda$ can vary)

Block[{f, g, \[Lambda], l, root},
  l = 2;
  \[Lambda] = 0.25;
  root = 
   z /. FindRoot[
     Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])], {z, 1.0}];
  f[z_] := 
   ConditionalExpression[#, Abs[z] > 1 && Re[z] < root] & /@ 
    ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 - 
         Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
  g[z_] := 
   ConditionalExpression[#, Abs[z] < 1 || Re[z] > root] & /@ 
    ReIm[(1 + \[Lambda])/(2 z) (z + 1) (z + 1 + 
         Sqrt[z^2 + 1 - 2 z (1 - \[Lambda])/(1 + \[Lambda])]) - 1];
  Show[ComplexContourPlot[{f[z], g[z]}, {z, -l - l I, l + l I}, 
    Contours -> {Range[-10, 11, 1/8]}, 
    PlotRange -> {{-l, l}, {-l, l}, {-10, 11}},
        ContourStyle -> Black,
        Exclusions -> Function[{z, f}, 1 < Abs[z]],
        PlotPoints -> 75], Graphics[Circle[]],
    Graphics[Disk[]]
   ]
  ] // Quiet

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ Now that I see the intended use, I can suggest f[z_] := (1 + λ)/(2) (z + 1) ((z + 1)/z + Sqrt[(z^2 + 1 - 2 z (1 - λ)/(1 + λ))/z^2]) - 1, which moves the branch cut inside the disk. $\endgroup$
    – Michael E2
    May 14 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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