Integral. Wrong answer.

Let’s consider the integral:
\int_0^\infty \frac{1-e^{-x}}{x} \cos{x} \ \mathrm{d}x

If you use Mathematica 7, you will get the right answer \frac{1}{2} \log{2}. You can check convergence by Dirichlet’s test: S. C. Malik, Savita Arora “Mathematical analysys” (second edition). 5.2 Tests for Convergence, page 391. “Dirichlet’s test.”

But the last version returns “integral does not converge”. On the other hand, the last version calculates:

\int_0^1 \frac{1-e^{-x}}{x} \cos{x} \ \mathrm{d}x + \int_1^\infty \frac{1-e^{-x}}{x} \cos{x} \ \mathrm{d}x

and \int_0^{-\infty} \frac{1-e^{x}}{x} \cos{x} \ \mathrm{d}x.

The current version also knows answer to NIntegrate of the function.

Hence, we see the BUG (obviously, the result is not correct). But Wolfram|Alpha support team answered, “After review, our internal development group believes the output given is correct.” ([W|A #487459])

Does Wolfram Mathematica use general mathematics rules or special branch only, e.g. “Wolfram branch of maths”?

You can obtain the result using the PrincipalValue -> True option. This setting tell Integrate to handle simple poles.

$Version
Integrate[(1 - Exp[-x])/x Cos[x], {x, 0, Infinity}, PrincipalValue -> True]

Btw, Version 9 also handles it the same way (gives same error without the PrincipalValue -> True setting) so this might not be a bug, but I am not an expert on this.

In[10]:= Integrate[(1 - Exp[-x])/x Cos[x], {x, 0, ul},
Assumptions → {ul > 0}]

Out[10]= 1/2 (2 CosIntegral[ul] - ExpIntegralEi[(-1 - I) ul] -
ExpIntegralEi[(-1 + I) ul] + Log[2])

In[11]:= Limit[%, ul → [Infinity]]

Out[11]= 1/4 (Log[-2 - 2 I] - Log[-1 - I] - Log[-1 + I] +
Log[-(1/2) + I/2] - Log[1/2 - I/2] - Log[1/2 + I/2] + Log[1 - I] +
Log[1 + I])

In[12]:= FullSimplify[%]

Out[12]= Log[2]/2

Yeah, looks like a bug (analyzing for convergence is a difficult area to automate). Will investigate further.

As I can see the bug has not been fixed yet. Do you know the class of functions that we can believe the result of integration? I am afraid to use Mathematica because of uncertain results.

There’s no 100% guaranteed source for integrals. I remember in grad school wasting a lot of time once due to an incorrect integral in Gradshteyn and Ryzhik, the “Bible” of integrals.

It was fixed in the internal version under development. It was not back-ported to 10.0.1. It is not considered to be a show-stopper level of bug and, to my mind, the risks of doing so outweigh the benefits. Risks include both delays in shipping, and the possibility of introducing subtle new bugs.