wolfram-mathematicanumerical-integrationmathematica-8

Bug in Integrate vs NIntegrate in mma8


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.


Solution

  • 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.