I have a function $$f(x)=e^{\cos{(x)}}\cos{(\sin{(x)})}$$ that I want to integrate from $0$ to $2\pi$.

Using Mathematica, the indefinite integral evaluates out to be $$\frac{-i\operatorname{Ei}(e^{ix})+i\operatorname{Ei}(e^{-ix})}{2}+C$$ where $\operatorname{Ei}(x)$ is the exponential integral.

When I ask Mathematica the definite integral directly, it gives a $2\pi$, but when I try to use the fundamental theorem of calculus, $$\implies\left.\frac{-i\operatorname{Ei}(e^{ix})+i\operatorname{Ei}(e^{-ix})}{2}\right|^{2\pi}_0=\frac{-i\operatorname{Ei}(e^{2\pi\cdot i})+i\operatorname{Ei}(e^{2\pi\cdot -i})}{2}-\frac{-i\operatorname{Ei}(e^{0i})+i\operatorname{Ei}(e^{-0i})}{2}$$ $$\implies\frac{-i\operatorname{Ei}(1)+i\operatorname{Ei}(1)}{2}-\frac{-i\operatorname{Ei}(1)+i\operatorname{Ei}(1)}{2}=0$$

Why do I get an incorrect value of 0 when I try to use the fundamental theorem of calculus on this integral?

  • 4
    $\begingroup$ WolframAlpha's plot of the antiderivative suggests that it is valid only over certain intervals, one example being $(-\pi,\pi)$. Looking at the image, it can be seen that the portion of the graph over $(\pi,2\pi)$ is the negative of the portion over $(0,\pi)$, explaining why your computation evaluates to $0$. $\endgroup$ Oct 26, 2021 at 3:20
  • 8
    $\begingroup$ You are likely falling victim to this problem. Long story short: when using symbolic computing software, don't use antiderivatives to compute definite integrals, unless you are absolutely certain that you are not crossing branch cuts, going around singularities, etc. $\endgroup$
    – march
    Oct 26, 2021 at 4:17
  • $\begingroup$ @AlannRosas But why would the correct answer be $2\pi$ if both areas cancel out? $\endgroup$
    – Max0815
    Oct 26, 2021 at 12:11
  • 2
    $\begingroup$ You need to split at singularities of the expression for the antiderivative. If you call the original expression for the antiderivative $F(x)$ then you can get your desired answer as $F(2\pi^-)-F(\pi^+)+F(\pi^-)-F(0)$. $\endgroup$
    – Ian
    Oct 26, 2021 at 12:30
  • 3
    $\begingroup$ That doesn't really have anything to do with it being an antiderivative, it is just shorthand for $\lim_{x \to \pi^+} F(x)$. $\endgroup$
    – Ian
    Oct 26, 2021 at 12:46

4 Answers 4


Graph the alleged antiderivative $(-i\operatorname{Ei}(e^{ix})+i\operatorname{Ei}(e^{-ix}))/{2}$:


The fundamental theorem of calculus is not applicable using this as antiderivative, since this is not a continuous function.

  • $\begingroup$ Wait how does your graph demonstrate discontinuity? I think there should be a jump discontinuity at $\pi$ right? So it would be two open circles at the top and bottom and a closed circle on the x axis right? $\endgroup$
    – Max0815
    Oct 26, 2021 at 15:40
  • $\begingroup$ This is how that CAS graphs a jump discontinuity. $\endgroup$
    – GEdgar
    Oct 26, 2021 at 15:46
  • $\begingroup$ Ah I see. That's fair. $\endgroup$
    – Max0815
    Oct 26, 2021 at 15:48

Both the comments above show why the computation failed. An alternate route is to solve it via series.

Recall that $$ \sum_{k=0}^{\infty} \frac{\cos^2(\frac{kx}{2})}{k!} = \frac{e + e^{\cos(x)} \cos(\sin(x))}{2} $$

After some rearranging, integrating from $0$ to $2\pi$ yields $$ (-2e \pi + \sum_{k=0}^{\infty} (\frac{2 \pi }{k!}) + ( 2 \pi +\sum_{k=1}^{\infty}\frac{\sin (2 \pi k)}{k \: k!}) $$ with the $2\pi$ coming from the limit at $k=0$. The left two items cancel and the $\sin$ sum is just $0$, leaving you with $2 \pi$.


$$I=\int_0^{2\pi}e^{\cos{(x)}}\cos{(\sin{(x)})} dx=\Re \int_{0}^{2\pi} e^{e^{ix}}dx=\Re \left(\int_{0}^{2\pi} dx+\sum_{k=1}^{\infty} \frac{1}{k!}\int_{0}^{2\pi}e^{ikx} dx\right)=2\pi.$$ $$\int_{0}^{2\pi} e^{ikx} dx=0, k\in I$$

  • $\begingroup$ I'm assuming the summation comes from the infinite series for $e^x$? Also why doesn't the fundamental theorem of calculus work on the antiderivative though? $\endgroup$
    – Max0815
    Oct 26, 2021 at 12:20
  • $\begingroup$ $\int e^{e^t} dt $, is not doable. $\endgroup$
    – Z Ahmed
    Oct 26, 2021 at 12:47
  • $\begingroup$ What do you mean by doable? $\endgroup$
    – Max0815
    Oct 26, 2021 at 12:48
  • $\begingroup$ it will be series and it cannot be expressed in terms of simple well known functions. $Ei(z)$ is not supposed to be a fundamental function. Bit within $[0,2\pi]$ it is doable as the answer is a well known number.: $2]pi$. $\endgroup$
    – Z Ahmed
    Oct 26, 2021 at 12:55

$$I= \int_{0}^{2\pi} e^{\cos x}\cos{(\sin x)} dx $$

From the Euler's formula:

$$I= \int_{0}^{2\pi} e^{\cos x}\left[\frac{e^{i\sin x}+e^{-i \sin x}}{2}\right] dx = \frac{1}{2} \int_{0}^{2\pi} \left[e^{\cos x + i \sin x} + e^{\cos x - i \sin x}\right] dx = \frac{1}{2} \int_{0}^{2\pi} \left[e^{\cos x + i \sin x} + e^{\cos(-x) + i \sin (-x)}\right] dx = \frac{1}{2} \int_{0}^{2\pi} \left[e^{e^{ix}} + e^{e^{-ix}}\right] dx $$

If we do the change of variable (see Appendix)

$$e^{ix} = z$$ $$dx = \frac{dz}{zi}$$

$$I= \frac{1}{2} \int_{0}^{2\pi} \left[e^{e^{ix}} + e^{e^{-ix}}\right] dx = \frac{1}{2i}\oint_{|z|=1} \frac{e^{z}+e^{\frac{1}{z}}}{z} dz = \underbrace{\frac{1}{2i}\oint_{|z|=1} \frac{e^{z}}{z} dz}_{A} +\underbrace{\frac{1}{2i}\oint_{|z|=1}\frac{e^{\frac{1}{z}}}{z} dz}_{B} $$

Now, apply the Cauchy's integral formula for A : $$f(a)=\frac{1}{2\pi\mathrm{i}}\oint_C \frac{f(z)}{z-a}\mathrm{d}z$$

with $f(z) = e^{z}$, $a= 0$ and $C$ the unit circle:

$$A = \frac{1}{2i}\oint_{|z|=1} \frac{e^{z}}{z} dz = \pi $$

For $B$, use the residue theorem

Expand $\displaystyle \frac{e^{\frac{1}{z}}}{z}$:

$$\frac{e^{\frac{1}{z}}}{z} = \frac{1}{z}+\frac{1}{z^2}+\frac{1}{z^32!}+\frac{1}{z^43!}+...$$

Therefore $\displaystyle \operatorname{Res}\left(\frac{e^{\frac{1}{z}}}{z} ,0\right) = 1$


$$B = \frac{1}{2i}\oint_{|z|=1}\frac{e^{\frac{1}{z}}}{z} dz = \pi \operatorname{Res}\left(\frac{e^{\frac{1}{z}}}{z} ,0\right) = \pi $$ \


$$\boxed{ I = \int_{0}^{2\pi} e^{\cos x}\cos{(\sin x)} dx = 2\pi }$$


This method will be useful in evaluating definite integrals of the type

$$\int_{0}^{2\pi} F(e^{i\theta})d\theta$$

The fact that $\theta$ varies from $0$ to $2\pi$ suggest that we consider $\theta$ as an argument of a point $z$ on the unit circle $C = \left\{ z \Big| |z|=1\right\}$ centered at the origin; hence we write $z =e^{i\theta} \quad 0 \leq \theta \leq 2\pi$. When we make this substitution using the equations:

$$ e^{i\theta} = z$$ $$d\theta = \frac{dz}{zi}$$

The integral becomes the contour integral

$$\int_{0}^{2\pi} F(e^{i\theta})d\theta = \oint_{|z|=1} F(z)\frac{dz}{zi}$$

Conversely, if we have the complex function:

$$f(z) = \frac{F(z)}{zi}$$

and the contour $\gamma(\theta) = e^{i\theta} \quad 0\leq \theta\leq 2\pi$. By definiton, the contour integral in $\gamma(\theta)$ is:

$$\oint_{\gamma} f(z) dz = \int_{0}^{2\pi} f(\gamma(\theta))\gamma'(\theta) d\theta = \int_{0}^{2\pi} \frac{F(e^{i\theta})}{e^{i\theta}i} ie^{i\theta} d\theta = \int_{0}^{2\pi} F(e^{i\theta}) d\theta $$

So, whenever you find an integral of the type $\int_{0}^{2\pi} F(e^{i\theta}) d\theta$ try to evaluate it converting it in a contour integral and then applying the techniques of complex integration.

  • $\begingroup$ Hm reading over this, I can't follow how you converted the regular integral to a contour integral. Would you mind expanding and elaborating that process? $\endgroup$
    – Max0815
    Oct 29, 2021 at 2:53
  • $\begingroup$ Sure @Max0815, I will explain further $\endgroup$
    – Bertrand87
    Oct 29, 2021 at 4:09
  • 1
    $\begingroup$ @Max0815 I have added an Appendix explaining the method. Additionally, a somewhat similar explanation is given in Complex Variables and Applicaitons by Churchill et. al. , third edition, page 187. $\endgroup$
    – Bertrand87
    Oct 29, 2021 at 5:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .