4

What is going on here (Mathematica version 8.x):

NIntegrate[Log[1/2 + Sqrt[1/4 - 1/(4 x^2)]]/x, {x, 1, Infinity}]
--> -0.171007

Integrate[Log[1/2 + Sqrt[1/4 - 1/(4 x^2)]]/x, {x, 1, Infinity}] // N
--> 0.171007

The NIntegrate[] value is correct. I have run into problems with PrincipalValue selections before but a) those have been fixed in mma8 and b) this integral doesn't, or at least shouldn't, have poles in the integration region.

EDIT: Thanks to people suggesting solutions to this problem, a general solution would be, e.g., using exclusively NIntegrate. However, I am interested in finding out why specifically this happens and whether thus this bug is predictable.

Timo
  • 4,246
  • 6
  • 29
  • 42

1 Answers1

5

This is a bug in Integrate, I am afraid. As a workaround, do the change of variables x->u^(-1/2):

In[12]:= Log[1/2 + Sqrt[1/4 - 1/(4*x^2)]]/x Dt[x]/Dt[u] /. 
 x -> 1/Sqrt[u]

Out[12]= Log[1/2 + Sqrt[1/4 - u/4]]/(2 u)

Then

In[14]:= Integrate[%, {u, 1, 0}]

Out[14]= 1/24 (-\[Pi]^2 + Log[8] Log[16])

In[15]:= N[%]

Out[15]= -0.171007

This agrees with NIntegrate.

Timo
  • 4,246
  • 6
  • 29
  • 42
Sasha
  • 5,935
  • 1
  • 25
  • 33
  • A better workaround is using exclusively `NIntegrate`, do you have any idea why that change of variables corrects the outcome? – Timo May 18 '11 at 05:33
  • The reason that the incorrect computation of anti-derivative (has wrong sign). This gives `ad = Integrate[f = Log[1/2 + Sqrt[1/4 - 1/(4*x^2)]]/x, x]; D[ad, x] + f // FullSimplify[#, x > 1] &` zero. This explains the wrong sign. In v7 this anti-derivative remains unevaluated, and so is the definite integrand. After the change of variables, both the anti-derivative and the definite integral are correct. – Sasha May 18 '11 at 05:58
  • Do you mean that in v7 only the definite integral is evaluated and in v8 there is an intermediate step via the indefinite integral (anti-derivative)? – Timo May 18 '11 at 06:44
  • No, I mean in v7 neither definite, not indefinite symbolic integral evaluates. Applying `N` to the unevaluated `Integrate` automatically calls `NIntegrate`. In v8 both anti-derivative and the definite integral are off by a sign. – Sasha May 18 '11 at 12:25