# Keeping Phase Factors in Sqrt

I am trying to plot certain holomorphic functions that contain square and higher roots. In the complex analysis sense, the function $$f:z\mapsto z^\alpha$$ for some $$\alpha\in\mathbb C$$ has a phase factor $$e^{2\pi i\alpha}$$ at $$z=0$$, which means that on a small circular path around $$0$$ the function $$f$$ picks up this factor. Is there a way to implement this in Mathematica?

For instance,

g[z_] = z^4;
Sqrt[g[Exp[Pi I/2]]]


gives 1 as a result, where I would like Mathematica to keep the phase $$g(e^{\pi i/2})=e^{2\pi i}$$ and then compute $$\sqrt{g(e^{\pi i/2})}=e^{\pi i}=-1.$$ With Sqrt or $$(\cdot)^{1/2}$$ this does not seem possible, as they pick the principal square roots. Many thanks for your help!

EDIT Here is an example:

lim = 5; dlim = 20;
f1[z_] = Sqrt[z^8];
f2[z_] = z^4;
p1 = ParametricPlot[{Re[f1[1 + d I]], Im[f1[1 + d I]]}, {d, -dlim,
dlim}, PlotRange -> {{-lim, lim}, {-lim, lim}}];
p2 = ParametricPlot[{Re[f2[ 1 + d I]], Im[f2[1 + d I]]}, {d, -dlim,
dlim}, PlotRange -> {{-lim, lim}, {-lim, lim}}];
GraphicsGrid[{{p1, p2}}]


Obviously the functions f1 and f2 are not the same, just as $$\sqrt{x^2}=|x|$$ is not equal to $$x$$ on $$\mathbb R\ni x$$. For my purpose I'm rather interested in a resolution of the square root that leads to a smooth function. The above plots look as follows:

In the left picture one sees points where the function crosses the branch cut of the square root. I am wondering whether there is a way to avoid it, such as in the right picture, without being able to resolve the square root by hand. For instance, if one adds an expression to $$z^8$$ that contains similar phases, I would like to take a common phase out of the square root, in order not to be affected by the branch cut.

One can also deform the above function to say $$f(z)=\sqrt{z^8+\varepsilon}$$ for some $$\varepsilon>0$$. Then there is no way to take the square root for generic $$z$$, and it is not possible to plot a deformation of the right picture. I am regardless interested in finding a way to do so, such that the right picture is deformed continuously.

The actual interest of mine comes square roots of the modular functions EllipticTheta and DedekindEta, which transform under certain fractional linear transformations with phases. Then it is well-defined to have expressions such as $$\sqrt{\vartheta_4(z)^8+\varepsilon \vartheta_2(z)^4\vartheta_3(z)^4}$$ since both summands transform with the same phases.

All of the above issues come from the fact that Mathematica expresses complex numbers at each step either in Cartesian coordinates or ignores everything modulo $$2\pi$$ in polar form. It would be nice to find a way to prevent Mathematica from doing this, without having to redefine every single operation. Thanks a lot!

• This is just an unpolished idea, but maybe work in (r,theta) coordinates, with power((r,theta),n) defined as (r^n,n*theta). I'm also curious to see if there are good ways to handle this question. Jan 6 at 14:37
• Thanks, I think this could work if all functions are defined this way by hand. Unfortunately I also use built in functions such as EllipticTheta and DedekindEta, which themselves transform under modular transformation with phases. Jan 6 at 14:47
• Sqrt is not the issue since g[Exp[Pi I/2]] evaluates to 1 before the Sqrt sees its input. Jan 6 at 14:50
• For the sum I'd say do the pedestrian thing: convert to complex (Cartesian), add, convert back to polar. Jan 6 at 15:55
• Have you seen this? Jan 7 at 0:14

This is an example of the general problem of analytically-continuing a multi-valued function along a continuous path.

In the case of an algebraic function such as $$w=\sqrt{z^8}$$, we can write it as $$f(z,w)=w^2-z^8=0$$ and in your case, letting $$z(t)=1+it$$, write: $$\frac{dw}{dt}=-\frac{f_z}{f_w}\frac{dz}{dt}=\frac{4i(1+it)^7}{w}$$ We next solve the (multi-valued) IVP: $$\frac{dw}{dt}=\frac{4i(1+i t)^7}{w};\quad \{w_0\}=\{f(z(t_0),w)=0\}$$ where the DE and initial values $$\{w_0\}$$ for $$t_0=-5$$ are set up as:

tStart = -5;
tEnd = 5;
thez[t_] = 1 + t I;
theDE = w'[t] == ((4 I z^7)/w /. {z -> thez[t],
w -> w[t]});
wStart = w /. Solve[w^2 == (1 + tStart I)^8, w]


Now solve both IVP's and plot the results:

colors = {Red, Blue};
plotTable = Table[
dSol =
First[NDSolve[{theDE, w[-5] == wStart[[i]]},
w, {t, tStart, tEnd}]];
theSol[t_] := Evaluate[Flatten[w[t] /. dSol]];
ParametricPlot[{Re[theSol[t]], Im[theSol[t]]}, {t, tStart, tEnd},
PlotRange -> {{-5, 5}, {-5, 5}}, PlotStyle -> colors[[i]]],
{i, 1, 2}];
Show[plotTable]


• Very nice, thanks a lot! From the reformulation $0=f(z,w)$ I guess one could express these graphs as affine algebraic plane curves, such that the two components are defined through real polynomials $0=P_1(x,y)P_2(x,y)$ with $w=x+iy$? Jan 6 at 20:51
• The function f(z,w)=w^2-z^8=0 is an algebraic curve and we could even plot the solution contours, the solutions to the DEs, over the branches of this curve to clearly show how the DE solutions provide an analytically-continuous route over the sheets of the curve. Jan 6 at 22:45