-1

What is the error with my thinking?

Sometimes imagpart(log(-%i)) is negative:

(%i1641) imagpart(log(-%i));
                                       %pi
(%o1641)                             - ---
                                        2

But this shows the imaginary part of log ranging from 0 to 2*pi:

wxplot2d(imagpart(log(-1/exp(%i*2*%pi*x))), [x, -1, +1]);

image here. Are the results of Maxima's log() predictable without studying the source code, and if so, how?

Edited to document additional bizarre Maxima behavior. Compare the ranges between these two:

wxplot2d(imagpart(log(+exp(%i*2*%pi*x))), [x, -1, +1]);
wxplot2d(imagpart(log(-exp(%i*2*%pi*x))), [x, -1, +1]);

What's the secret to predicting Maxima's results?

Edited to add: Despite the extensive replies about log being "multivalued", the same behavior is exhibited plog, proving log's "multivalued" nature to be irrelevant.

  • 2
    Maxima's project administrator blocked you from their mailing list because you dropped a link to this question with "Subject: Here's a bug for you clowns to ignore. Body: this is one hopeless CAS " Trolling getting you blocked shouldn't be a surprise. (see https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/CABc8mQXMb_gajD6v35BjDLJ97swhV0hUF600qY6REAuuGWoBgw%40mail.gmail.com/#msg37091393) – Nick J Aug 22 '20 at 20:05
  • 2
    "the Maxima administrator isn't tracking the bug" no. the administrator isn't including you in any conversation. and you didn't submit a bug, just a link to this here. I suspect posting your query in a civil manner would have actually produced a civil response. (case in point, already an answer below from a developer). You're also new here, I suggest https://stackoverflow.com/conduct may be a worthwhile reminder before you follow suit here. – Nick J Aug 22 '20 at 20:15
  • as plog uses the [-pi,pi] range, and the command used for log are set to require collapsing to a principle angle, it's unsurprising they produce mostly similar results. plog of course simplifies for a few direct calls where log does not. the last two plots are not identical though. plog does not produce the same plot for your log(+exp(%i*2*%pi*x)) example, since it seems plog does not oversimplify as does log, probably due to the logexpand bug mentioned before. the + also fails to produce the pi-shift to [0,2pi] that you get with log and - examples. perhaps this is just a wxplot2d artifact. – Nick J Aug 24 '20 at 05:42

1 Answers1

3

imagpart(log(a+b*%i)) is immediately converted to atan2(b,a), as you can easily confirm.

Of course there are other values for the mathematical log() in the complex plane, but what matters here is imagpart choses one, and the plot programs plot it. imagpart(log(-x)) is atan(0,x)+ %pi/2, presumably because log(-x)= log(x)+log(-1), etc.

The dangers of using an arbitrarily chosen branch of a function can be illustrated without using complex numbers and log. All you need is square-root. If you (or your computer system) insist that sqrt(9) is 3, and never -3, you are already courting proofs of false statements.

ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • 1
    Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/220283/discussion-on-answer-by-richard-j-fateman-maximas-log-is-inconsistent-with-maxi). – Martijn Pieters Aug 23 '20 at 01:32
  • Defining log to return an arbitrary but consistent range has never resulted in a proof of any false statement by me. It's like everything else in math: your results are valid iff your reasoning is valid. I see no benefit to Maxima's unpredictability here. It's obviously a bug, despite your excuse. – Sadiq Moshif Aug 23 '20 at 02:13
  • "imagpart choses one" <-- That assertion was proven false by the original post – Sadiq Moshif Aug 23 '20 at 11:37
  • no on has said there isn't a bug here. they've actually found a specific one in logexpand simplification rules. see https://sourceforge.net/p/maxima/mailman/maxima-discuss/thread/CACLVabVOFdJnOTN9LzRuuEAzbg6XhLOfe%3DRAuUgsrOXMx8%3DQOw%40mail.gmail.com/#msg37091449 – Nick J Aug 23 '20 at 17:51
  • 1
    "The big issue here is that handling multivalued functions like *log* and fractional powers in a CAS is a balancing act. We could try to be completely correct, or else we can compromise to make the system usable. If we were trying to be completely correct, we couldn't simplify *log(x)-log(x)* to *0*, because we couldn't assume that the same branch is chosen in both cases. I'm pretty sure that that would make the system unusable." – Sadiq Moshif Aug 23 '20 at 20:00
  • and those are the consistencies they're taking their free time to look at fixing thanks to your helpful pointer. when they work out the consistency between the functions involved, I'll be sure to pass along the recommendation of noting the proper function range in the docs – Nick J Aug 23 '20 at 20:29