问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/63539603/maximas-log-is-inconsistent-with-maximas-plog-and-with-itself