Branch cuts of Sqrt

I was trying to plot some complex functions with branch cuts in Mathematica, but I have two problems.

1. The function is z - Sqrt[z - 1]*Sqrt[z + 1] with z complex. Mathematica says that the standard branch cut for the square root is chosen to be $$]-\infty, 0]$$. In this case I would expect to see the branch cut only between $$-1$$ and $$1$$, but instead the branch cuts do not "cancel out" (mathematicians, please don't kill me) before $$-1$$ (see picture, I am contour-plotting real and imaginary part of the function). What is happening here?

2. If I try to plot z - Sqrt[z^2 - 1], I get a very strange function (see picture). I also have a branch cut on the imaginary axis, but this is due to the fact that if $$z=i$$, Mathematica is forced to calculate the square root of $$-2$$, which is on the branch cut for the standard definition of the square root. Everything kind of fixes if I rotate the branch cuts by multiplying by $$-1$$ in the square root and by $$i$$ outside. Of course now the branch cuts are $$]-\infty, -1]$$ and $$[1, +\infty[$$, but the function behaves like it should, but that is not what I want.

This boils down to understand how Mathematica treats branch cuts, but I can't figure out why I have these strange behaviors.

• I assume you mean z - Sqrt[z - 1]*Sqrt[z + 1] and not z - Sqrt[z - 1]*Sqrt[z - 1]. Commented Mar 4, 2016 at 16:13
• yes, sorry. Fixed. Commented Mar 4, 2016 at 16:14

Yes, I think M gets this one wrong.

We explicitly see where it thinks the branch cuts are:

ComplexAnalysisBranchCuts[Sqrt[z - 1]*Sqrt[z + 1], z]

Im[z] == 0 && Re[z] < 1


But it does look like the answer should be Im[z] == 0 && -1 < Re[z] < 1. We can use a Manipulate to look at cross sections:

Manipulate[
Plot[
Evaluate[ReIm[Sqrt[(x + y I) - 1]*Sqrt[(x + y I) + 1]]],
{y, -1, 1},
PlotLegends -> {Re, Im}
],
{x, -2, 1/2}
]


To manually fix this, you can use the option Exclusions.

With[{z = x + I y},
ContourPlot[
Re[z - Sqrt[z - 1]*Sqrt[z + 1]],
{x, -2, 2}, {y, -2, 2},
Contours -> 40, Exclusions -> {{y == 0, -1 < x < 1}}
]
]


Edit

To answer the second part of your question, it looks like the correct branch cuts were chosen.

If I understand your question correctly, I think you're assuming $$\sqrt{z^2 - 1} = \sqrt{z - 1}\sqrt{z + 1}$$ is always true. This is not the case (given that we're using the principal branch cut, as M does).

We can see the factored form of Sqrt[z^2 - 1] differs in phase angle, but has the same magnitude as Sqrt[z - 1]Sqrt[z + 1]:

PowerExpand[Sqrt[(z - 1) (z + 1)], Assumptions -> z ∈ Complexes]

E^(I π Floor[1/2 - Arg[z-1]/(2π) - Arg[z+1]/(2π)]) Sqrt[z-1] Sqrt[z+1]

• Hello Chip Hurst and J.M., thank you very much for the reply. I only have one additional comment on the second part. Forgetting about mathematica for a second, math tells us that one correct branch cut can indeed be [-1, 1], you can read this discussion about it math.stackexchange.com/questions/184386/… So, choosing this branch cut, I should have a smooth function, without any jump in the phase. Moreover if you print the real part of the function for z=x + i * 0.00001, you will notice a wrong behavior for negative x. Commented Mar 7, 2016 at 9:08
• @IntFabio The comments section states that the imaginary axes is also a branch cut if one chooses the branch for sqrt that way. We show this in Mathematica: sqrt[z_] := Sqrt[z] (2 UnitStep[Im[z]] - 1). Now you can see the cuts here: ContourPlot[Re[sqrt[1 - (x + I y)^2]], {x, -2, 2}, {y, -2, 2}]. Commented Mar 7, 2016 at 16:59
• @IntFabio But to potentially answer your question, defining sqrt[z_] := Sqrt[z] (2 UnitStep[Im[z]] - 1), you get branch cuts (-inf, -1], [1, inf) for your function in part 2. Commented Mar 7, 2016 at 17:00
• Just to add to your last comment: you can rotate the branch cuts by writing the function as z- I * Sqrt[- (z^2-1)] which effectively does nothing but correctly rotates the branch cuts. As for the second last comment, yes, if I choose that definition of the square root I should get the additional branch cut, but complex analysis tells us we should not get it. M might do it but you don't have that in formal math. Commented Mar 14, 2016 at 9:15
• @IntFabio No, I think you do get it in formal math. See the first 2 comments here. I think you'd have to find a different cut of sqrt to get the desired branch. Commented Mar 14, 2016 at 14:28
f = Sqrt[z - 1] * Sqrt[z + 1];


Using FunctionDiscontinuities (new in 12.2)

FunctionDiscontinuities[f, z, Complexes]


z == -1 || z == 1 || (Im[z] == 0 && Re[z] <= 1)

Using ComplexPlot (new in 12.0)

ComplexPlot[f, {z, -2 - 2 I, 2 + 2 I},
FrameLabel -> Automatic,
ColorFunction -> "DarkRainbow",
ExclusionsStyle -> Red,
Mesh -> Automatic,
PlotLegends -> Automatic,
PlotPoints -> 50]


Using ReImPlot (new in 12.0)

ReImPlot[Sqrt[x - 1]*Sqrt[x + 1], {x, -2, 2},
PlotLabels -> "Expressions",
ReImStyle -> {Thickness[.01], {Red, Dashing[{0.03, 0.01}]}}]
`