What is wrong in evaluating $\int_{0}^{2\pi} e^{\cos x} \cos (\sin x)\:dx$ Find value of $I=\int_{0}^{2\pi} e^{\cos x} \cos (\sin x)\:dx$
I have done it as follows:
we know that  $$\int_{0}^{2a}f(x) dx=2 \int_{0}^{a} f(x)dx$$ if $f(2a-x)=f(x)$
Now if $f(x)=e^{\cos x} \cos (\sin x)$, we have
$$f(2\pi-x)=f(x)$$
hence $$I=2\int_{0}^{\pi} e^{\cos x} \cos (\sin x)\:dx=2 \times Re\left\{\int_{0}^{\pi} e^{e^{ix}}dx\right\}$$
Now let
$$J=\int_{0}^{\pi} e^{e^{ix}}dx$$
Put $e^{ix}=t$, Then limits will switch over to $-1$ and $1$
Also
$$e^{ix} i dx=dt$$
so
$$dx=\frac{dt}{it}$$
So
$$J=i \times \int_{-1}^{1}\frac{e^t \:dt}{t}$$
So $J$ is Purely imaginary and hence $I=0$
Can i know what went wrong in my solution?
 A: The error is mentioned by @user296602 and @Fred. Below is a correct way to solve it.
Consider
$$f:z\mapsto \frac{e^z}{z}$$
For $0<\epsilon<1$, we have
$$0=\int_\epsilon^1\frac{e^x}{x}dx+\int_0^{\pi}\frac{e^{e^{it}}}{e^{it}}ie^{it}dt+\int_{-1}^{-\epsilon}\frac{e^x}{x}dx+\int_{\pi}^0\frac{e^{\epsilon e^{it}}}{\epsilon e^{it}}i\epsilon e^{it}dt$$
As $\epsilon\to 0$,
$$\int_0^{\pi}{e^{e^{it}}}dt=\int_0^{\pi}dt+i\int_0^1\frac{e^x-e^{-x}}{x}dx$$
Thus,
$$\operatorname {Re}(J)=\pi$$
A: Let $t(x)=e^{ix}$ for $x \in I:=[0, \pi]$.
You have assumed that $t(I)=[-1,1]$, but this is wrong. 
We have $t(I)=\{z \in \mathbb C: |z|=1, Im(z) \ge 0\}$ (a "half circle").
A: Here is an approach that avoids complex analysis altogether.
Let 
$$I(\theta) = \int_0^{2\pi} e^{\theta \cos x} \cos (\theta \sin x) \, dx, \quad \theta \in \mathbb{R}$$
Observe that $I(0) = 2\pi$.
Now using Feynman's trick of differentiating the the integral sign with respect to the parameter $\theta$, we have
$$I'(\theta) = \int_0^{2\pi} \frac{\partial}{\partial \theta} \left [e^{\theta \cos x} \cos (\theta \sin x) \right ] \, dx. \tag1$$
Observing that
$$\frac{\partial}{\partial \theta} \left [e^{\theta \cos x} \cos (\theta \sin x) \right ] = \frac{1}{\theta} \frac{\partial}{\partial x} \left [e^{\theta \cos x} \sin (\theta \sin x) \right ],$$
(1) becomes
$$I'(\theta) = \frac{1}{\theta} \int_0^{2\pi} \frac{\partial}{\partial x} \left [e^{\theta \cos x} \sin (\theta \sin x) \right ] \, dx = \frac{1}{\theta} \left [e^{\theta \cos x} \cos (\theta \sin x) \right ]_{x = 0}^{x = 2\pi} = 0.$$
Thus $I(\theta) = K$ where $K$ is a constant and can be found from $I(0) = 2\pi$. Thus
$$I(\theta) = \int_0^{2\pi} e^{\theta \cos x} \cos (\theta \sin x) \, dx = 2\pi.$$
Setting $\theta = 1$ returns the integral we seek, namely
$$I(1) = \int_0^{2\pi} e^{\cos x} \cos (\sin x) \, dx = 2\pi.$$
