# Notebook Principal Branch not working yet

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

• the principal branch
• the branches

I also downloaded the UtilitiesTypesetting 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.

<< UtilitiesTypesetting

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}][] /.
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

• 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. Feb 18, 2022 at 15:21
• @Michael E2, thanks, yes its a spiral The sentence : Nothing in your code relies on non-System functions. ?, Please clarify this . Feb 18, 2022 at 19:51
• Look up Context and related tutorials. Your question points to a different context than System but your code does not use it Feb 18, 2022 at 20:24
• @ Michael E2 , i am sorry but i am lost here Feb 18, 2022 at 20:54
• 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. Feb 18, 2022 at 21:23

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}] • 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. Feb 18, 2022 at 19:30
• 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) Feb 18, 2022 at 20:49
• Oops.. i found rotate finally : doubleclick Feb 18, 2022 at 21:35
• @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}]
– josh
Feb 18, 2022 at 22:07
• 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.
– josh
Feb 18, 2022 at 22:13

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}] ParametricPlot3D[{r Cos[θ], r Sin[θ], Im[Log[r Exp[I θ]]]},
{r, .01, 1}, {θ, 0, 2 π},
BoxRatios -> {1, 1, 1},
PlotRange -> {Automatic, Automatic, {-10, 10}}] For comparison, The followings are outputs in v5.2:  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][] /.
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. )