I'm running the git master (currently at 5.28.0_137_ge1a2891 using CLISP 2.49). I have a project that generates various atan2's. In trying to simplify an expression I noticed that something like:
atan2(y,x)-atan2(-y,x);
doesn't always return zero (which is should no matter what the signs or x or y are).
Here's a test case:
ans1:atan2(y,x)+atan2(-y,x);
(%o1) 0
(%i2) assume(y>0);
(%o2) [y > 0]
(%i3) ans2:atan2(y,x)+atan2(-y,x);
(%o3) atan2(y, x) + atan2(- y, x)
(%i4)
I also tried this on an older maxima on another box (unfortunately I left the version # at home) and things worked as expected.
I just noticed a typo in my initial report; it is atan2(y,x)+atan2(-y,x) which should return zero, not atan2(y,x)-atan2(-y,x); (the example is correct).
I just updated maxima to the git/master (not having done so for several months). I notice that this bug is still present, even though a fix was posted to the newsgroup.
The culprit was found by Stavros Macrakis macrakis@alum.mit.edu last August::
The original simplification problem here has nothing to do with anything so sophisticated as square roots, branch cuts, etc.
Here is the simplest case of the problem:
Maxima moves the negation out of atan2 if the first argument is syntactically negative but not known to be positive or negative. The culprit is the cond clause calling mminusp* in simpatan2.
This looks intentional, but I don't know the motivation. It certainly breaks the simplification atan2(-p,r)+atan2(p,r). Replacing mminusp* with mminusp fixes this particular problem.
Manually making the change indeed fixes the problem. Any good reason why it wasn't fixed in master?
A patch:is attached.
Applied the patch as commit 67e616f. Closing this report as fixed.