I need to get Mathematica to evaluate the logarithm of a negative real number using the lower branch instead of the upper branch, so that while
In[1]:= Log[3.2]
Out[1]:= 1.16315
I need
In[2]:= Log[-3.2]
Out[2]:= 1.16315 - 3.14159 I
and not
Out[2]:= 1.16315 + 3.14159 I
I have already defined my own function loopLog
that does this:
loopLog[x_: NumericQ] = If[Element[x,Reals], Conjugate[Log[x]]];
But I am not able to get it to perform any of the usual simplifications or manipulations using this function. For example, when I want to differentiate loopLog, I get
In[3]:= D[loopLog[x],x]
Out[3]:= If[x \[Element] Reals, Derivative[1][Conjugate][Log[x]]/x]
Instead of the much needed 1/x
. What is the cleanest way to define such a logarithm function in Mathematica?
x_: NumericQ
this is a pattern that matches anything, but defaults to the symbolNumericQ
if no argument is given. You surely meantx_?NumericQ
$\endgroup$$BranchCut
global variable that affectsArcTan
and the rest as well, even nicer if it could be set to an arbitrary curve. $\endgroup$x_?NumericQ
$\endgroup$Log
with a branch cut along any curve of the form $z = re^{i\theta(r)}$:branchLog[z_, \[Theta]_] := With[{r = Abs[z]}, Log[z/Exp[I \[Theta][r]]] + I \[Theta][r]]
. Then forArcTan
you can doExpToTrig[TrigToExp@ArcTan[z] /. Log[z_] -> branchLog[z, \[Theta]]]
... $\endgroup$