Evaluation of $\int \limits _0 ^{2 \pi} \frac {(r \cos \phi +x) \cos(n\phi)} {r^2+2xr \cos \phi +x^2} d\phi$ How to compute
$$\int \limits _0 ^{2 \pi} \frac {(r \cos \phi +x) \cos(n\phi)} {r^2+2xr \cos \phi +x^2} d\phi ?$$
The answer I am provided with is $\dfrac {(-1)^n\pi r^n} {x^{n+1}}$ for $\ x>r$, but I have no idea whether this is actually correct and how to get this.
 A: If I may add my two cents.  A 'real' method to consider. 
There are many Poisson-like series identities. A 'family' if you will.
One of those sums that can be derived from the geometric series:
$$\sum_{n=0}^{\infty}\frac{(-1)^{n}r^{n}}{x^{n+1}}\cos(n\theta)=\Re\left(\frac{1}{x}\cdot \frac{1}{1+\frac{re^{i\theta}}{x}}\right)=\frac{x+r\cos(\theta)}{r^{2}+2rx\cos(\theta)+x^{2}}, \;\ r<x$$
EDIT:
Something I just thought of that may be another approach. 
If we instead find, by whatever means (residues is a good approach, of course), $$\int_{0}^{2\pi}\frac{\cos(n\theta)}{r^{2}+2xr\cos(\theta)+x^{2}}d\theta=\frac{2(-1)^{n}\pi r^{n}}{x^{n}(x^{2}-r^{2})}**$$
then use it with the identity:
$$\frac{2x\cos(n\theta)}{x^{2}-r^{2}}\left(\frac{x+r\cos(\theta)}{r^{2}+2rx\cos(\theta)+x^{2}}-\frac{1}{2x}\right)=\frac{\cos(n\theta)}{r^{2}+2rx\cos(\theta)+x^{2}}$$
Expand and integrate both sides:
$$\frac{2x}{x^{2}-r^{2}}\int_{0}^{2\pi}\frac{(x+r\cos(\theta))\cos(n\theta)}{r^{2}+2rx\cos(\theta)+x^{2}}d\theta-\frac{1}{x^{2}-r^{2}}\int_{0}^{2\pi}\cos(n\theta)d\theta=\frac{2(-1)^{n}\pi r^{n}}{x^{n}(x^{2}-r^{2})}$$
The rightmost integral with just the cos term evaluates to 0. Multiply by $\frac{x^{2}-r^{2}}{2x}$ and obtain:
$$\int_{0}^{2\pi}\frac{(x+r\cos(\theta))\cos(n\theta)}{r^{2}+2rx\cos(\theta)+x^{2}}d\theta=\frac{2(-1)^{n}\pi r^{n}}{x^{n}(r^{2}-x^{2})}\cdot \frac{r^{2}-x^{2}}{2x}=\frac{(-1)^{n}\pi r^{n}}{x^{n+1}}$$
Please excuse any typos and let me know of them. Really easy in all that :)
** one way is to consider $$f(z)=\frac{z^{n}}{(1-rz)(1-r/z)}$$ and note the residue at $z=r$.  Then, do some manipulating by letting $r\to -r/x$.
Ergo, the residue at $z=r$ is $\frac{r^{n}}{1-r^{2}}$.
Thus, $$\int_{0}^{2\pi}\frac{\cos(n\theta)}{1-2r\cos*\theta)+r^{2}}d\theta=\frac{2\pi r^{n}}{1-r^{2}}$$
Let $r\to -r/x$ and obtain:
$$\int_{0}^{2\pi}\frac{x^{2}\cos(n\theta)}{x^{2}+2rx\cos(\theta)+r^{2}}d\theta=\frac{2\pi\cdot x^{2}(-1)^{n}r^{n}}{x^{n}(x^{2}-r^{2})}$$.
Multiply by $1/x^{2}$:
$$\int_{0}^{2\pi}\frac{\cos(n\theta)}{x^{2}+2rx\cos(\theta)+r^{2}}d\theta=\frac{2\pi (-1)^{n}r^{n}}{x^{n}(x^{2}-r^{2})}$$ 
From above, multiplying by the $\frac{x^{2}-r^{2}}{2x}$ gives the result needed. 
A: Suppose we seek to evaluate
$$\int_0^{2\pi} \frac{(r\cos\phi+x)\cos(n\phi)}{r^2+2xr\cos\phi+x^2}
\; d\phi.$$
Introduce $z=\exp(i\phi)$ so that $dz=iz \; d\phi$ to get
$$\int_{|z|=1}
\frac{(r(z+1/z)/2+x)(z^n+1/z^n)/2}{r^2+xr(z+1/z)+x^2}
\frac{dz}{iz}
\\ = \frac{1}{4i} \int_{|z|=1}
\frac{(r(z+1/z)+2x)(z^n+1/z^n)}{(r^2+x^2)z + xrz^2 + xr}
\; dz.$$
The denominator may be factored manually and we get
$$(xz+r)(rz+x)$$
so the poles are at $z=0$ and
$$\rho_0 = -r/x
\quad\text{and}\quad 
\rho_1 = -x/r$$
and with $r \lt x$ only $\rho_0$ is inside the contour.
We get for the residue at $\rho_0$
$$\frac{1}{4i} \left.
\frac{(r(z+1/z)+2x)(z^n+1/z^n)}{(r^2+x^2) + 2xrz}
\right|_{z=-r/x}
\\ = \frac{(-1)^n}{4i} 
\frac{(-r^2/x - x + 2x)((r/x)^n+(x/r)^n)}
{r^2+x^2-2r^2}
\\ = \frac{(-1)^n}{4ix} ((r/x)^n+(x/r)^n).$$
Supposing that  $n$ is  a non-negative integer  the only
remaining contribution is from the pole at zero of
$$\frac{1}{4i} \int_{|z|=\epsilon}
\frac{1}{z^n}
\frac{r(z+1/z)+2x}{(r^2+x^2)z + xrz^2 + xr}
\; dz.$$
Observe that
$$\frac{1}{(xz+r)(rz+x)}
= \frac{1}{x^2-r^2}\frac{1}{z+r/x}
- \frac{1}{x^2-r^2}\frac{1}{z+x/r}.$$
and that
$$[z^n] \frac{1}{z-\beta} =
\frac{1}{\beta} [z^n] \frac{1}{z/\beta-1}
= - \frac{1}{\beta^{n+1}}.$$
so that on performing coefficient extraction we obtain
$$\frac{1}{4i} \frac{1}{x^2-r^2}
\left(-r(-x/r)^{n-1}+r(-r/x)^{n-1}
- r(-x/r)^{n+1}+r(-r/x)^{n+1}
\\ - 2x(-x/r)^{n}+2x(-r/x)^{n}\right).$$
This is
$$\frac{1}{4i} \frac{1}{x^2-r^2} (-x/r)^{n-1}
(-r-r(-x/r)^2-2x(-x/r))
\\+ \frac{1}{4i} \frac{1}{x^2-r^2} (-r/x)^{n-1}
(r+r(-r/x)^2+2x(-r/x))
\\ = \frac{1}{4i} \frac{1}{x^2-r^2} (-x/r)^{n-1}
(-r+x^2/r)
\\+ \frac{1}{4i} \frac{1}{x^2-r^2} (-r/x)^{n-1}
(-r+r^3/x^2)
\\ = \frac{1}{4i} \frac{1}{r} (-x/r)^{n-1}
- \frac{1}{4i} \frac{r}{x^2} (-r/x)^{n-1}
\\ = - \frac{1}{4i} \frac{1}{x} (-x/r)^{n}
+ \frac{1}{4i} \frac{1}{x} (-r/x)^{n}.$$
Finally collect the contributions from both poles to get
$$2\pi i \times \frac{(-1)^n}{4ix}
\left(-(x/r)^n + (r/x)^n + (r/x)^n + (x/r)^n\right)
\\ = 2\pi i \times \frac{(-1)^n}{4ix}
\times 2 (r/x)^n
\\ = \frac{\pi (-1)^n}{x} \left(\frac{r}{x}\right)^n.$$
