Integration on log of a triangle side $ \int_0^{2\pi} \log\sqrt{r^2 + s^2 -2rs\cos\theta}\ d\theta$ I need to evaluate
$$
\int_0^{2\pi} \! d\theta \, \log\left(\sqrt{r^2 + s^2 -2rs\cos(\theta)} \right)
$$
i.e. the log of the length of the third side of a triangle ($r$ and $s$ being the lengths of the first two sides), integrated over angle.
This is a bit reminiscent of some kind of elliptic integral, but I've never seen one with a log as its argument (I don't know much about elliptic integrals though).
Mathematica gives me the answer
$$
-\pi \log\left(\frac{2}{r^2 + s^2 + |r^2 - s^2|}\right)
$$
with conditions $r\neq0$ or $s\neq0$.
I would like to to find this analytically if I can for a number of reasons, e.g.

*

*Mathematica weirdly doesn't give me this answer 100% of the time,

*if I ask for the indefinite integral I get a massive expression in the complex numbers  (which I've asked about over on Mathematica stack exchange: https://mathematica.stackexchange.com/questions/270314/integrate-ignoring-assumptions) so I want to understand how it reduces to such a simple expression,

*I next need to integrate this against some functions of $r$ and $s$, so the more insight into the $\theta$ integral I have the better.

I'm not sure where to start tackling this analytically though. Can anyone point me in the right direction?
 A: For $r\ge s$
\begin{align}
I=&\int_0^{2\pi}  \log\left(\sqrt{r^2 + s^2 -2rs\cos\theta} \right)d\theta\\
=& \int_0^{\pi}  \log\left(r^2 + s^2 -2rs\cos\theta \right)d\theta\\
=& \int_0^{\pi}  2\log r+ \log\bigg(1-\frac {2s}r\cos\theta + \frac{s^2}{r^2}\bigg)d\theta
=2\pi\log r
\end{align}
where $\int_0^{\pi} \log\left(1-\frac {2s}r\cos\theta + \frac{s^2}{r^2}\right)d\theta=0$. Similarly, $I=2\pi \log s$ for $s\ge r$.
A: $$I=\int_0^{2\pi}   \log\left(\sqrt{r^2 + s^2 -2rs\cos(\theta)} \right)\, d\theta=\frac 12 \int_0^{2\pi}   \log\left({r^2 + s^2 -2rs\cos(\theta)} \right)\, d\theta$$
$$\log\left({r^2 + s^2 -2rs\cos(\theta)} \right)=\log(r^2+s^2)+\log \left(1-\frac{2 r s }{r^2+s^2}\cos (\theta )\right)$$ Let $a=\frac{2 r s }{r^2+s^2}$ and, as  @Laxmi Narayan Bhandari commented, consider
$$I(a)=\int_0^{2\pi} \log(1-a  \cos (\theta ))\, d\theta$$
$$I'(a)=-\int_0^{2\pi}\frac{\cos (\theta )}{ (1-a \cos (\theta ))}\, d\theta=\frac{2 \pi }{a}\left(1-\frac{1}{\sqrt{1-a^2}}\right)$$
$$ I(a)=2 \pi  \log \left(1+\sqrt{1-a^2}\right)$$
Combining all the above
$$I=\frac 12\Bigg[2\pi\log(r^2+s^2)+2 \pi  \log \left(1+\sqrt{1-\frac{4 r^2 s^2}{\left(r^2+s^2\right)^2}}\right)\Bigg]$$ Simplifying
$$I=\pi \log \left( \left(r^2+s^2\right)+\sqrt{\left(r^2-s^2\right)^2}\right)=\pi\log \left( \left(r^2+s^2\right)+\left|r^2-s^2\right|\right)$$
A: In my post, I found that
$$
\int_{0}^{\pi} \ln (b \cos x+c) d x=\pi \ln \left(\frac{c+\sqrt{c^{2}-b^{2}}}{2}\right)
$$
where $\left|\frac{b}{c}\right| \leqslant 1$ and $c \neq 0$.
$$
\begin{aligned}
I&=\int_{0}^{\pi} \ln \left[-2 r \sin \theta+r^{2}+s^{2}\right] d \theta\\
&=\pi \ln \left(\frac{r^{2}+s^{2}+\sqrt{\left(r^{2}+s^{2}\right)^{2}-(-2 r s)^{2}}}{2}\right.\\
&=\pi \ln \left(\frac{r^{2}+s^{2}+\left|r^{2}-s^{2}\right|}{2}\right)\\
&=2 \pi \ln (\max (r, s))
\end{aligned}
$$
