1
$\begingroup$

This notebook again is useful to see in a 3D plot of the complex log function :

  • the principal branch
  • the branches

For this purpose, I downloaded the notebook from http://mathworld.wolfram.com/notebooks/ComplexAnalysis/PrincipalBranch.nb.

I also downloaded the Utilities`Typesetting` package of Eric Weisstein First, it goes wrong to see the "branches" in a 3D plot and then it goes wrong with the "principal(branch)" 3D plot. I start with the branches calculation.

<< Utilities`Typesetting`

branches = 
 Show[Graphics3D[
                 ParametricPlot3D[
                                 Evaluate[
 Table[{r Cos[θ], r Sin[θ], 
 Im[Log[r Exp[I θ]]] + 2 Pi k}, {k, -1, 1}]], {r, .01, 
 1}, {θ, 0, 2 π},
 DisplayFunction -> Identity,
 PlotPoints -> {4, 25}][[1]] /. 
 Polygon[x_] :> 
 If[Max[z = Last /@ x] - Min[z] > .5, 
 Polygon[Join[# - {0, 0, 2 Pi} & /@ Take[x, 2], Take[x, -2]]], 
 Polygon[x]]],
 Axes -> Automatic,
 AxesLabel -> TraditionalForm /@ {x, y, HoldForm[Im[Log[z]]]},
 AxesEdge -> {{-1, -1}, {1, -1}, {1, 1}},
 BoxRatios -> {1, 1, 1},
 PlotLabel -> 
 StyleForm["multiple branches", FontSlant -> "Italic", 
 FontFamily -> "Times"],
 PlotRange -> {-10, 10}]

Note: don't know yet how to write the code here in a programmer style

$\endgroup$
7
  • 1
    $\begingroup$ Does Normal@ParametricPlot3D[ Evaluate[ Table[{r Cos[\[Theta]], r Sin[\[Theta]], Im[Log[r Exp[I \[Theta]]]] + 2 Pi k}, {k, -1, 1}]], {r, .01, 1}, {\[Theta], 0, 2 \[Pi]}, DisplayFunction -> Identity, PlotPoints -> {4, 25}] /. Polygon[x_] :> If[Max[z = Last /@ x] - Min[z] > .5, Polygon[Join[# - {0, 0, 2 Pi} & /@ Take[x, 2], Take[x, -2]]], Polygon[x]] help? Nothing in your code relies on non-System` functions. GraphicsComplex was introduced in V6 and plotters were changed to use it. $\endgroup$
    – Michael E2
    Feb 18 at 15:21
  • $\begingroup$ @Michael E2, thanks, yes its a spiral The sentence : Nothing in your code relies on non-System` functions. ?, Please clarify this . $\endgroup$
    – janhardo
    Feb 18 at 19:51
  • $\begingroup$ Look up Context and related tutorials. Your question points to a different context than System but your code does not use it $\endgroup$
    – Michael E2
    Feb 18 at 20:24
  • $\begingroup$ @ Michael E2 , i am sorry but i am lost here $\endgroup$
    – janhardo
    Feb 18 at 20:54
  • 1
    $\begingroup$ Read this, reference.wolfram.com/language/tutorial/…, and the sections following it, or read the whole thing. I don't know where to begin explaining except to repeat what's in the docs. You will need to spend a little time learning about such things if you want to understand what depends on a package and what does not. $\endgroup$
    – Michael E2
    Feb 18 at 21:23

2 Answers 2

5
$\begingroup$

That's old, unnecessarilly-complex code. Start with: $$ \begin{align} \log(z)&=\ln|z|+i\arg(z) \\ &=\ln|z|+i\left[\text{Arg}(z)+2 k\pi\right];\quad -\pi\lt\text{Arg}(z)\leq \pi \end{align} $$ $\ln|z|$ is the single-valued real component but $\arg(z)$ is the multivalued imaginary component. $k=0$ is the principal branch of the imgainary component. Simpler code to plot branching $k=0,1,2$:

f[z_, k_] = Log[Abs[z]] + I (Arg[z] + 2 k Pi)
realPlot = 
  ParametricPlot3D[{Re[z], Im[z], Re[f[z, 0]]} /. z -> r Exp[I t], {r,
     0.001, 1}, {t, -Pi, Pi}, PlotLabel -> Style["Real Sheet", 16]];
colors = {Red, Blue, Green};
imagPlotList = Table[
   ParametricPlot3D[{Re[z], Im[z], Im[f[z, i - 1]]} /. 
     z -> r Exp[I t], {r, 0.001, 1}, {t, -Pi, Pi}, 
    PlotStyle -> colors[[i]]],
   {i, 1, 3}
   ];
imagPlot = 
  Show[imagPlotList, PlotRange -> All, BoxRatios -> {1, 1, 1}, 
   PlotLabel -> Style["Imag sheets", 16]];
GraphicsRow[{realPlot, imagPlot}]

enter image description here

$\endgroup$
5
  • $\begingroup$ thanks your code ,looks simpler in function notation ,then the original code from Eric Weisstein. Do have also a notebook "Riemann Surface" from Eric Weisstein, but there are the surfaces not so easy to define as a function. $\endgroup$
    – janhardo
    Feb 18 at 19:30
  • $\begingroup$ It is a simple one this boxplot Points of improvement can be -naming the axes -be able to rotate - indicate the distance between the branches - maybe interactive ? Interesting is also the functionality of geogebra program to experiment in Complex analysis Can this also be done in MMA? See: complex-analysis.com geogebra.org/m/rsqxtq9t ( interesting) $\endgroup$
    – janhardo
    Feb 18 at 20:49
  • $\begingroup$ Oops.. i found rotate finally : doubleclick $\endgroup$
    – janhardo
    Feb 18 at 21:35
  • $\begingroup$ @janhardo: I looked at RiemannSurface.nb. Eric is using an obsolete 3D viewer before Mathematica included a built-in interactive 3D viewer called LiveGraphics3D. In RiemannSurface.nb, remove the line << UtilitiesLiveGraphics3D and then remove the WriteLiveForm construct around all the plot routines. For example, for the first example in the notebook, after executing the first two commands, execute: ParametricPlot3D[Evaluate[{r, i, v}], {u, -6, 2}, {v, -5, 5}, PlotPoints -> {18, 32}, Ticks -> None, BoxRatios -> {1, 1, 2}] $\endgroup$
    – josh
    Feb 18 at 22:07
  • $\begingroup$ Also, just noticed his second example in RiemannSurface.nb is not working. Again, it's unnecessarilly-complex and general code. There are easier ways to generate specific Riemann surfaces. $\endgroup$
    – josh
    Feb 18 at 22:13
1
$\begingroup$

Eric's code includes a replacement /. Polygon[x_] :> … because there's no Exclusions option in v5.2. Nowadays the code can be simplified to

ParametricPlot3D[
 Evaluate@Table[{r Cos[θ], r Sin[θ], Im[Log[r Exp[I θ]]] + 2 Pi k}, {k, -1, 1}], 
                {r, .01, 1}, {θ, 0, 2 π}, BoxRatios -> {1, 1, 1}]

Mathematica graphics

ParametricPlot3D[{r Cos[θ], r Sin[θ], Im[Log[r Exp[I θ]]]}, 
                 {r, .01, 1}, {θ, 0, 2 π},
                 BoxRatios -> {1, 1, 1}, 
                 PlotRange -> {Automatic, Automatic, {-10, 10}}]

Mathematica graphics

For comparison, The followings are outputs in v5.2:

enter image description here

enter image description here

Just for fun, the following is a "quick" fix based on the logic of Eric's code, notice I've forced Exclusions to be None:

branches = Show[
  Graphics3D[Normal@
      ParametricPlot3D[
        Evaluate[Table[{r Cos[θ], r Sin[θ], 
           Im[Log[r Exp[I θ]]] + 2 Pi k}, {k, -1, 1}]], {r, .01, 1}, {θ, 0,
          2 π}, PlotPoints -> {4, 25}, Exclusions -> None][[1]] /. 
     Line[pts_] :> Line[Split[pts, Abs@Last[#2 - #1] < Pi &]] /. 
    Polygon[x_, opt__] :> 
     If[Max[z = Last /@ x] - Min[z] > 
       Pi, {Polygon[Join[# - {0, 0, 2 Pi} & /@ Take[x, 2], Take[x, -2]], opt]}, {Polygon[
        x, opt]}]], Axes -> Automatic, 
  AxesLabel -> TraditionalForm /@ {x, y, HoldForm[Im[Log[z]]]}, 
  AxesEdge -> {{-1, -1}, {1, -1}, {1, 1}}, BoxRatios -> {1, 1, 1}, 
  PlotLabel -> 
   StyleForm["multiple branches", FontSlant -> "Italic", FontFamily -> "Times"], 
  PlotRange -> {-10, 10}]

A new replacement /. Line[pts_] :> Line[Split[pts, Abs@Last[#2 - #1] < Pi &]] is added because Mesh option seems to be working in a different manner nowadays. (Not 100% sure what's the difference though. )

$\endgroup$

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.