Evaluating integral using invalid substitution I was trying to show that for suitable t: 
$$
2\pi(1+t/(\sqrt{(1-t)(3-t)})=\sum_{0}^{\infty}(t^n\int_0^{2\pi}1/(2-cos(\theta))^nd\theta  
$$
By uniqueness this is clearly the Taylor series about $0$ and the form of $c_n $ suggests the use of Cauchy's formula so we get $c_n=\frac{1}{2i\pi}\int_{\gamma(0,r)}\frac{2\pi(1+t/(\sqrt{(1-t)(3-t)})}{t^{n+1}}dt $ for $n\geq1$
$$
=-i\int_{\gamma(0,r)}\frac{1}{t^{n}\sqrt{(1-t)(3-t)}}dt 
$$
as $ \int_{\gamma(0,r)}\frac{1}{t^{n+1}}dt=0 \forall n\geq 1$
Curiously the substitution $t=2-cos(\theta)$ for $\theta\in [0,2\pi]$ gives
$$
\frac{dt}{d\theta}=sin(\theta)=\sqrt{1-cos(\theta)^2}=\sqrt{-3+4t-t^2}=i\sqrt{(1-t)(3-t)}
$$
$$
\therefore c_n=\int_0^{2\pi} \frac{1}{(2-cos(\theta))^n}d\theta 
$$
and so solves the problem, except for the small issue that it is not a valid substitution.
I was wondering if anyone has any insight into why this gives the correct answer and if there are other integrals where invalid substitutions can give the correct answer.
 A: Here's an explanation for the invalid substitution.
First, we note that
$$f(z)=\frac1{z^n\sqrt{(1-z)(3-z)}}$$
is a well-defined holomorphic function on $\mathbb C_\infty\setminus(\{0\}\cup[1,3])$ (choose a branch for $\sqrt{(1-z)(3-z)}$), where $\mathbb C_\infty$ is the Riemann sphere $\mathbb C\cup\{\infty\}$
For $0<r,\epsilon<1/4$, as you did, you can draw a circle $C_r(0)$ around $0$. Moreover, you can picture a contour $\Gamma$ around $[1,3]$ such that for each point $z\in\Gamma$, the minimal distance between $z$ and $[1,3]$ is $\epsilon$. You can easily see that $\Gamma$ is made up of two straight line segments and two half-circles.
By an appropriate choice of orientation, $\int_{C_r(0)}f(z)dz=\int_\Gamma f(z)dz$. It's because that $f$ is holomorphic. (It's important that $f$ is holomorphic at $\infty$. If you don't want to utilize this term, you can draw a large $C_R(0)$ and get $\int_{C_r(0)}-\int_\Gamma=\int_{C_R(0)}$, and let $R\to\infty$)
Now let $\epsilon\to0^+$ and $\int_\Gamma$ tends to the value you calculated by the invalid substitution.
