Trying to get the argument of the product of 2 complex numbers produces the wrong result:
image link
So I multiply
3(\cos(\frac{5π}{13}) + i*\sin(\frac{5π}{13})
with
4(\cos(\frac{7π}{13}) + i*\sin(\frac{7π}{13})
The right answer for the argument should be \frac{12π}{13}
, not \frac{25π}{13}
.
You can try yourself with this Maxima file that I've joined:
BUG.wxmx
Someone on Github of Wxmaxima suggested it's a problem with Maxima " switching to atan and atan getting the wrong result larger than pi/2."
Github issue
My version of WxMaxima: 22.04.0 Maxima version: 5.46.0 (x86_64-unknown-linux-gnu) Maxima compiled using: ECL 21.2.1
EDIT (Robert Dodier):
For reference, I'm appending here the content of the BUG.wxmx notebook.
Input:
c:3*(cos(5*%pi/13)+%i*sin(5*%pi/13));
Output:
5 π 5 π
3 (%i sin(---) + cos(---))
13 13
Input:
d:4*(cos(7*%pi/13)+%i*sin(7*%pi/13));
Output:
7 π 7 π
4 (%i sin(---) + cos(---))
13 13
Input:
carg(c*d);
Output:
7 π 5 π
sin(---) sin(---)
13 13
π + atan(--------) + atan(--------)
7 π 5 π
cos(---) cos(---)
13 13
Input:
trigreduce(%);
Output:
25 π
----
13
Thanks for the bug report.
The function trigreduce simplifies
atan(tan(XXX))
toXXX
. This simplification doesn’t respect the value of triginverses.The user documentation for trigreduce doesn’t say anything about simplifying all
atan(tan(XXX))
expressions toXXX
, so I say this is a bug.A possible fix to this bug is insert a check for the value of triginverses into
sp1atrig
(defined in trgred.lisp)A quick test using the proposed change to sp1atrign gives a failure to rtest14, problem 376. The test is
trigreduce(atan(tan(x+y+z))).
I think that's the only failure caused by this proposed change,
I don't think there is any problem with the conversion of atan(tan(x)) to x, but the check still needs to be done that the resulting x needs to be in range of atan and that is -pi/2 to pi/2. This is necessary because the atan2 function added pi knowing that atan needed to be negative angle.
It seems like the check of the resulting range of atan is not respected. The problem is that the atan(sin(7pi/13)/cos(7pi/13)) when reduced does not get atan(tan(x)). atan(tan(7pi/13)) does give -6pi/13.
Last edit: Richard Gobeli 2022-05-29
Here is example of using rules and set limits function. the limit to the atan2rule can also be-pi/2 to pi/2.
I'd like to know more about this bug.
can someone explain me why "carg" produce this "atan (sin x/cos x) + pi"?
The manual only explains how to use it but not HOW it is done:
https://maxima.sourceforge.io/docs/manual/maxima_singlepage.html#index-carg
I wonder where the extra %pi comes from.
c*d
isIf then take the carg of each component I would expect
0 + atan(tan(5*%pi/13)) + atan(tan(7*%pi/13))
whichtrigreduce
would simply to12*%pi/13
. Butcarg(c*d)
has an extra%pi
.Another weird result:
Where does that
%pi
come from? The arg of the exponential is just12*%pi/13
, which is the expected answer.Some more weird results:
But
It's almost as if the arg of the exponential is more than 6.5/13, then a %pi is added.