       a bug in Integrate

• To: mathgroup at smc.vnet.net
• Subject: [mg122247] a bug in Integrate
• From: dimitris <dimmechan at yahoo.com>
• Date: Sat, 22 Oct 2011 06:07:15 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```The following has a connection with the recent post of mine called
Simplification.

Let

int = 1/((x^2 + x + 1) Sqrt[x^2 - x + 1]);

Then Mathematica's result for the definite integral in the range
[-1,0] is

In:= Integrate[int, {x, -1, 0}]

Out= -((1/(4* Sqrt))*(I*(Sqrt[
1 + I*Sqrt]*(-2*I* ArcTan[(6 + 3*I*Sqrt)/(3*I - Sqrt
+
3*Sqrt[1 - I*Sqrt])] +
2*ArcTanh[(3*Sqrt)/(3*I + Sqrt -
Sqrt[3 - 3*I*Sqrt])] -
Log[11*I + 4*Sqrt + 10*I*Sqrt[1 - I*Sqrt]] +
Log[3*(13*I + 4*Sqrt + 6*I*Sqrt[3 - 3*I*Sqrt])]) +
Sqrt[1 - I*Sqrt]*(2*ArcTanh[(3*(2*I + Sqrt))/(3*I +
Sqrt - 3*Sqrt[1 + I*Sqrt])] +
2*ArcTanh[(3*Sqrt)/(3*I - Sqrt + Sqrt[3 +
3*I*Sqrt])] +
Log[(1/16)*(-11*I + 4*Sqrt - 10*I*Sqrt[1 + I*Sqrt])]
-
Log[(3/16)*(-13*I + 4*Sqrt - 6*I*Sqrt[3 +
3*I*Sqrt])]))))

which is incorect. Indeed:

In:= N[%]//Chop

Out= -1.294232744953466

In:= NIntegrate[int, {x, -1, 0}]

Out= 0.9272087241257184

I think the reason is that Mathematica firsts evaluates an
antiderivative:

In:= intMath = Integrate[int, x]
Out= (1/(4*Sqrt))*(-2*Sqrt[1 + I*Sqrt]*
ArcTan[(3*(1 - x + x^2)*(I*Sqrt - x + x^2))/
(3*I + Sqrt - 2*Sqrt*x^4 -
Sqrt[3 - 3*I*Sqrt]*Sqrt[1 - x + x^2] +
2*x^3*(3*I + Sqrt[3 - 3*I*Sqrt]*Sqrt[1 - x + x^2]) +
x*(3*I - 3*Sqrt + Sqrt[3 - 3*I*Sqrt]*Sqrt[1 - x + x^2])
+
x^2*(-3*I + Sqrt +
Sqrt[3 - 3*I*Sqrt]*Sqrt[1 - x + x^2]))] -
2*Sqrt[1 - I*Sqrt]*
ArcTan[(3*(I*Sqrt + x - x^2)*(1 - x + x^2))/(3*I - Sqrt +
2*Sqrt*x^4 +
Sqrt[3 + 3*I*Sqrt]*Sqrt[1 - x + x^2] +
x^3*(6*I - 2*Sqrt[3 + 3*I*Sqrt]*Sqrt[1 - x + x^2])
+
x*(3*I + 3*Sqrt -
Sqrt[3 + 3*I*Sqrt]*Sqrt[1 - x + x^2]) -
x^2*(3*I + Sqrt +
Sqrt[3 + 3*I*Sqrt]*Sqrt[1 - x + x^2]))] +
I*((Sqrt[1 - I*Sqrt] - Sqrt[1 + I*Sqrt])*
Log[16*(1 + x + x^2)^2] +
Sqrt[1 + I*Sqrt]*
Log[(1 + x + x^2)*(11*I + 4*Sqrt + (11*I + 4*Sqrt)*x^2 +
10*I*Sqrt[1 - I*Sqrt]*
Sqrt[1 - x + x^2] -
x*(17*I + 4*Sqrt +
8*I*Sqrt[1 - I*Sqrt]*Sqrt[1 - x + x^2]))] -
Sqrt[1 - I*Sqrt]*
Log[(1 + x + x^2)*(-11*I +
4*Sqrt + (-11*I + 4*Sqrt)*x^2 -
10*I*Sqrt[1 + I*Sqrt]*
Sqrt[1 - x + x^2] +
x*(17*I - 4*Sqrt +
8*I*Sqrt[1 + I*Sqrt]*Sqrt[1 - x + x^2]))]))

and then simply does (intMath /. x -> 0) - (intMath /. x -> -1).

In:= N[(intMath /. x -> 0) - (intMath /. x -> -1)]//Chop

Out= -1.2942327449534659

However the evaluated antiderivative possesses a jump singularity at
near x = -0.725
and Mathematica fails unfortunately to take it into acount.

In:= Plot[intMath, {x, -3, 3}]

Nevertheless, there are and some good news. The antiderivative is
correct in the whole complex plane.

In:= FullSimplify[D[intMath, x] - int]

Out= 0

If the integration range does not include the jump, Mathematica will
give correct result. E.g.

In:= Integrate[int, {x, 0, Infinity}] (*after several minutes*)

Out= (1/(4* Sqrt))*(I*(Sqrt[
1 + I*Sqrt]*(2*ArcTanh[(3*Sqrt)/(3*I + Sqrt -
Sqrt[3 - 3*I*Sqrt])] +  Log[11*I + 4*Sqrt -
8*I*Sqrt[1 - I*Sqrt]] -
Log[11*I + 4*Sqrt + 10*I*Sqrt[1 - I*Sqrt]] -
Log[(-2 - I*Sqrt + 2*Sqrt[1 - I*Sqrt])/(-1 +
Sqrt[1 - I*Sqrt])] +
Log[(-2 + I*Sqrt + 2*Sqrt[1 - I*Sqrt])/(-1 +
Sqrt[1 - I*Sqrt])]) + Sqrt[1 - I*Sqrt]*(2*
ArcTanh[(3*Sqrt)/(3*I - Sqrt +
Sqrt[3 + 3*I*Sqrt])] -
Log[-11*I + 4*Sqrt + 8*I*Sqrt[1 + I*Sqrt]] +
Log[-11*I + 4*Sqrt - 10*I*Sqrt[1 + I*Sqrt]] -
Log[(-2 - I*Sqrt + 2*Sqrt[1 + I*Sqrt])/(-1 +
Sqrt[1 + I*Sqrt])] +  Log[(-2 + I*Sqrt + 2*Sqrt[1 +
I*Sqrt])/(-1 +
Sqrt[1 + I*Sqrt])])))

In:= N[%]

Out= 0.9358813101035703 + 0.*I

In:= NIntegrate[int, {x, 0, Infinity}]

Out= 0.9358813101035696

At first glance integrand 1/((x^2 + x + 1) Sqrt[x^2 - x + 1]) may look
simple.
This is far from true.

Dimitris

```

• Prev by Date: Re: count the number of sub-list in a list
• Next by Date: Re: count the number of sub-list in a list
• Previous by thread: Re: Clean up code to run faster
• Next by thread: a bug in Integrate (2nd message)