"Unexpected behavior of log() in complex plane"



On Fri, Oct 28, 2011 at 2:25 PM, Richard Fateman
<fateman at eecs.berkeley.edu> wrote:
> The behavior you report below is not the behavior of the Maxima that I just
> tried it on, 5.23.2.
>
> It reports for an answer, log(w).

Interesting.  In that version I get

Maxima 5.23.2 http://maxima.sourceforge.net
using Lisp ECL 11.1.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) declare(w,real);
(%o1)                                done
(%i2) assume(w<0);
(%o2)                               [w < 0]
(%i3)  limit(log(w+%i*eps),eps,0);
(%o3)                                 und
(%i4) limit(log(w+%i*eps),eps,0,plus);
(%o4)                           log(w) + %i %pi


> Originally the limit program did not refer directly to assumptions or
> declarations, and so
> lines %i1 and %i2 should be irrelevant. ?Newer versions of limit, or
> ?subroutines called during
> the computation of limits may refer to that information.

Yeah, that's what I figured.

> Also, originally, the limit program was aimed at computing ?limits of
> real-valued functions. ?If it works in other contexts, that's nice, but not
> something that was an original intent.

Ah, that is *definitely* interesting.

> So complex log -- eh, not necessarily supported. ?But log has multiple
> values, ?and to distinguish between
> log(w)+n*i*pi ?for odd integer n, ? ? ?and log(-w), is a kind of subtle
> point, not one that is easily handled by
>
> ... just tell me the limit, don't confuse me with, uh, ?the mathematics...

Well, the point is that there is supposed to be a well-defined branch
cut for such functions, and almost universally this is the negative
real axis (see the post on ask.sagemath.org for Mathematica's
computation).  So that the limit would make sense, given this choice
of branch.

After all, if one does it numerically:

sage: var('eps,w')
(eps, w)
sage: f(eps) = log(w+i*eps)
sage: [f(e).subs(w=-1) for e in [.1,.01,.001,.0001]]
[0.00497516542658397 + 3.04192400109863*I, 0.0000499975001665547 +
3.13159298690313*I, 4.99999750058881e-7 + 3.14059265392313*I,
4.99999995711264e-9 + 3.14149265359013*I]
sage: [f(e).subs(w=-2) for e in [.1,.01,.001,.0001]]
[0.694395620659239 + 3.09163425786785*I, 0.693159680403698 +
3.13659269525583*I, 0.693147305559930 + 3.14109265363146*I,
0.693147181809945 + 3.14154265358983*I]

which sure looks like log(-(-2))+I*pi to me.   This is the standard cut.

> So, one answer is: ?upgrade Sage to a later Maxima.

No, that doesn't make sense, because the 5.25.0 I tried is later than
the Maxima in Sage.