Evaluating an Integral by change of order of differentiation and Integration $$I=\int_0^\pi \frac{\ln(1+t\cos x)} {\cos x} dx $$
After differentiating the integrand, this simplifies to
$$I'=\int_0^\pi \frac{1} {1+t\cos x} dx $$
I am then asked to use substitution $u=\tan(\frac{x}2)$ to solve for $I'$. How do I do this?
Edit: I was given the answer to this being $\frac{\pi}{\sqrt{1-t^2}}$. However, I still am unsure of how to progress.
Furthermore, it asks me to solve for $I(0)$. How do I do that too?
 A: We have,
$$
I=\int_0^{\pi}\frac{\log(1+t\cos(x))dx}{\cos(x)}
$$
Differentiating under the integral sign,
$$
\frac{d}{dt}I=\int_0^{\pi}\frac{dx}{1+t\cos(x)}
$$
Make the Weierstrass substitution,
$$
u=\tan(\frac{x}{2})\\
\cos(x)=\frac{1-u^2}{1+u^2}\\
dx=\frac{2du}{1+u^2}
$$
which gives,
$$
\int_0^{\pi}\frac{dx}{1+t\cos(x)}=2\int_0^{\infty}\frac{du}{(u^2 +1)(1 + t \frac{(1-u^2)}{(1+u^2)})}\\
=\frac{2}{(1-t)}\int_0^{\infty}\frac{dr}{u^2 + \frac{(1+t)}{(1-t)}}\\
=\frac{2}{\sqrt{(1-t)(1+t)}}\tan^{-1}(\sqrt\frac{(1-t)}{(1+t)}x) |_0^{\infty}\\
=\frac{\pi}{\sqrt{(1-t)(1+t)}}
$$
I is the anti-derivative of this expression,
$$
I=\pi\int \frac{dt}{\sqrt{1-t^2}}\\
$$
Make the substitution,
$$
t=\tanh(u)\\
dt=\frac{du}{(\cosh(u))^2}
$$
to get,
$$
I=\pi\int \frac{dt}{\sqrt{1-t^2}}=\pi\int \frac{du}{(\cosh(u))^2(sqrt{1-(\tanh(u))^2})}\\
=\pi\int sech(u)du\\
=\pi\tan^{-1}(\sinh(u)) + C\\
I=\pi\tan^{-1}(\sinh(\tanh^{-1}(t))) + C
$$
Setting $t=0$ we find $0=0+C$ and thus $C=0$.
A: Let
$$\phi(t)=\int_0^{2\pi}\frac{\log(1+t\cos x)}{\cos x}\mathrm{d}x$$
Notice that
$$\phi'(t)=\frac{1}{t}\int_0^{2\pi}\frac{1}{\frac{1}{t}+\cos x}\mathrm{d}x$$
With that in mind, let's evaluate
$$f(s)=s\int_0^{2\pi}\frac{1}{s+\cos x}\mathrm{d}x$$
I'll assume $s$ is real, since things get messy when we allow $s$ to be complex. It is easily seen that $f(s)$ fails to exist when $|s|\leq 1$, since the denominator of the integrand will have a zero. It can also be shown rather easily that $f$ is even (exercise). With that in mind, let's assume $s\in\mathbb{R}_{>1}$.
We can use the exponential form of cosine,
$$f(s)=s\int_0^{2\pi}\frac{1}{s+\frac{1}{2}\left(e^{ix}+e^{-ix}\right)}\mathrm{d}x$$
Now letting $z=e^{ix}$, we can see that
$$\mathrm{d}z=ie^{ix}\mathrm{d}x\implies \mathrm{d}x=\frac{\mathrm{d}z}{iz}$$
And we now take our integral over the unit circle,
$$f(s)=\frac{s}{i}\oint\limits_{\partial\mathbb{B}(0,1)}\frac{1}{s+\frac{1}{2}(z+z^{-1})}\frac{\mathrm{d}z}{z}$$
With a little algebra we transform this as
$$f(s)=\frac{2s}{i}\oint\limits_{\partial\mathbb{B}(0,1)}g(z,s){\mathrm{d}z}$$
Where
$$g(z,s)=\frac{1}{z^2+2sz+1}$$
This looks like a perfect time to use the Residue Theorem,
$$\oint\limits_{\partial\mathbb{B}(0,1)}g(z,s)\mathrm{d}z=2\pi i\sum_n \operatorname{Res}_z(g,z_n)$$
Meaning
$$f(s)=4\pi s\sum_n \operatorname{Res}_z(g,z_n)$$
Where $z_1,\dots, z_n$ are the poles of $g$. Since the numerator and denominator of $g$ are polynomials which are entire, the poles of $g$ occur when the denominator is zero, i.e
$$z^2+2sz+1=0$$
Which using the quadratic formula one can find the roots in the first argument as
$$z_{1,2}=-s\pm\sqrt{s^2-1}$$
Since we have assumed $s>1$, only the plus root is inside the unit circle. Hence we simply have
$$f(s)=4\pi s\operatorname{Res}\left(g,-s+\sqrt{s^2-1}\right)$$
This residue is fairly easy to compute. Since $g$ only has simple poles, it is
$$\operatorname{Res}(g,z_1)=\lim_{z\to z_1}(z-z_1)g(z)$$
Factoring $g(z)$, we have
$$=\lim_{z\to z_1}(z-z_1)\frac{1}{(z-z_1)(z-z_2)}=\frac{1}{z_1-z_2}=\frac{1}{2\sqrt{s^2-1}}$$
So we have our result
$$f(s)=s\int_0^{2\pi}\frac{1}{s+\cos x}\mathrm{d}x=\frac{2\pi s}{\sqrt{s^2-1}}$$
For $s>1$. When $s<-1$ we can just use the fact that $f$ is even. Hence
$$f(s)=\frac{2\pi |s|}{\sqrt{s^2-1}}$$
This should get you most of the way there.
