How to compute the following integral in complex analysis?

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?

• Have you tried writing $e^{i\theta} = \cos\theta + i\sin\theta$ and computing the two resulting integrals separately? – MisterRiemann May 2 '18 at 17:57
• please check something called residue theorem – MoonKnight May 2 '18 at 18:08
• @MoonKnight How does one apply the residue theorem to evaluate the integral of interest?? – Mark Viola May 2 '18 at 21:29
• @Sobi How does your suggestion facilitate a way forward?? – Mark Viola May 2 '18 at 21:30
• @MarkViola Sorry, my bad. I did not notice the absolute value part. It is not an analytic function, so residue theorem does not apply here. – MoonKnight May 3 '18 at 22:35

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}