2
$\begingroup$

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:

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?


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.

  • 0
    $F(x)=\int_a^xf(t)dt$ is real valued (say for integrable $f:\mathbb{R}\to\mathbb{R}$)2011-12-15
  • 0
    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...2011-12-15
  • 4
    Pretty picture, nice colours. However, the integral you mention is real.2011-12-15
  • 0
    Yes, it's certainly real. Did you try an explicit numerical example to prove your claim of complex values?2011-12-15
  • 0
    I appreciate the comments and I am glad that it is the computer program, and not my brain, that has it wrong. Unfortunately, I am still left without the integral I seek. Okay, so it's real-valued, but what is $\int_1 ^x \cos(2\pi N/t) dt$?2011-12-15
  • 0
    The only explanation I can think of is that you're looking at an antiderivative with a (constant) nonzero imaginary part.2011-12-15
  • 0
    @J.M.: The computer algebra system I am using is apparantly in error. I'm not sure how I could run a numerical example exept perhaps by discretizing the function. What would you recommend?2011-12-15
  • 0
    What computing environment are you on? There's a chance that the sine integral is already available...2011-12-15
  • 0
    I'm using a public server running sagemath (http://alpha.sagenb.org/). I like the program very much and have not had many issues with it (this being the exception). It gives the answer in terms of the exponential integral rather than the sine integral.2011-12-15
  • 1
    Ask Wolfram Alpha to take its time: http://www.wolframalpha.com/input/?_=1323976042890&fp=1&i=integrate+cos%282pi+N%2ft%29%2c+t%3d1..x&incTime=true . You could also just use a substitution $x=au$ in your integral and then use the answer from your previous question.2011-12-15
  • 1
    Ah, the exponential integral showing up [is easy to explain](http://dlmf.nist.gov/6.5)... unfortunately it does seem to me that none of the trigonometric integrals are supported by Sage. A pity.2011-12-15
  • 0
    @DavidMitra: Thanks! It looks like I'm back on track now. I'm a bit disappointed about the Sage SNAFU, but for a free program I'd still say it beats the competition hands down.2011-12-15
  • 0
    This may be an artifact of round-off errors or possibly a bug in the integration routines. Do you have magnitudes of the real and imaginary parts of the complex numbers you are getting? The motivation for asking is that _real_ roots of some cubic polynomials are expressible only as sums of complex-valued functions of the polynomial coefficients. That is, the sum is real-valued because the imaginary parts cancel out. So you may be having round-off error, or a bug is giving you only one term of a similar sum of terms, and the missing term would have canceled the imaginary part were it present.2011-12-15
  • 0
    @DilipSarwate: I think you are getting at the issue. When I evaluate the integral at specific values, I get very small (i.e. 1E-19) values for the complex part. It is probably a rounding and canceling out error.2011-12-15
  • 0
    I don't understand what's the problem with the colours. As far as I can tell, there are exactly two colours along the real axis, red for positive and cyan for negative, and the complex values only occur at complex arguments -- where in this image do you see evidence of complex values for real $x$?2011-12-15
  • 0
    @joriki: Two points: 1) when I try to plot the integral with the normal "plot" function instead of the "complex_plot" one, it gives me errors; 2) when I evaluate the integral directly, for certain values it gives me complex answers (e.g. $f(2) ~ a + 1\times 10^{-19} i$)2011-12-16
  • 0
    @Adam: Yes, I read about the small imaginary parts due to rounding errors above. I was asking specifically about the colour plot. You wrote "The pretty colored complex-plot above is wrong", and I don't see anything wrong with it.2011-12-16
  • 0
    @joriki: Insofar as it represents the incorrect results of the CAS, it is wrong (even if the errors are minute). Yes, it is probably quantitatively close enough to be considered correct, but the fact that it is shown at all is (to my mind) misleading. I suppose it's a matter of opinion.2011-12-16
  • 0
    @Adam: A diagram at this (spatial and colour) resolution can't represent an imaginary part of $1\times10^{-19}\mathrm i$. In any case, your post seems to imply that there's something *visibly* wrong with the diagram; I think that's misleading and should be changed. About showing this plot at all being misleading, I guess that depends on what sort of software this is, what sort of diagrams it usually shows for other functions, etc.2011-12-16

1 Answers 1

2

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

  • 0
    See the comments above. I was using sagemath.2011-12-15
  • 3
    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.2011-12-15