a bug in Integrate
- To: mathgroup at smc.vnet.net
- Subject: [mg78729] a bug in Integrate
- From: dimitris <dimmechan at yahoo.com>
- Date: Sun, 8 Jul 2007 06:04:50 -0400 (EDT)
(version 5.2; the bug exists also in version 6 as I was informed)
In[1106]:=
Integrate[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])], {z, 0, Infinity}]
Out[1106]=
1/2
However this is incorrect
In[1112]:=
NIntegrate[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])], {z, 0, Pi, Infinity},
PrecisionGoal -> 6, WorkingPrecision -> 40,
MaxRecursion -> 16, MinRecursion -> 12]
Out[1112]=
0.363985435056665403`6.3687538868422156
The integral is evaluated by
1) taking the antiderivative
2) application of the NL formula
In[1115]:=
Developer`ClearCache[]
In[1115]:=
Unprotect[Limit];
Limit[a___] := Null /; (Print[InputForm[lim[a]]]; False)
Evaluate again, now, the integral
In[1116]:=
Integrate[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])], {z, 0, Infinity}]
(*lengthy output is ommited*)
The antiderivative has infinitely many jump discontinuities at
Pi,3Pi,5Pi...
In[1117]:=
Integrate[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])], z]
Table[{n*Pi, (Limit[%, z -> n*Pi, Direction -> #1] & ) /@ {-1, 1}},
{n, 1, 5, 2}]
Out[1117]=
((-(1/2))*(1 + 2*ArcTan[Tan[z/2]]))/E^z
Out[1117]=
{{Pi, {((1/2)*(-1 + Pi))/E^Pi, ((-(1/2))*(1 + Pi))/E^Pi}}, {3*Pi,
{((1/2)*(-1 + Pi))/E^(3*Pi), ((-(1/2))*(1 + Pi))/E^(3*Pi)}},
{5*Pi, {((1/2)*(-1 + Pi))/E^(5*Pi), ((-(1/2))*(1 + Pi))/E^(5*Pi)}}}
Mathematica's integrator misses these jump discontinuities
unfortunately.
In[1119]:=
Clear[Limit]
In[1119]:=
Limit[((-(1/2))*(1 + 2*ArcTan[Tan[z/2]]))/E^z, z -> Infinity] -
Limit[((-(1/2))*(1 + 2*ArcTan[Tan[z/2]]))/E^z, z -> 0]
Out[1120]=
1/2
At this point I would like your (any!) comments on this issue.
Next, wrap the integrand to TrigToExp.
In[1121]:=
Integrate[TrigToExp[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])]], {z, 0,
Infinity}]
N[%]
Out[1121]=
(1/2)*(1 - Pi*Csch[Pi])
Out[1122]=
0.3639854725089334
Now Mathematica gets the integral correctly!
Of course this is not the first time that I have
encountered a case where TrigToExp "helps"
Integrate but what remains mysterious is that
even with TrigToExp the antiderivative has finite
discontinuities at the same (infinite) points at the
real axis
In[1123]:=
Integrate[TrigToExp[Exp[-z]*ArcTan[Sin[z]/(1 + Cos[z])]], z]
Table[{n*Pi, (Limit[%, z -> n*Pi, Direction -> #1] & ) /@ {-1, 1}},
{n, 1, 5, 2}]
Out[1123]=
((1/2)*I*(I - Log[1/(1 + E^(I*z))] + Log[E^(I*z)/(1 + E^(I*z))]))/E^z
Out[1124]=
{{Pi, {((1/2)*(-1 + Pi))/E^Pi, ((-(1/2))*(1 + Pi))/E^Pi}}, {3*Pi,
{((1/2)*(-1 + Pi))/E^(3*Pi), ((-(1/2))*(1 + Pi))/E^(3*Pi)}},
{5*Pi, {((1/2)*(-1 + Pi))/E^(5*Pi), ((-(1/2))*(1 + Pi))/E^(5*Pi)}}}
So, even with TrigToExp Mathematica detects the infinite
many discontinuities or in this case the integral is evaluated
with the convolution method.
BTW,
As David Cantrell and Vladimir Bondarenko noticed in another
CAS, the returning antiderivative is a continuous function in
the possitive real axis
INT(EXP(-z)*ATAN(SIN(z)/(1+COS(z))),z,0,inf)
(#e^(2*pi)-2*pi*#e^pi-1)/(2*(#e^(2*pi)-1))
0.3639854725
INT(EXP(-z)*ATAN(SIN(z)/(1+COS(z))),z)
-pi*#e^(-z)*FLOOR(1/2-z/(2*pi))+pi*#e^(2*pi*FLOOR
(1/2-z/(2*pi))+pi)/(#e^(2*pi)-1)-#e^(-z)*(z+1)/2
Would it be possible for Mathematica to return a result
like the above?
Dimitris