Proving $\int_{0}^\pi \frac{2\cos 2\theta + \cos 3\theta}{5+4\cos\theta} = \frac{\pi}{8}$ Given that $$\int_{|z|=1|}\frac{z^2}{2z+1} dz = \frac{i\pi}{4}$$,
show $$\int_{0}^\pi \frac{2\cos 2 \theta + \cos 3\theta}{5+4\cos\theta} = \frac{\pi}{8}$$.  
I saw the bounds of the latter integral and thought that I should try and parametrize using $z = e^{2i\theta}$ where $\theta \in [0,\pi]$.
This doesn't seem to simplify easily.
i saw this thread: Show that $\int_0^\pi\frac{2\cos(2\theta)+\cos(3\theta)}{5+4\cos(\theta)}d\theta=\frac{\pi}{8}$ 
and the top answer says:
$$\begin{align}
\int_0^\pi \frac{2\cos(2\theta)+\cos(3\theta)}{5+4\cos(\theta)}\,d\theta&=\frac12\text{Re}\left(\oint_{|z|=1}\frac{2z^2+z^3}{5+2(z+z^{-1})}\,\frac{1}{iz}\,dz\right)\\\\\end{align}$$
which I don't understand.   
How does multiplying a half to the integral with contour $|z|=1$ (parametrized by $z = e^{i\theta}, \theta\in [0,2\pi]$) give the LHS?  
I tried looking at it by taking the latter integral and using the substitution $u=\pi + \theta$, in hopes that the integrand simplifies to stay the same but it doesn't, so I can't see why the integral with bounds $0,\pi$ is half the integral that would have bounds $0,2\pi$ (since we would use the parametrization $z=e^{i\theta}$).

Note that 
$$2\int^\pi_0 \cos(n\theta)f(\cos \theta ) d\theta = \int^{\pi}_{-\pi} \cos(n\theta)f(\cos\theta ) d \theta $$
Now you can use that $\gamma(t) = e^{i t}$ where $t \in [-\pi , \pi )$ to prove 
$$\Re \oint_{|z|=1} z^n f\left(\frac{z+z^{-1}}{2} \right) \frac{dz}{iz} = 2\int^\pi_0 \cos(n\theta)f(\cos \theta ) d\theta $$
Or any linear combination 
$$\Re \oint_{|z|=1} (az^n+bz^m) f\left(\frac{z+z^{-1}}{2} \right) \frac{dz}{iz} = 2\int^\pi_0 (a\cos(n\theta)+b \cos(m\theta))f(\cos \theta ) d\theta $$
So we have by choosing $n=2,m=3,a=2,b=1$
$$\Re \oint_{|z|=1} \frac{z^3+2z^2}{5+2(z+z^{-1})} \frac{dz}{iz} =2\int^{\pi}_{0}\frac{\cos(3t)+2\cos(2t)}{5+4\cos(t)}dt $$
Note that 
$$\frac{z^3+2z^2}{5+2(z+z^{-1})} \frac{1}{z} = \frac{z^2(z+2)}{(z+2)(2z+1)} = \frac{z^2}{2z+1}$$
So we deduce that 
$$2\int^{\pi}_{0}\frac{\cos(3t)+2\cos(2t)}{5+4\cos(t)}dt =-i \Re \oint_{|z|=1}  \frac{z^2}{2z+1} = \frac{\pi}{4}$$
