Addition theorem for arctangent



Your function does some impressive simplifications. Questions:

  (1) Do you have an example that shows the need for calling trigexpand twice? If so, is this a bug in trigexpand?

  (2) Do you have a fix for

       (%i4) atan_contract(42);
       (%o4) 42-13*%pi

--Barton
________________________________

(%i1) atan_contract(r):=block([],
tan(r),
trigexpand(%%),
trigexpand(%%),
atan(%%)
)$

 Examples
 1.
(%i2) atan(x)+atan(y)$
%=atan_contract(%);
(%o3) atan(y)+atan(x)=atan((y+x)/(1-x*y))

 2.
(%i4) atan(1/2)+atan(1/3)$
%=atan_contract(%);
(%o5) atan(1/2)+atan(1/3)=%pi/4
(%i6) float(%), numer;
(%o6) 0.78539816339745=0.78539816339745

 3.
(%i7) atan(1/3)+atan(1/5)+atan(1/7)+atan(1/8)$
%=atan_contract(%);
(%o8) atan(1/3)+atan(1/5)+atan(1/7)+atan(1/8)=%pi/4
(%i9) float(%), numer;
(%o9) 0.78539816339745=0.78539816339745

 4. Machin's  formulae
(%i10) 4*atan(1/5)-atan(1/239)$
%=atan_contract(%);
(%o11) 4*atan(1/5)-atan(1/239)=%pi/4
(%i12) float(%), numer;
(%o12) 0.78539816339745=0.78539816339745

 5. see http://en.wikipedia.org/wiki/Machin-like_formula
(%i13) 12*atan(1/49)+32*atan(1/57)-5*atan(1/239)+12*atan(1/110443)$
%=atan_contract(%);
(%o14) 12*atan(1/49)+32*atan(1/57)-5*atan(1/239)+12*atan(1/110443)=%pi/4

best

Aleksas D