TITLE: How to compute the following integral in complex analysis?
QUESTION [6 upvotes]: Let $C$ denote the unit circle centered at origin in $\mathbb{C}$. Then $$\frac{1}{2\pi i}\int_C|1+z+z^2|\,dz$$  where the integral is taken anti-clockwise in along $C$, equals what?
Well I start with putting $z = e^{i \theta}$, $0 \leq \theta \leq 2\pi$. Then $$\frac{1}{2\pi i}\int_C|1+z+z^2|\,dz = \frac{1}{2\pi i} \int_{0}^{2\pi} \sqrt{3+2\cos(\theta)}\,  e^{i \theta} \,i\, d \theta$$
Am I going in the right manner? How do I proceed further?

REPLY [2 votes]: Note that on $|z|=1$ we have $\bar z=1/z$.  Hence on the unit circle
$$\begin{align}
|1+z+z^2|&=\sqrt{(1+z+z^2)\,\overline{(1+z+z^2)}}\\\\
&=\sqrt{\left(1+z+z^2\right)\left(1+\frac1z+\frac1{z^2}\right)}\\\\
&=\sqrt{\left(\frac1z+1+z\right)^2}\\\\
&=|2\cos(\theta)+1|\tag1
\end{align}$$
Using $(1)$, we find that 
$$\begin{align}
\oint_{|z|=1}|1+z+z^2|\,dz&=i\int_{0}^{2\pi}|2\cos(\theta)+1|\cos(\theta)\,d\theta\\\\
&=i\left(\sqrt 3+\frac{2\pi}{3}\right)
\end{align}$$