# One Integral — Two Results

I compared Mathematica's default integral evaluation to what you get by computing the indefinite integral and then plugging in the limits.

(I did this because the latter approach was much faster for some integrals.)

I got two different results:

integral=-Log[-a+b+2 a x+2 a Sqrt[(-1+x) x]]+Log[-a+b-2 b x+2 b Sqrt[(-1+x) x]]

integralDefault=Assuming[a>0&&b>0,Integrate[integral,{x,0,1}]]//Timing
(*I Pi/2*)

integralInDef[x]=Assuming[a>0&&b>0,Integrate[integral,x]]//Timing;
integralDef=Assuming[a>0&&b>0,Limit[integralInDef[x][[2]],x->1]-Limit[integralInDef[x][[2]],x->0]]//Timing
(*-I (a^2-8 a b+b^2) Pi/(4 a b)*)


The first result agrees with the numeric value.

Is this a known bug?

-
It does not look like a bug, known or unknown. It looks like an integral that might be crossing branch cuts. –  Daniel Lichtblau Oct 22 '12 at 19:15

I think it's useful to manipulate the integrand before integration; notice you have a negative number under square root :

simplifiedIntegrand = Simplify[ComplexExpand[integral, TargetFunctions -> {Re, Im}], Assumptions -> {a > 0, b > 0, 0 < x < 1}]
(* I (-ArcTan[-a + b + 2 a x, 2 a Sqrt[(1 - x) x]] +
ArcTan[-a + b - 2 b x, 2 b Sqrt[(1 - x) x]]) *)

defIntegral =  Integrate[simplifiedIntegrand, {x, 0, 1}, Assumptions -> {a > 0, b > 0}]
(* ConditionalExpression[I Pi/2, a <= b] *)

indefIntegral = Integrate[simplifiedIntegrand, x, Assumptions -> {a > 0, b > 0}] ;

defIntegral2 =  Assuming[a > 0 && b > 0, Limit[indefIntegral, x -> 1, Direction -> +1] - Limit[indefIntegral, x -> 0, Direction -> -1]]
(* (I Pi)/2 *)


As pointed out by @Simon :

Integrate[simplifiedIntegrand, {x, 0, 1}, Assumptions -> {a > b > 0}]
(* (I Pi)/2 *)


which would establish the identity integral = I Pi /2 for any positive a, b.

However

general = Integrate[simplifiedIntegrand, {x, 0, 1}, Assumptions -> {a \[Element] Reals, b \[Element] Reals}]
(* ConditionalExpression[-(1/2) I (\[Pi] - 2 ArcTan[-a - b, 0] + 2 Arg[a + b]),
(b < 0 && (b <= a < 0 || 0 < a <= -b)) || (b > 0 && (-b <= a < 0 || 0 < a <= b))] *)


and

Simplify[general, Assumptions -> {0 < a < b}]
(* (I Pi)/2 *)


but

Simplify[general, Assumptions -> {a > b > 0}]
(* Undefined *)

-
If you do the integral Integrate[simplifiedIntegrand, {x, 0, 1}, Assumptions -> {a > b > 0}] you also get the answer I Pi / 2, so the result is stronger than the ConditionalExpression would have you think. –  Simon Oct 22 '12 at 23:20
@Simon Good point, please see edit. –  b.gatessucks Oct 23 '12 at 8:20