Integrating dx/( a+b sin(x))



For 0 < b < a, Maxima returns an antiderivative of 1/(a + b * sin(x)) that is valid on the open interval (-%pi, %pi), or on any integer multiple of
two pi translation of the open interval (-%pi, %pi).

For definite integration of 1/(a + b * sin(x)), Maxima sometimes fails to give a correct value (these are bugs):

  (%i1)  integrate(1 /(1+sin(x)/2), x,0,z);
  "Is  "z"  positive, negative, or zero?"pos;
  "Is  "z-%pi"  positive, negative, or zero?"pos;
  (%o1) (4*atan((2*sqrt(3)*sin(z)+sqrt(3)*cos(z)+sqrt(3))/(3*cos(z)+3)))/sqrt(3)-(2*%pi)/3^(3/2)

A plot of %o1 shows that it is discontinuous at %pi.  When the integration limits are multiples of %pi, sometimes the definite
integral is correct:

  (%i3)  integrate(1 /(1+sin(x)/2), x,-%pi,%pi);
  (%o3) (4*%pi)/sqrt(3)

  (%i4)  integrate(1 /(1+sin(x)/2), x,-2*%pi,2*%pi);
  (%o4) (8*%pi)/sqrt(3)

The question you observed, "Is 33102*%pi*false-103993"  positive, negative, or zero?"positive" is likely a bug that
has been fixed--try installing the current Maxima.

Sometimes Maxima will ask questions that are somewhat difficult to answer; for example:

  (%i1) assume(0 < b, b < 1);
  (%o1) [b>0,b<1]

  (%i2)  integrate(1 /(1+b * sin(x)), x,0,2*%pi);
  "Is  "abs(sqrt(1-b^2)-1)-b"  positive, negative, or zero?"neg;
  "Is  "sqrt(1-b^2)-b+1"  positive, negative, or zero?"pos;
  (%o2) (2*%pi)/sqrt(1-b^2)

I answered each question consistent with 0 < b < 1. Of course, Maxima should be able to deduce that
abs(sqrt(1-b^2)-1)-b < 0 automatically.  If you are lazy like me, you can start another Maxima session
and  plot  abs(sqrt(1-b^2)-1)-b for b in (0,1).

I haven't really answered your questions, but maybe this helps. If you haven't installed the current Maxima,
I suggest that you do that.

--Barton
________________________________

I was trying to do
 integrate( 1 / ( a+b*sin(x) ), x)
and I got this:
(2.0*atan((0.5*((2*a*sin(x))/(cos(x)+1)+2*b))/(a^2-b^2)^0.5))/(a^2-b^2)^0.5
But if I evaluate this from 0 to 2pi (I was trying to get the Laplace transform of the zeroth Bessel function) I get some weird stuff.

So I evaluated first from 0 to pi and got this:

(%o47) (1.0*%pi)/(a^2-b^2)^0.5  -  ( 2*atan((1.0*b)/(a^2-b^2)^0.5))/(a^2-b^2)^0.5

And then from pi to 2 pi, and got some weird question again (what should answer to:  33102*%pi*false-103993"  positive, negative, or zero?"positive;)

So if I integrate from (pi+0.00001) to (2 pi - 0.00001), I get this:

(%o82) (2*atan((1.0*b-4.9999999999748384*10^-6*a)/(a^2-b^2)^0.5))/(a^2-b^2)^0.5-(2*atan((1.0*b-199999.9834474549*a)/(a^2-b^2)^0.5))/(a^2-b^2)^0.5

Assuming (199999.9834474549) goes to infinity and (4.9999999999748384*10^-6) goes to zero, and then adding (%o47) and (%o82), I would then get the correct answer :  1/ (a^2-b^2)^0.5.

So I must bias pi and 2 pi a little bit in order to get the correct answer. Is this a bug ? How can I solve problems like these in the future without losing much time finding out where is maxima failing?