Residue of $\frac{g(z)}{\cos^{2}z}$ I would like to show that the residue of the function $$\text{Res}\left(\frac{g(z)}{\cos^{2}z}\right) = g'(z_n)$$ at $z_{n}=(n+\frac{1}{2})\pi$, where $g$ is analytic.
I tried the Limit formula for higher order poles and it fails. What other method can  I use?
 A: Using the addition theorem for the cosine and the fact that
$\sin(z_n) = \pm 1$, $\cos(z_n) = 0$, you can compute the initial part of the
Taylor series for $\cos^2(z_n + h)$ at $h = 0$:
$$
\cos^2(z_n + h) = \sin^2(h) = \bigl( h + \frac{h^3}{3!} + O(h^5) \bigr)^2 \\
 = h^2 \bigl( 1 + \frac{h^2}{6} + O(h^4) \bigr)^2 \\
 = h^2 \bigl( 1 + \frac{h^2}{3} + O(h^4) \bigr) 
\quad \text{ for } h \to 0
$$
It follows that
$$
\frac{1}{\cos^2(z_n + h)} = \frac{1}{h^2} \bigl( 1 - \frac{h^2}{3} + O(h^4) \bigr) \\
 = \frac{1}{h^2} - \frac 13 + O(h^2)
$$
Now multiply that with
$$
  g(z_n + h) = g(z_n) + g'(z_n) h + O(h^2)
$$
to get
$$
\frac{g(z_n+h)}{\cos^2(z_n + h)} = \frac{g(z_n)}{h^2} + \frac{g'(z_n)}{h} + O(1)
\quad \text{ for } h \to 0
$$
Finally, substitute $z = z_n + h$:
$$
\frac{g(z)}{\cos^2(z)} = \frac{g(z_n)}{(z-z_0)^2} + \frac{g'(z_n)}{z-z_n} + O(1)
\quad \text{ for } z \to z_n
$$
and the residuum is the coefficient of $(z-z_n)^{-1}$ in the
Laurent series, which is $g'(z_n)$.
A: $z_n$ is a double zero of $h(z)=\cos^2(z)$.
The limit formula for double poles is
$$
\mathrm{Res}(f,c) = \lim_{z \to c} \frac{d}{dz}\left( (z-c)^{2}f(z) \right)
$$
Thus, if $f(z)=\dfrac{g(z)}{h(z)}$ and $c$ is a double zero of $h$, then $h(z)=(z-c)^2 H(z)$, with $H(c)\ne0$, and
$$
\mathrm{Res}(f,c)
= \lim_{z \to c} \frac{d}{dz}\left( (z-c)^{2}f(z) \right)
= \lim_{z \to c} \frac{d}{dz} \frac{g(z)}{H(z)}
= \left. \left( \frac{g(z)}{H(z)} \right)'\right|_{z=c}
= \frac{g'(c)H(c)-g(c)H'(c)}{H^2(c)}
$$
Now, $H(c)=\dfrac{h''(c)}{2}$ and $H'(c)=\dfrac{h'''(c)}{6}$.
In your case, 
$\quad h'(z)=-2 \cos(z) \sin(z)=-\sin(2z)$
$\quad h''(z)=-2\cos(2z) \implies H(z_n)=1$
$\quad h'''(z)=4\sin(2z) \implies H'(z_n)=0$
Thus, 
$
\mathrm{Res}(f,z_n) = g'(z_n)
$.
