Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)$$


$$\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:

enter image description here

A strange thing happens, however, when I integrate. Even along the real axis, there are complex values:

enter image description here

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?


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.

share|cite|improve this question
$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:… . 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
up vote 2 down vote accepted

$$ \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?

share|cite|improve this answer
See the comments above. I was using sagemath. – AdamRedwine Dec 15 '11 at 20:16
I started writing my answer just before you added your EDIT and mentioned Sage in the comments. I saw them as soon as I posted the answer. Sorry for asking a question that was already answered. Thanks for the answer. – robjohn Dec 15 '11 at 20:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.