Calculate the following integral for $n \in \mathbb{Z}$ with the residue theorem $$\int_{0}^{2\pi} \frac{\cos((2n+1)t)}{\cos(t)}dt$$
So far I have tried two approaches. Firsty, for $n\geq 0$: $$\begin{align*}\int_{0}^{2\pi} \frac{\cos((2n+1)t)}{\cos(t)}dt &= \int_{C(0,1)^{+}} \frac{z^{2n+1}+z^{-(2n+1)}}{z+z^{-1}}\cdot \frac{1}{iz}dz \\ & = -i \int_{C(0,1)^{+}} \frac{z^{2n+1}+z^{-(2n+1)}}{z^2+1}dz \\ & = -i \int_{C(0,1)^{+}} \frac{z^{2(2n+1)}+1}{z^{2n+1}(z^2+1)}dz \\ & = -i \cdot 2\pi i \cdot Res_{z=0}\left(\frac{z^{2(2n+1)}+1}{z^{2n+1}(z^2+1)}\right) \\ & = \left.\frac{2\pi}{(2n)!} \left[ \frac{z^{2(2n+1)}+1}{z^2+1} \right]^{(2n)} \right\rvert_{z=0} \end{align*}$$
For the first equality I used the reversed parametrization $z(t) = e^{it}$, with $0 \leq t \leq 2\pi$. The last equality follows from $Res_{z=a} \left( \frac{f(z)}{(z-a)^{n+1}}\right) = \frac{f^{(n)}(a)}{n!}$. However, I'm not sure how to calculate that derivative.
Seconldy, I tried to integrate the function $f(z) = \frac{e^{i(2n+1)t}}{cos(t)}$. Using a similar technique this yields:
$$\begin{align*} \int_{0}^{2\pi} \frac{e^{i(2n+1)t)}}{\cos(t)}dt &= \int_{C(0,1)^{+}} \frac{z^{2n+1}}{(z+z^{-1})/2}\cdot \frac{1}{iz}dz \\ & = -2i\int_{C(0,1)^+}\frac{z^{2n+1}}{z^2+1}dz \end{align*}$$
However, for $n \geq 1$, the singularities lie on my contour over which I integrate. How do I fix this? Can I just ignore that?
Is this the right approach, or should I try differently? Thanks in advance.