Finding $\int_0^\pi\frac{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)}{1+2p\cos(x)+p^2}\mathrm dx$ Let $f$ be a analytic function in the closed unit circle with its center
at the point $\alpha\in\mathbb{R}$, then:
\begin{equation*}
\int_0^\pi\frac{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)}{1+2p\cos(x)+p^2}\mathrm dx=\frac{2\pi}{1-p^2}f(\alpha+p) ,
\end{equation*}
for $|p|<1$.
My attempt: By
\begin{align*}
\therefore\quad \sum_{n=1}^{\infty}p^{n}\sin(nx)=\frac{p\sin (x)}{1-2p\cos (x)+p^2},\qquad|p|<1
\end{align*}
adjusting $p\to -p$ and highlighting $\displaystyle \frac1{1+2p\cos(x)+p^2}$:
\begin{align*}
\frac1{1+2p\cos(x)+p^2}=-\frac{1}{\sin(x)}\sum_{n=1}^\infty(-p)^{n}\sin(nx).
\end{align*}
Thus:
\begin{align*}
\int_0^\pi\frac{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)}{1+2p\cos(x)+p^2}\mathrm dx=-\sum_{n=1}^\infty(-p)^{n}\int_0^\pi\left\{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)\right\}\frac{\sin(nx)}{\sin(x)}\mathrm dx\tag{1}
\end{align*}
by the \textit{Dirichlet Kernel}: $\displaystyle \sum_{k=0}^{N-1}e^{2ikx}=e^{(N-1)x}\frac{\sin(Nx)}{\sin(x)}$ setting $N\to n$, $n\in\mathbb{N}$ and then taking $(1)$, follows that:
\begin{align*}
&=-\sum_{n=1}^\infty(-p)^{n}\sum_{k=0}^{n-1}\int_0^\pi\left\{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)\right\}e^{-(n-1)x}e^{2ikx}\mathrm dx,\quad\left(e^{ix}\to z\right)\\
&=...
\end{align*}
At this point I'm out of ideas. I would like some light on my last step, or another approach that is similar to this one.
 A: Integrate as follows
\begin{align}
&\int_0^\pi\frac{f\left(\alpha+e^{ix}\right)+f\left(\alpha+e^{-ix}\right)}{1+2p\cos x+p^2} dx\\
=&\int_0^\pi\frac{2\Re f\left(\alpha+e^{ix}\right)}{1+2p\cos x+p^2} dx
= 2\int_0^\pi\frac{\sum_{k=0}^\infty \frac{f^{(k)}(a)}{k!} \cos(kx)}{1+2p\cos x+p^2} dx\\
=& \> 2\sum_{k=0}^\infty \frac{f^{(k)}(a)}{k!} \int_0^\pi \frac{\cos(kx)}{1+2p\cos x+p^2} dx\\
 =& \> 2\sum_{k=0}^\infty \frac{f^{(k)}(a)}{k!}\cdot \frac{\pi (-p)^k}{1-p^2}=
\frac{2\pi}{1-p^2}f(\alpha-p)
\end{align}
where
$$\eqalign{
\frac{1-p^2}{1+2p\cos x+p^2}
=1+2\sum_{j=1}^\infty (-p)^j\cos(j x)
}
$$
is used to integrate
$\int_0^\pi \frac{\cos(kx)}{1+2p\cos x+p^2} dx=\frac{\pi (-p)^k}{1-p^2}$.
A: If we convert the integral into a contour integral, we get
$$ \begin{align} \int_{0}^{\pi} \frac{f(\alpha+e^{ix})+f(\alpha+e^{-ix})}{1+2p \cos x +p^{2}} \, \mathrm dx &=  \frac{1}{2}\int_{-\pi}^{\pi} \frac{f(\alpha+e^{ix})+f(\alpha+e^{-ix})}{1+2p \cos x +p^{2}} \,  \mathrm dx \\ &= \int_{-\pi}^{\pi}\frac{f(\alpha+e^{ix})}{1+2p \cos x +p^{2}} \, \mathrm dx \\&= \int_{-\pi}^{\pi} \frac{f(\alpha +e^{ix})}{(e^{ix}+p)(e^{-ix}+p)} \, \mathrm dx \\ &= \int_{|z|=1} \frac{f(\alpha + z)}{(z+p)(\frac{1}{z}+ p)} \frac{dz}{iz} \\ &=  \int_{|z|=1} \frac{f(\alpha +z)}{(z+p)(1+pz)} \, \frac{\mathrm dz}{i}.  \end{align}$$
Since $|p| <1$, the only singularity inside the unit circle is a simple pole at $z=-p$.
Therefore, $$ \begin{align} \int_{0}^{\pi}\frac{f(\alpha+e^{ix})+f(\alpha+e^{-ix})}{1+2p \cos x +p^{2}} \, \mathrm dx &=   2 \pi i \operatorname{Res} \left[ \frac{f(\alpha +z)}{i(z+p)(1+pz)}, -p \right] \\ &= \frac{2\pi f(\alpha \color{red}{-}p)}{1-p^{2}}. \end{align}$$

If $|p| <1$ and not equal to zero, we also have $$ \begin{align} \int_{0}^{\pi} \frac{f(\alpha+e^{ix})+ f(\alpha+e^{-ix})}{1+2p \cos (x) +p^{2}} \, \cos (x) \, \mathrm dx &=  \frac{1}{2}\int_{-\pi}^{\pi} \frac{f(\alpha+e^{ix})+f(\alpha+e^{-ix})}{1+2p \cos (x) +p^{2}} \, \cos (x) \,  \mathrm dx \\ &=\int_{-\pi}^{\pi} \frac{f(\alpha+e^{ix})}{1+2p \cos (x) +p^{2}} \, \cos (x) \,  \mathrm dx \\ &= \int_{-\pi}^{\pi} \frac{f(\alpha+e^{ix})}{(e^{ix}+p)(e^{-ix}+p)} \, \frac{\left(e^{ix}+e^{-ix} \right)}{2} \,  \mathrm dx \\ &= \int_{|z|=1} \frac{f(\alpha+z)}{(z+p)(\frac{1}{z}+p)} \, \frac{1}{2} \left(z+\frac{1}{z} \right) \,  \frac{\mathrm dz}{iz} \\ &= \int_{|z|=1} \frac{f(\alpha+z)}{(z+p)(1+pz)} \, \frac{1+z^{2}}{2iz} \,  \mathrm dz \\ &=   2 \pi i \left(\frac{f(\alpha - p)}{1-p^{2}} \frac{1+p^{2}}{-2ip}+ \frac{f(\alpha)}{2ip} \right) \\ &= \frac{\pi}{p} \left(f(\alpha)- \frac{1+p^{2}}{1-p^{2}} \, f(\alpha -p) \right). \end{align}$$
At $p=0$, we get $$ \int_{0}^{\pi} \left(f(\alpha+e^{ix})+f(\alpha+e^{-ix}) \right) \cos(x) \, \mathrm dx = \lim_{p \to 0} \frac{\pi}{p} \left(f(\alpha)- \frac{1+p^{2}}{1-p^{2}} \, f(\alpha -p) \right) = \pi f^{\prime}(\alpha). $$

Finally, if $|p| <1$ and not equal to zero, $$ \begin{align} \int_{0}^{\pi} \frac{f(\alpha+e^{ix})\color{red}{-} f(\alpha +e^{-ix})}{1+2p \cos(x) + p^{2}} \, \sin(x)  \,  \mathrm dx &=  \int_{|z|=1} \frac{f(\alpha+z)}{(z+p)(1+pz)} \, \frac{1-z^{2}}{2z} \,  \mathrm dz \\ &=  2 \pi i \left(\frac{f(\alpha-p)}{1-p^{2}} \frac{1-p^{2}}{-2p} + \frac{f(\alpha)}{2p}\right) \\ &=\frac{\pi i}{p} \left(f(\alpha) - f(\alpha-p) \right). \end{align}$$
And at $p=0$, we get $$ \int_{0}^{\pi}\left(f(\alpha+e^{ix})\color{red}{-} f(\alpha +e^{-ix})\right)\, \sin(x)   \mathrm dx = \pi i f^{\prime}(\alpha)$$
