# Moving the location of the branch cut in Mathematica

According to the documentation, Mathematica chooses the branch cut for $\log(z)$ to lie along the negative real axis. It it possible to change this so that it lies along the positive axis or elsewhere in the complex plane?

• By the way, welcome to Mathematica.SE! Please consider registering your account so that any upvotes you get on this question are added to those you might get on future questions and answers. That way, over time you will be able to do more on the site (post graphics, edit things, etc). – Sjoerd C. de Vries Nov 18 '12 at 19:16
• I don't have enough reputation to comment or vote, but I am just making a note that Mathematica's default branch cut means values fall in (-Pi,Pi], making Jens answer incorrect and Zzz's original answer the correct one. – user13631 Apr 11 '14 at 2:13
• Can you explain your reasoning in more detail? @Zzz's answer gives myLog[-1, 0.1] as $-2.94159i$, which is quite incorrect. – user484 Apr 11 '14 at 2:28
• @Owen You are wrong. The inverse of my definition, i.e. the Exp of my function, leads back to the original argument. With ZZZ's definition, that is not the case, so it is not an inverse of the exponential function. – Jens Apr 11 '14 at 2:34
• In any case, this is not an answer and should be deleted, perhaps after some more discussion (in case I overlooked something). – Jens Apr 11 '14 at 2:35

Let me join the fun and see if I can write my answer without any omissions... both of the previous ones had little errors you can easily check by inverting the newly defined log function myLog, i.e., doing Exp[myLog[...]].

So here is my definition that I just verified:

myLog[z_, θ_: 0] := Log[Abs[z]] + I (Arg[z Exp[I θ]] - θ)


Note that the sign in front of the branch angle θ has to be different in the two places where it appears, so that when you do the inverse the two instances of θ cancel.

• I think @Zzz has right sign. May be you would like to consider it. Let me know if I am wrong, but I checked it(properly hope so). E.g. myLog[Exp[3 I Pi], Pi] = 3 I Pi, however, in your case, it comes out to be -I Pi, which is not even in the cut range(i.e from Pi to 3 Pi). I hope I am not talking bullshit – L.K. Apr 14 '18 at 17:24
• @L.K I posted this answer as a response to the one by Zzz and therefore took over the definition of the angle from that answer. But that angle is actually the (negative of) the direction angle of the branch cut plus $\pi$. A more useful definition that really uses the angle of the branch cut is in the answer I gave here. It also gives the result you expect with the value of the second argument corresponding to the true branch angle. – Jens Apr 14 '18 at 23:30

My comment from elsewhere seems relevant here, so I'm reposting it.

Here's a Log with a branch cut along any curve of the form $z=-re^{i\theta(r)}$:

myLog[z_, θ_: Function] := With[{r = Abs[z]}, Log[z/Exp[I θ[r]]] + I θ[r]]


Neat example: ArcTan with a weird branch cut.

myArcTan[z_] := Evaluate@ExpToTrig[TrigToExp@ArcTan[z] /. Log[w_] -> myLog[w, # &]]
ContourPlot[Re@myArcTan[x + I y], {x, -3, 3}, {y, -3, 3},
Contours -> FindDivisions[{-π/2, π/2}, 20]] I think the correct way to achieve this is

    myLog[z_, θ_: 0] := Log[Abs[z]] + I (Arg[z Exp[I θ]] + θ)


Positive or negative θ corresponds to moving up or down the Riemann surface.

• You have a little sign error in there - see my answer. – Jens Nov 18 '12 at 3:27