integrate(1/(sin(x)^2+1),x,a,b)?



>>>>> "Richard" == Richard Fateman <fateman at cs.berkeley.edu> writes:

    Richard> Here is what commercial macsyma gets. I don't know what it boils down to.
    Richard> RJF


    Richard> limit(((atan(((2 * tan(z + x))/(sqrt(2)))))/(sqrt(2))) + ((sqrt(2) * %pi *
    Richard> floor((z/(%pi)) + (x/(%pi)) + (1/2)))/2) - ((sqrt(2) * %pi)/2),x,0,minus) +
    Richard> ((sqrt(2) * %pi)/2) 

This seems reasonable.

With a slight change of my current code,  maxima says this (I hope
this comes out ok with a fixed-width font):

(%i131) integrate(1/(sin(x)^2+1),x,0,z);
Is  z  positive, negative, or zero?

pos;
     z
Is ----- an integer?
   2 %pi

no;
Is  z - 2 %pi  positive, negative, or zero?

pos;
                  z
Is  2 %pi floor(-----) - z  positive, negative, or zero?
                2 %pi

neg;
                  z
Is  4 %pi floor(-----) - 2 z + %pi  positive, negative, or zero?
                2 %pi

neg;
                                                 z
                       sqrt(2) sin(2 %pi floor(-----) - z)
                                               2 %pi
          sqrt(2) atan(-----------------------------------)
                                             z
                           cos(2 %pi floor(-----) - z)
                                           2 %pi
(%o131) - -------------------------------------------------
                                  2
                                                                 z        %pi
                                           + sqrt(2) %pi floor(-----) + -------
                                                               2 %pi    sqrt(2)


(%i132) subst(z=8,%o131);
                          sqrt(2) sin(8)
             sqrt(2) atan(--------------)
                              cos(8)                        %pi
(%o132)      ---------------------------- + sqrt(2) %pi + -------
                          2                               sqrt(2)
(%i133) float(%);
(%o133)                        5.626872849439725
(%i134) integrate(1/(sin(x)^2+1),x,0,8);
    4
Is --- an integer?
   %pi

no;
                          sqrt(2) sin(8)
             sqrt(2) atan(--------------)
                              cos(8)                        %pi
(%o134)      ---------------------------- + sqrt(2) %pi + -------
                          2                               sqrt(2)
(%i135) float(%);
(%o135)                        5.626872849439725


So comparing %o131, %o132, and %o134, maxima appears to be doing the
right thing.  I think, though that %o131 probably needs to produce
limits to make sure the floor function is evaluated correctly since
it's not continuous.

Ray