From: psycho_dad on
On Apr 6, 1:22 pm, Jason Alexander <ja...(a)lse.ac.uk> wrote:
> Hello all,
>
> I'm getting a strange result when calculating what I thought was a relatively straightforward integral. If I evaluate the following expression, I receive an imaginary result when it should, in fact, equal 1. (This happens in Mathematica 7.0.1 on Mac OS X):
>
> In[1]:=
> Integrate[(
> 4 (8/(2320 + 3 x (-96 + 3 x)) + 8/(1460 + 3 x (-76 + 3 x)) + 6/(
> 800 + 3 x (-56 + 3 x)) + 4/(340 + 3 x (-36 + 3 x)) + 1/(
> 80 + 3 x (-16 + 3 x))))/(9 \[Pi]), {x, -Infinity, Infinity}]
>
> Out[1]:=
> 1/3 + (52 I)/9
>
> However, if I break the integral into two parts, as below, then I get an answer of 1.
>
> In[2]:=
> Integrate[(
> 4 (8/(2320 + 3 x (-96 + 3 x)) + 8/(1460 + 3 x (-76 + 3 x)) + 6/(
> 800 + 3 x (-56 + 3 x)) + 4/(340 + 3 x (-36 + 3 x)) + 1/(
> 80 + 3 x (-16 + 3 x))))/(9 \[Pi]), {x, -Infinity, 0}] +
> Integrate[(
> 4 (8/(2320 + 3 x (-96 + 3 x)) + 8/(1460 + 3 x (-76 + 3 x)) + 6/(
> 800 + 3 x (-56 + 3 x)) + 4/(340 + 3 x (-36 + 3 x)) + 1/(
> 80 + 3 x (-16 + 3 x))))/(9 \[Pi]), {x, 0, Infinity}] // Simplify
>
> Out[2]:=
> 1
>
> Furthermore, if I compute the antiderivative, I get the following:
>
> (1/(9 \[Pi]))4 (-(1/24) ArcTan[1/4 (8 - 3 x)] -
> 1/4 ArcTan[1/4 (28 - 3 x)] - 1/3 ArcTan[1/4 (38 - 3 x)] +
> 2/3 ArcTan[3/4 (-16 + x)] + 1/3 ArcTan[3/4 (-6 + x)] +
> 1/3 ArcTan[1/4 (-38 + 3 x)] + 1/4 ArcTan[1/4 (-28 + 3 x)] +
> 1/24 ArcTan[1/4 (-8 + 3 x)])
>
> And if I define f[x] to be the above, and then ask Mathematica to calculate
>
> Limit[f[n] - f[-n], n -> Infinity]
Well, NIntegrate seem to be working OK (the result is 1.), so as
MajorBob said, always try to check your results!

>
> I get 1, as expected.
>
> Is this a bug, or am I overlooking some subtle point in how Mathematica computes improper integrals?
>
> Cheers,
>
> Jason
>
> --
> Dr. J. McKenzie Alexander
> Department of Philosophy, Logic and Scientific Method
> London School of Economics
> Houghton Street, London WC2A 2AE