Formula for Legendre polynomials by use of Cauchy's Integral Formula (From _Visual Complex Analysis_) I decided to look through Tristan Needham's Complex Analysis book since it's usually mentioned with great praise. Just doing some exercises, I got stuck on #4 of Chapter 9).
Here $P_n(z)$ denotes the $n$-th Legendre polynomial. I've been able to derive that
$$
P_n(z)=\frac{1}{2\pi i}\int_K\frac{(Z^2-1)^n}{2^n(Z-z)^{n+1}}dZ
$$
for $K$ any simple loop around $z$. 
Then the book says by taking $K$ to be a circle of radius $\sqrt{|z^2-1|}$ centered at $z$, 
$$
P_n(z)=\frac{1}{\pi}\int_0^\pi(z+\sqrt{z^2-1}\cos t)^n dt.
$$
I tried to rewrite the RHS of the original equation by reparametrizing $Z=z+\sqrt{|z^2-1|}e^{it}$. However, upon rewriting in terms of the standard substitutions, the integral becomes unmanageable. I have $dZ=i\sqrt{|z^2-1|}e^{it}dt$, $Z^2-1=z^2+2z\sqrt{|z^2-1|}e^{it}+|z^2-1|e^{2it}-1$, $(Z-z)=\sqrt{|z^2-1|}e^{it}$.
Substituting in,
$$
\frac{1}{2^{n+1}\pi i}\int_0^{2\pi}\left(\frac{Z^2-1}{Z-z}\right)^2\frac{i\sqrt{|z^2-1|}e^{it}dt}{\sqrt{|z^2-1|}e^{it}}
$$
which simplifies to
$$
\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\frac{z^2-1}{\sqrt{|z^2-1|}e^{it}}+2z+\sqrt{|z^2-1|}e^{it}\right)^n dt.
$$
Is there a way to put this into the final desired form? Thanks.
 A: Let's start with :
$$
I(z)=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\frac{z^2-1}{\sqrt{|z^2-1|}e^{it}}+2z+\sqrt{|z^2-1|}e^{it}\right)^n dt
$$
If $z^2-1\ge 0$ then :
$$
I(z)=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\sqrt{|z^2-1|}e^{-it}+2z+\sqrt{|z^2-1|}e^{it}\right)^n dt
$$
$$
=\frac{1}{2\pi}\int_0^{2\pi}\left(\sqrt{z^2-1}\cos(t)+z\right)^n dt
$$
If $z^2-1< 0$ then :
$$
I(z)=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\frac{-(1-z^2)e^{-it}}{\sqrt{1-z^2}}+2z+\sqrt{1-z^2}e^{it}\right)^n dt
$$
$$
=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(-\sqrt{1-z^2}e^{-it}+2z+\sqrt{1-z^2}e^{it}\right)^n dt
$$
$$
=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\sqrt{1-z^2}(-e^{-it}+e^{it})+2z\right)^n dt
$$
$$
=\frac{1}{2^{n+1}\pi}\int_0^{2\pi}\left(\sqrt{z^2-1}(e^{it}-e^{-it})i+2z\right)^n dt
$$
(using $\sqrt{-1}=i$, $\sqrt{-1}=-i$ would give the same result as we will see) (see too this)
$$
=\frac{1}{2\pi}\int_0^{2\pi}\left(\sqrt{z^2-1}(-\sin(t))+z\right)^n dt
$$
use the change of variable $t=x+3\frac{\pi}2$ to get (cutting the integral in two parts $(0, 2\pi-3\pi/2)$ and $(-3\pi/2,0)$ with the second interval replaced by $2\pi-3\pi/2,2\pi$) :
$$
=\frac{1}{2\pi}\int_0^{2\pi}\left(\sqrt{z^2-1}\cos(x)+z\right)^n dx
$$
so that for any real $z$ we have :
$$
I(z)=\frac{1}{2\pi}\int_0^{2\pi}\left(\sqrt{z^2-1}\cos(t)+z\right)^n dt
$$
Analytic continuation should allow you to extend this in the complex plane (we are searching polynomials after all!) but this is probably not the simple answer you hoped... 
