How do I evaluate the residue at $z=0$ of $\oint_{|z|=1} \frac{z^n+z^{-n}}{2iz(1-rz)(1-rz^{-1})}dz$? I am trying to evaluate the following contour integral by evaluating the residue at $z=0$ of the integrand.
$$I=\oint_{|z|=1} \frac{z^n+z^{-n}}{2iz(1-rz)(1-rz^{-1})}dz.$$
We can manipulate the integrand (which we denote by $f(z)$) and ignore the term with positive $z$ exponent to get
$$\mathop{\rm Res}_{z=0}f(z) = \mathop{\rm Res}_{z=0} \frac{z^{-n}}{2i(1-rz)(z-r)}.$$
I am not quite sure what to do here. I'm not sure how to deal with a pole that isn't just a simple pole. How do I deal with this?
 A: $\newcommand{\d}{\,\mathrm{d}}$I’d like to note that: $$I=\int_0^{2\pi}\frac{\cos(n\phi)}{1-2r\cos(\phi)+r^2}\d\phi$$
Anyway. To find a more difficult residue like this I recommend the use of Laurent series expansions. Presumably $r\neq0$ (else the integral is just $2\pi\delta_{n,0}$, by looking at the real form, so the residue must be $-i\delta_{n,0}$). Also, $|r|\neq1$ must be asserted.
Then for all small $|z|<\min(|r|,|r|^{-1})$ let’s expand the integrand as: $$-\frac{1}{2ir}(z^n+z^{-n})\sum_{m\ge0}(rz)^m\sum_{m\ge0}(z/r)^m$$Since the term corresponding to multiplication by $z^n$ is ($n\ge0$) a holomorphic function on a neighbourhood of zero we can ignore that for the residue calculation. It then remains to determine the $(n-1)$th coefficient in: $$-\frac{1}{2ir}\sum_{m\ge0}(rz)^m\sum_{m\ge0}(z/r)^m$$Which is zero when $n=0$ and otherwise just: $$-\frac{1}{2ir}\sum_{k=0}^{n-1}r^k\cdot r^{-(n-1-k)}=-\frac{1}{2i}r^{-n}\cdot\frac{r^{2n}-1}{r^2-1}$$
I initially deleted this answer many times because my results were contradicting numerical evaluation of the real integral. However, the mistake that you may also be making is that there is also a pole at $z=r$ if $|r|<1$ and at $z=r^{-1}$ if $|r|>1$ which are enclosed by the contour. The residue at this pole, for $|r|<1$, is simply $\frac{1}{2i}\frac{r^n+r^{-n}}{1-r^2}$. In sum that finds: $$I(r)=\frac{2\pi}{1-r^2}\cdot r^n$$For integer $n>0$ and all (even $r=0$) complex $r$ in the unit disk.
A: For calculating residue integrals the term we are interested in is the coefficient of $\frac{1}{z}$ in the Laurant expansion around 0. For example if we were integrating $\frac{1}{z} + \frac{3}{z^2}$ around 0, then the only term that would contribute is the $\frac{1}{z}$ term, and so the residue would be $1$.
There is a general formula that will pick up this term given any function, that looks like:
Suppose $f$ has a pole of order $m$ about $z_0$. Then,
$$\text{Res}_{z_0}(f) = \lim_{z \rightarrow z_0} \frac{1}{(m-1)!} \frac{d^{m-1}}{dz^{m-1}} ((z-z_0)^mf(z))$$
However in practice this often leads to difficult calculations. The "reason" this formula is true, is supposing we are intergrating $f(z) = \sum_{k \geq -m}a_k z^m$ around $z_0 = 0$. Then the residue is given by $a_{-1}$, so to pick this term out we can multiply $f(z)$ by $z^m$ to get a holomorphic function, and then use the standard Taylor's formula to pick out the term $a_{-1}$ (which will now be the coefficient of $z^{m-1}$ in $g(z) = z^mf(z)$.
In your example the best way to procede would be to use partial fractions to split the integrand up into terms of the form $z^{-n}/({1-bz})$, for some $b$. And then write $1/(1-bz) = \sum_{k=0}^\infty (bz)^k$, for $z$ small enough. You can then multiply all these terms by $z^{-n}$ and add them together, at which point you should be able to pick out the term $a_{-1}$
