# How does $\int_1 ^x \cos(2\pi/t) dt$ have complex values for real values of $x$?

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.

-
$F(x)=\int_a^xf(t)dt$ is real valued (say for integrable $f:\mathbb{R}\to\mathbb{R}$) – yoyo Dec 15 '11 at 18:45
Assuming $a$ is real: exactly how do you integrate? Your claim that the integral should result in real numbers is correct, of course, integration of real valued integrable functions results in real numbers. Math programs may possibly yield an imaginary error because they possible use Eulers formula. If $x$ tends to $0$ and you are looking at $\cos(1/x)$ such an error might become rather large. I'd be surprised nonetheless... – user20266 Dec 15 '11 at 18:46
Pretty picture, nice colours. However, the integral you mention is real. – André Nicolas Dec 15 '11 at 18:49
Ask Wolfram Alpha to take its time: wolframalpha.com/input/… . You could also just use a substitution $x=au$ in your integral and then use the answer from your previous question. – David Mitra Dec 15 '11 at 19:15
Ah, the exponential integral showing up is easy to explain... unfortunately it does seem to me that none of the trigonometric integrals are supported by Sage. A pity. – J. M. Dec 15 '11 at 19:22

\begin{align} \int_1^x\cos\left(\frac{2\pi}{t}\right)\;\mathrm{d}t &\stackrel{\quad t\to1/t}{=}-\int_{1/x}^1\cos(2\pi t)\;\mathrm{d}\!\!\frac{1}{t}\\ &=x\cos\left(\frac{2\pi}{x}\right)-1-2\pi\int_{1/x}^1\frac{\sin(2\pi t)}{t}\mathrm{d}t\\ &=x\cos\left(\frac{2\pi}{x}\right)-1-2\pi\int_{2\pi/x}^{2\pi}\frac{\sin(t)}{t}\mathrm{d}t\\ &=x\cos\left(\frac{2\pi}{x}\right)-1+2\pi\operatorname{Si}\left(\frac{2\pi}{x}\right)-2\pi\operatorname{Si}(2\pi) \end{align} This is essentially the formula given by Joriki. Everything is real for real $x$. If a computer-aided math program gave you a complex answer, it is a problem with the program. What program are you using? What was the expression you gave to the program?