I need to compute:
$$ I = \int_{-\frac{\pi}{2}}^{\frac{\pi}{2}}\frac{i}{9 e^{i 2 \theta} + 1}d\theta $$
The indefinite integral above is:
$$ F(\theta)= i \theta - \frac{1}{2} \log(1 + 9 e^{2 i \theta}) $$
According to Wolfram Alpha and my own computation.
The problem is that if I assign the values of the limit myself to it I get:
$$ F(\frac{\pi}{2}) - F(-\frac{\pi}{2}) = \\ i (\frac{\pi}{2} - (-\frac{\pi}{2}))-\frac{1}{2} \left (\log(1+9 e^{2 i\frac{\pi}{2}}) -\log(1+9e^{2 i \cdot (-\frac{\pi}{2})}\right ) = \\ i \pi -\frac{1}{2}\left ( \log(\frac{1-9}{1-9})\right ) = i\pi $$
And wolfram's solution for the definite integral is $0$ (link).
Why? Is it related to the principal value of the natural logarithm?
Definitely related to the natural logarithm. When $\theta=-\pi/2$ we may take the argument to be $9(-1)+1=8e^{-\pi i}$. As $\theta$ increases from $-\pi/2$ to $\pi/2$, $9e^{2i\theta}+1$ circles the point $z=1$ counterclockwise in the complex $z$-plane so that when $\theta=0$ it will be $10e^{i0}$ and by the time $\theta=\pi/2$ it will be $8e^{\pi i}$ so $$F(\pi/2)-F(-\pi/2)=\left(i\frac{\pi}2-\frac12\left(\pi i+\ln8\right)\right)-\left(-i\frac{\pi}2-\frac12\left(-\pi i+\ln8\right)\right)=0$$ Since the magnitude is never $0$ the phase must change continuously.
EDIT: Another way to think about it to say that $$\begin{align}F(\theta)&=i\theta-\frac12\ln\left(1+9e^{2i\theta}\right)\\ &=-\frac12\ln\left(e^{-2i\theta}\right)-\frac12\ln\left(1+9e^{2i\theta}\right)=-\frac12\ln\left(e^{-2i\theta}+9\right)\end{align}$$ And now as $\theta$ changes the path doesn't circle a branch point so it's not so critical to think about the phase of the argument of the natural logarithm.