Calculate $\int_0^{2\pi} \tan \frac{\theta}8 d\theta $ using complex analysis

Professor gave me the problem that calculates below real integral using complex analysis.

$$\int_0^{2\pi} \tan \frac{\theta}8 d\theta $$

Actually this integral can easily be calculated just substituting $t=\cos\frac{\theta}8$, but the professor requested me to calculate this integral using complex analysis.

As far as I know, if we want to calculate a real integral that consists of trigonometric functions, we can substitute $z=e^{i\theta}$ then $\cos\theta=\dfrac{z+\frac 1z}2$ and $\sin\theta=\dfrac{z-\frac 1 z}{2i}$ where the contour is the unit circle.

But $\frac \theta 8$ holds me back. How can I treat this? I tried to substitute $z^{1/8}=e^{i\theta/8}$, but still challenging.


Solution 1:

As you have identified the issue of branch cuts when taking a fractional power, the problem may be easier to handle using a line integral rather than a closed contour: \begin{align}\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\int_0^{2\pi}\tan\frac\theta8\,d\theta&=4\int_0^{\pi/2}\tan\frac t2\,dt\tag{$\theta=4t$}\\&=-4i\int_0^{\pi/2}\frac{e^{it}-1}{e^{it}+1}\,dt\tag{complex expansion}\\&=-4\int_\gamma\frac{z-1}{z(z+1)}\,dz\tag{$\gamma(t)=e^{it},t\in[0,\pi/2]$}\\&=-4\int_\gamma\left(\frac2{z+1}-\frac1z\right)\,dz\tag{partial fractions}\\&=-4\left[2\log(z+1)-\log z\right]_{e^{i0}}^{e^{i\pi/2}}\tag{FTC for line integrals}\\&=-4(2\log(1+i)-\log i-2\log2)\\&=4\log 2\end{align}