Atan2 doesn't symplify as expected.



Hi Stavros,

Interesting.   It also simplifies for me here when I run in a fresh
maxima session with no declarations.  I then added some of the
declarations and assumptions I use in my real calculation, evaluating my
expression after each one; here's what I get:

Maxima 5.28.0_130_g925e3f2 http://maxima.sourceforge.net
using Lisp CLISP 2.49 (2010-07-07)
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) display2d:false;
(%o1) false
(%i2) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o2) 0
(%i3) declare(k, real);
(%o3) done
(%i4) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o4) 0
(%i5) declare(omega, real);
(%o5) done
(%i6) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o6) 0
(%i7) assume(k>0);
(%o7) [k > 0]
(%i8) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o8) atan2(sqrt(2)*sqrt(omega)+2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
 +atan2(-sqrt(2)*sqrt(omega)-2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
(%i9) assume(omega>0);
(%o9) [omega > 0]
(%i10) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o10) atan2(sqrt(2)*sqrt(omega)+2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
 +atan2(-sqrt(2)*sqrt(omega)-2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
(%i11) assume(k*sqrt(2*omega) >0);
(%o11) [redundant]
(%i12) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o12) atan2(sqrt(2)*sqrt(omega)+2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
 +atan2(-sqrt(2)*sqrt(omega)-2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
(%i13) assume(2^(1/2)*omega^(1/2)+2*k>0);
(%o13) [redundant]
(%i14) atan2(2^(1/2)*omega^(1/2)+2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1)
 +atan2(-2^(1/2)*omega^(1/2)-2*k,omega+2^(1/2)*k*omega^(1/2)+k^2-1);
(%o14) atan2(sqrt(2)*sqrt(omega)+2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)
 +atan2(-sqrt(2)*sqrt(omega)-2*k,omega+sqrt(2)*k*sqrt(omega)+k^2-1)

Basically as soon as I tell maxima that k>0 it stops simplifying
correctly.  It also seems that it's not k specifically that triggers the
problem; assume(omega>0) first also breaks the simplication.

Also note that it correctly uses the +ve sqrt in the %i11 declaration
which is then redundant.  

David