MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

bug in Integrate (5.2)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74918] bug in Integrate (5.2)
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Wed, 11 Apr 2007 01:57:54 -0400 (EDT)

Consider the integral of the following function in [0,Infinity).

In[710]:=
f[x_, a_, b_] := (ArcTan[x/a] - ArcTan[x/b])/x

The integrand can be proved that converges for a, b>0.

In[723]:=
f[x, a, b] + O[x]^4
(Simplify[#1, a > 0 && b > 0] & )[f[x, a, b] + O[x, Infinity]^4]

Out[723]=
SeriesData[x, 0, {a^(-1) - b^(-1), 0, -1/(3*a^3) + 1/(3*b^3)}, 0, 4,
1]
Out[724]=
SeriesData[x, Infinity, {-a + b}, 2, 4, 1]

However Mathematica returns

In[725]:=
Block[{Message}, Integrate[f[x, a, b], {x, 0, Infinity}]]

Out[725]=
Infinity

result which came from a very bad performance of Mathematica's
Integrate algorithm.

(The ommited message is Integrate::idiv, generated when Mathematica
considers an integral
divergent.)

However it must be pointed out that giving specific values for a and b
Mathematica returns correct results.

E.g.

In[735]:=
lst = Table[{Random[Integer, {1, 10}], Random[Integer, {1, 10}]},
{10}]
(Integrate[f[x, #1[[1]], #1[[2]]], {x, 0, Infinity}] & ) /@ lst
N[%]
(NIntegrate[f[x, #1[[1]], #1[[2]]], {x, 0, Infinity}] & ) /@ lst

Out[735]=
{{6, 10}, {9, 10}, {7, 3}, {10, 8}, {3, 1}, {4, 2}, {7, 3}, {6, 5},
{6, 2}, {4, 1}}

Out[736]=
{(1/2)*Pi*Log[5/3], (1/2)*Pi*Log[10/9], (-(1/2))*Pi*Log[7/3], (-
(1/2))*Pi*Log[5/4], (-(1/2))*Pi*Log[3], (-(1/2))*Pi*Log[2], (-
(1/2))*Pi*Log[7/3], (-(1/2))*Pi*Log[6/5], (-(1/2))*Pi*Log[3], (-
Pi)*Log[2]}

Out[737]=
{0.8024030134443301, 0.16549991098452982, -1.3309323667973947,
-0.35051307075232924, -1.7256961476116015, -1.088793045151801,
-1.3309323667973947, -0.286390031707471, -1.7256961476116015,
-2.177586090303602}

Out[738]=
{0.802403013444152, 0.1654999109844223, -1.3309323667973953,
-0.35051307075216187, -1.7256961476116057, -1.088793045151836,
-1.3309323667973953, -0.28639003170546784, -1.72569614760899,
-2.1775860903036426}


Also, (and more importantly) specifying explicitly assumptions for a,b
give correct symbolic results.

E.g.

In[764]:=
Integrate[f[x, a, b], {x, 0, Infinity}, Assumptions -> a > 0 && b > 0]
Out[764]=
(1/2)*Pi*Log[b/a]

In[766]:=
Block[{Message}, Integrate[f[x, a, b], {x, 0, Infinity}, Assumptions -
> a < 0 && b > 0]]
Out[766]=
Infinity

Note that the option GenerateConditions does not modify above
mentioned buggy performance
of Integrate

In[775]:=
Block[{Message}, (Integrate[f[x, a, b], {x, 0, Infinity},
GenerateConditions -> #1] & ) /@ {Automatic(*default*), True(*does
more extensive searching*), False}]
Out[775]=
{Infinity, Infinity, Integrate[(ArcTan[x/a] - ArcTan[x/b])/x, {x, 0,
Infinity}, GenerateConditions -> False]}


If Mathematica uses (in the curent integral) the Newton Leibniz
formula for obtaining the definite integral from the indefinite one,
below may be is one explanation why it fails if we don't specify
ranges for the parameters a,b.

In[795]:=
Integrate[f[x, a, b], x]
Limit[%, x -> Infinity] - Limit[%, x -> 0](*no specification*)
Limit[%%, x -> Infinity, Assumptions -> a > 0 && b > 0] - Limit[%%, x -
> 0, Assumptions -> a > 0 && b > 0](*specification*)

Out[795]=
(1/2)*I*(PolyLog[2, -((I*x)/a)] - PolyLog[2, (I*x)/a]) -
(1/2)*I*(PolyLog[2, -((I*x)/b)] - PolyLog[2, (I*x)/b])
Out[796]=
DirectedInfinity[I*Sign[Log[-(I/a)] - Log[I/a] - Log[-(I/b)] + Log[I/
b]]]
Out[797]=
(1/2)*Pi*Log[b/a]


Another way to get the definite integral is

In[804]:=
Integrate[f[x, Catalan, EulerGamma], {x, 0, Infinity}] /. {Catalan ->
a, EulerGamma -> b}
Out[804]=
(1/2)*Pi*Log[b/a]


By hand the integral can be obtained easily by integration by parts.


Dimitris



  • Prev by Date: Re: RootSum
  • Next by Date: Re: ColorFunction help?
  • Previous by thread: Fwd: ColorFunction help?
  • Next by thread: Re: bug in Integrate (5.2)