How to Integrate $\int_0^\pi \ln(1+\alpha \cos(x)) \,\mathrm{d}x$ I've been trying to learn how to integrate by differentiation under the integral. I've made good progress on some problems, but I seem to not be able to get an answer for $$f(\alpha)=\int_0^\pi \ln(1+\alpha \cos(x)) \,\mathrm{d}x$$
I've managed to get as far as $$f'(\alpha)=\int_0^\pi \frac{\cos(x)}{1+ \alpha \cos(x)} \,\mathrm{d}x$$
But this seems like a ridiculous integral to try and integrate by elementary methods, indeed an integral calculator returns $$\dfrac{x}{a}+\dfrac{\ln\left(\left|\left(a-1\right)\tan\left(\frac{x}{2}\right)-\sqrt{a^2-1}\right|\right)-\ln\left(\left|\left(a-1\right)\tan\left(\frac{x}{2}\right)+\sqrt{a^2-1}\right|\right)}{a\sqrt{a^2-1}}$$
Hopefully someone can advise on whether I've already made a mistake in my working, or whether I've just completely misunderstood the method.
 A: Before anything else, note that $f(0)=0$, so our constant of integration will be $0$.
As you found,
$$f'(a)=\int_0^\pi\frac{\cos x}{1+a\cos x}dx$$
$$f'(a)=\frac1a\int_0^\pi\frac{1-1+a\cos x}{1+a\cos x}dx$$
$$f'(a)=\frac1a\int_0^\pi\frac{1+a\cos x}{1+a\cos x}dx-\frac1a\int_0^\pi\frac{dx}{1+a\cos x}$$
$$f'(a)=\frac\pi a-\frac1aj(a)$$
For $j$, we preform $t=\tan\frac{x}2$ which gives
$$j(a)=2\int_0^\infty \frac{1}{1+a\frac{1-t^2}{1+t^2}}\frac{dt}{1+t^2}$$
$$j(a)=\frac2{1-a}\int_0^\infty \frac{dt}{t^2+\frac{1+a}{1-a}}$$
It is easily shown that 
$$\int_0^\infty \frac{dx}{x^2+c}=\frac\pi{2\sqrt c}$$
So we have that 
$$j(a)=\frac\pi{(1-a)\sqrt{\frac{1+a}{1-a}}}=\frac\pi{\sqrt{1-a^2}}$$
Hence
$$f'(a)=\frac\pi a-\frac\pi{a\sqrt{1-a^2}}$$ 
So 
$$f(a)=\pi\log|a|-\pi\int\frac{da}{a\sqrt{1-a^2}}$$
For the remaining integral, let $a=\sin x$ to get 
$$\int\frac{da}{a\sqrt{1-a^2}}=\int\frac{dx}{\sin x}=-\log\left(\cot x+\csc x\right)=-\log\frac{1+\sqrt{1-a^2}}{a}$$
So 
$$f(a)=\pi\log a+\pi\log\frac{1+\sqrt{1-a^2}}{a}$$
Which is just
$$f(a)=\pi\log\left(1+\sqrt{1-a^2}\right)$$
