Artificial intelligent assistant

$\int_0^\pi \tan(\theta + \text{i}a)\text{d}\theta$ =? Solve the integration $$\int_0^\pi \tan(\theta + \text{i}a)\text{d}\theta$$ Where $a\in \mathbb R$ and $a \neq 0$ The method I took is to let $$z=e^{i\theta}$$ and since $$\tan(\theta+ia)=\frac{\sin(\theta+ia)}{\cos(\theta+ia)}=\frac{\sin\theta\cos ia+\sin ia\cos \theta}{\cos\theta\cos ia-\sin\theta\sin ia}$$ So we can do a complex substitution. However, I got something like: $$\int_{C}\frac{(cha+sha)z^2+sha-cha}{iz((cha-sha)z^2+cha+sha)}dz$$ And its singularity is awkward to me. Where am I wrong? Or is there a better solution? Thank you a lot!

**Hint:**

Separating into real and imaginary components,

$$\tan{\left(\theta+ia\right)}=\frac{\sin{(2\theta)}}{\cos{(2\theta)}+\cosh{(2a)}}+i\frac{\sinh{(2a)}}{\cos{(2\theta)}+\cosh{(2a)}}.$$

Then, integrating over $0\le\theta\le\pi$ we see that the real part of the integral vanishes:

$$\begin{align} \int_{0}^{\pi}\tan{\left(\theta+ia\right)}\,\mathrm{d}\theta &=\int_{0}^{\pi}\frac{\sin{(2\theta)}}{\cos{(2\theta)}+\cosh{(2a)}}\,\mathrm{d}\theta+i\int_{0}^{\pi}\frac{\sinh{(2a)}}{\cos{(2\theta)}+\cosh{(2a)}}\,\mathrm{d}\theta\\\ &=-\frac12\int_{1}^{1}\frac{\mathrm{d}u}{u+\cosh{(2a)}}+i\int_{0}^{\pi}\frac{\sinh{(2a)}}{\cos{(2\theta)}+\cosh{(2a)}}\,\mathrm{d}\theta\\\ &=i\int_{0}^{\pi}\frac{\sinh{(2a)}}{\cos{(2\theta)}+\cosh{(2a)}}\,\mathrm{d}\theta. \end{align}$$

The imaginary integral can be evaluated using the tangent-half-angle substitution.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 4d15653576a5360e3f5f0ad7df247c50