Calculating the following integral using complex analysis: $\int_{0}^{\pi}e^{a\cos(\theta)}\cos(a\sin(\theta))\, d\theta$

Solution 1:

As noted in Emmet´s comment, there is an error in your computation: when $\theta=\pi$ $z=-a$, not $-i\,a$ ($e^{\pi i}=-1$).

The computation becomes easier by noting that the integrand is even, so that it is one half of the integral between $0$ and $2\,\pi$. After the change of variables the integral becomes a line integral along the unit circle, and you can apply Cauchy's theorem or the calculus of residues.

I will work backwards. Consider the integral $$ \int_{|z|=1}\frac{e^{az}}{i\,z}\,dz. $$ By Cauchy's theorem its value is $2\,\pi$. Now let $z=e^{it}$. Then \begin{align*} \int_{|z|=1}\frac{e^{az}}{i\,z}\,dz&=\int_0^{2\pi}e^{ae^{it}}\frac{i\,e^{it}\,dt}{i\,e^{it}}\\ &=\int_0^{2\pi}e^{a(\cos t+i\sin t)}dt\\ &=\int_0^{2\pi}e^{a\cos t}\cos(a\sin t)\,dt+i\int_0^{2\pi}e^{a\cos t}\sin(a\sin t)\,dt. \end{align*} Finally, we get $$ \int_0^{\pi}e^{a\cos t}\cos(a\sin t)\,dt=\pi. $$