Back in my undergrad days I wrote a false proof of the following.
Problem. Prove that $\displaystyle\int_0^{2\pi}\frac{dx}{1+e^{\sin{x}}}=\pi$
Proof. Integrating by parts gives $$ \int_0^{2\pi}\frac{dx}{1+e^{\sin{x}}} = \left.\frac{x}{1+e^{\sin{x}}}\right\vert_0^{2\pi}+\int_0^{2\pi} x\cdot\frac{e^{\sin x}\cos{x}}{(e^{\sin{x}}+1)^2}dx =\pi+\int_0^{2\pi} x\cdot\frac{e^{\sin x}\cos{x}}{(e^{\sin{x}}+1)^2}dx $$ Taking $u=\sin x$ in the last integral gives $$ \int_0^{2\pi} x\cdot\frac{e^{\sin x}\cos{x}}{(e^{\sin{x}}+1)^2}dx =\int_0^0\arcsin u\frac{e^u}{(e^u+1)}du=0 $$ and combining the two equations gives the result. $\Box$
Of course, the problem with this proof is that the equation $x=\arcsin u$ is only valid on $[0,\pi/2]$. However, $\sin{x}$ is invertible on the intervals $[\pi/2,3\pi/2]$ and $[3\pi/2,2\pi]$ so it seems that this problem can be circumvented by splitting the integral up into three integrals and individually applying the $u$-substitution.
Can this proof be salvaged?
Edit: I'm aware that there are other ways to prove this result. I'm mainly concerned with the validity of this proof.
Edit: I've voted up both answers because they give correct proofs. I haven't accepted an answer, however, because neither addresses the issue of breaking up a noninvertible function into seperate integrals where the function is invertible, which was my main reason for posting this question.