weird bugs in Integrate

• To: mathgroup at smc.vnet.net
• Subject: [mg75303] weird bugs in Integrate
• From: dimitris <dimmechan at yahoo.com>
• Date: Tue, 24 Apr 2007 03:29:10 -0400 (EDT)

```I don't know if it worths two years after Mathematica 5.2 was released
in Integrate but since: a) I couldn't find anything relevant in the
archives and b) the integrals are rather
trivial and the bugs very clear and weird, here we go...

Consider the definite integral of the functions cot and tan in [a,b].

In[30]:=
ints = HoldForm[Integrate[{Cot[x], Tan[x]}, {x, a, b},
GenerateConditions -> True]]

(*I use the setting GenerateConditions->True because as I was informed
does search
harder for convergence/divergence. The default setting
GenerateConditions->Automatic
does not change my findings*)

Here we taste Integrate

In[31]:=
ReleaseHold[ints /. {a -> Pi/3, b -> 2*(Pi/5)}]
{N[%], ReleaseHold[ints /. Integrate[x__, GenerateConditions ->
True] :> NIntegrate[x] /. {a -> Pi/3, b -> 2*(Pi/5)}]}

Out[31]=
{(1/2)*Log[(1/6)*(5 + Sqrt[5])], ArcCsch[2]}
Out[31]=
{{0.0936592,0.481212},{0.0936592,0.481212}}

Indeed correct results.

Let's make the things a little harder.
Obviously, tan(x) has poles at the vanishing points of cos(x) whereas
cot(x)
has poles at the vanishing points of sin(x).
So for example in the range [0,2Pi].

In[32]:=
({#1, Reduce[#1[x] == 0 && 0 <= x <= 2*Pi, x]} & ) /@ {Cos, Sin}
Out[32]=
{{Cos, x == Pi/2 || x == (3*Pi)/2}, {Sin, x == 0 || x == Pi=
|| x ==
2*Pi}}

In[33]:=
MapIndexed[Plot[#1[x], {x, 0, 10*Pi}, PlotStyle -> Hue[#2[[1]]/3],
PlotLabel -> ToString[#1]] & , {Tan, Cot}];

It is very obvious that the integrals does not converge e.g. in the
range
[0,4Pi] and [1,4Pi].

And Mathematica understands this.

In[34]:=
ReleaseHold[ints /. {a -> 0, b -> 4*Pi}]
Integrate::idiv: Integral of Cot[x] does not converge on {0, 4\=F0}.
Integrate::idiv: Integral of Tan[x] does not converge on {0, 4\=F0}.
Out[34]=
{Integrate[Cot[x], {x, 0, 4*Pi}, GenerateConditions -> True],
Integrate[Tan[x], {x, 0, 4*Pi}, GenerateConditions -> True]}

In[35]:=
ReleaseHold[ints /. {a -> 1, b -> 4*Pi}]
Integrate::idiv: Integral of Cot[x] does not converge on {1, 4\=F0}.
Integrate::idiv: Integral of Tan[x] does not converge on {1, 4\=F0}.
Out[35]=
{Integrate[Cot[x], {x, 1, 4*Pi}, GenerateConditions -> True],
Integrate[Tan[x], {x, 1, 4*Pi}, GenerateConditions -> True]}

To my surprize however,

In[39]:=
ReleaseHold[ints /. {a -> 0, b -> Infinity}]
Integrate::idiv : Integral of Cot[x] does not converge on
{0,Infinity}.
Out[39]=
{Integrate[Cot[x], {x, 0, Infinity}, GenerateConditions -> True], -
Log[Interval[{-1, 1}]]}

I=2Ee. Mathematica fails to detect that the integral of Tan[x] does not
converge on [0,Infinity).
Even worse behavior appeared is the following examples

In[42]:=
ReleaseHold[ints /. {a -> 1, b -> Infinity}]
Out[42]=
{Log[Interval[{-Csc[1],Csc[1]}]],Log[Cos[1]]-Log[Interval[{-1,1}]]}

In[43]:=
ReleaseHold[ints /. {a -> 1000, b -> Infinity}]
Out[43]=
{Log[Interval[{-Csc[1000], Csc[1000]}]], Log[Cos[1000]] -
Log[Interval[{-1, 1}]]}

where for both Tan[x] and Cot[x] Mathematica fails to detect the
divergence.

Dimitris

```

• Prev by Date: weird bugs in integrate 2
• Next by Date: Re: Interpreting the solutions... better this time
• Previous by thread: weird bugs in integrate 2
• Next by thread: Re: weird bugs in Integrate