This question is closely related to one I just asked here. I believe that it is just different enough to warrant another question; please let me know if it does not.
In the question mentioned above, I was informed by Joriki that
$\int \cos\left(\frac{1}{x}\right) \mathrm{d}x = x \cos\left(\frac{1}{x}\right) + \operatorname{Si}\left(\frac{1}{x}\right)$
where
$\mbox{Si}(u) = \int \frac{\sin(u)}{u} \mathrm{d}x$
is the sine integral. That is all well and good, but...
When I asked the question originally, I was trying to simplify things. The integrand I really should have asked about was $\cos(a/x), a \neq 1$. While undefined at the origin, this integrand is continuous and real on the positive real axis:
A strange thing happens, however, when I integrate. Even along the real axis, there are complex values:
I understand that the trigonometric functions are closely related to imaginary numbers via Euler's formula $\cos(x)=e^{ix}-i\sin(x)$, but I have always been told that the integral is "just the area under the curve."
How can the area under a real valued function be complex?
EDIT
See comments below. The problem was due to a software problem. The actual integral is real on the real-axis. The pretty colored complex-plot above is wrong.