$\int _{C} (z^3 + 2z +{\bf Re} z)\,dz$ where C is a triangle of vertices $z=0$, $z=1+2i $ and $z=1$. 
How do I compute 
  $ \int _{C} (z^3 + 2z +{\bf Re} z)\,dz$ where C is a triangle of vertices $z=0$, $z=1+2i $ and $z=1$.

The solution given is $i$
Anyone showing me how to deal with these problems will be extremely helpful, as this entire subject quite unclear to me.
 A: The function $z^3+2z$ in triangle is analytic so it's integral over $C$ is zero. With paramerization of $C$ we have
\begin{cases}
C_1:~t+2it&0\leq t\leq1, \\
C_2:~1+2i(1-t)&0\leq t\leq1, \\
C_3:~1-t&0\leq t\leq1.
\end{cases}
this parametrization is counter-clockwise (according to the vertices in the question), so we split the integral over $C$:
\begin{align}
\int_{C} (z^3 + 2z +{\bf Re} z)dz 
&= \int_{C} {\bf Re} z\,dz  \\
&= \int_{C_1} {\bf Re} z\,dz+\int_{C_2} {\bf Re} z\,dz+\int_{C_3} {\bf Re} z\,dz \\
&= \int_0^1t(1+2i)\,dt+\int_0^1-2i\,dt+\int_0^1(1-t)(-1)\,dt \\
&= \int_0^1(2t+2it-2i-1)\,dt \\
&= \color{blue}{-i}
\end{align}
if we change the direction of path, we will have $i$ as answer instead of $-i$.
A: Alternatively, you say that $z=x+yi$ and rewrite the integral as $\oint_C\left[(x+yi)^3+2(x+yi)+x\right]\,\left(\mathrm{d}x+i\mathrm{d}y\right)$. This is a simple closed curve on the complex plane therefore we can use greens theorem (who’s complex equivalent I cannot remember)
\begin{align*}
\oint_C\left[(x+yi)^3+2(x+yi)+x\right]\,\mathrm{d}x+ \left[(x+yi)^3+2(x+yi)+x\right] i\mathrm{d}y&=\iint_Di\left(3(x+yi)^2+3\right)-\left(3i(x+yi)^2(i)+2i\right)\,\mathrm{d}A\\
&=i\iint_D 3(x+yi)^2+3-3(x+yi)^2-2\,\mathrm{d}A\\
&=i\iint_D\,\mathrm{d}A
\end{align*} 
The triangular region we are integrating along is simply a right triangle with a height of 2 and base of 1 so the area is simply $\frac12(1)(2)=1$ Multiplying this by $i$ we get the final answer of $i$
