Integral: $\int_{0}^{2\pi}\arctan\left(\frac{1+2\cos x}{\sqrt{3}}\right)dx$ (Context) While working on an integral for fun, I stumbled upon the perplexing conjecture:
$$\int_{0}^{2\pi}\arctan\left(\frac{1+2\cos x}{\sqrt{3}}\right)dx = 2\pi\operatorname{arccot}\left(\sqrt{3+2\sqrt{3}}\right).$$
(Attempt) I tried multiple methods. One method that stuck out to me was using the formula $$\arctan(\theta) = \frac{1}{2i}\ln{\left(\frac{1+i\theta}{1-i\theta}\right)}$$ so that my integral becomes
$$\frac{1}{2i}\int_{0}^{2\pi}\ln\left(1+i\left(\frac{1+2\cos x}{\sqrt{3}}\right)\right)dx-\frac{1}{2i}\int_{0}^{2\pi}\ln\left(1-i\left(\frac{1+2\cos x}{\sqrt{3}}\right)\right).$$
Both of these look similar to the integral
$$\int_{0}^{2\pi}\ln\left(1+r^2-2r\cos(x)\right)dx=\begin{cases}
0, &\text{for}\; |r|<1,\\
2\pi\ln \left(r^2\right), &\text{for}\; |r|>1,
\end{cases}\tag{2}$$
and its solution can be found here.
I tried to get my integrals to "look" like the above result but to no avail. Not wanting to give up, I searched on this site for any ideas, and it seems like a few people have stumbled upon the same kind of integral, such as here and here.
In the first link, the user @Startwearingpurple says,
"Now we have
\begin{align}
4\sqrt{21}\pm i(11-6\cos\varphi)=A_{\pm}\left(1+r_{\pm}^2-2r_{\pm}\cos\varphi\right)
\end{align}
with
$$r_{\pm}=\frac{11-4\sqrt7}{3}e^{\pm i\pi/3},\qquad A_{\pm}=(11+4\sqrt7)e^{\pm i\pi /6}."$$
I tried to replicate his method but even after doing messy algebra, I couldn't figure out how to manipulate the inside of my logarithm such that it looked like what he did. I also tried letting $\operatorname{arg}\left(1+i\left(\frac{1+2\cos x}{\sqrt{3}}\right)\right) \in \left(-\pi/2, \pi/2\right)$, if that helps.
(Another method I tried was noticing that the original integral's function is periodic, so I tried using residue theory by letting $z=e^{ix}$, but I wasn't able to calculate the residues.)
(Question) Can someone help me approach this integral (preferably finding a closed form)? Any methods are absolutely welcome. And if someone could figure out how to get my logarithms to look like $\ln{\left(1+r^2-2r\cos{(x)}\right)}$, that would be nice.
(Edit) After using @SangchulLee's integral,
$$ \int_{0}^{\pi} \arctan(a + b\cos\theta) \, d\theta = \pi \arg \left(1 + ia + \sqrt{b^2 + (1+ia)^2}\right), $$
found here, I was able to deduce that
$$\int_{0}^{2\pi}\arctan\left(\frac{1+2\cos x}{\sqrt{3}}\right)dx\ =\ 2\pi\operatorname{arccot}\left(\sqrt{3+2\sqrt{3}}\right).$$
I still have no idea how they proved it though.
 A: Using your appoach, I think that I should focus on
$$I=\int \log(a+b \cos(x))\,dx$$ Using the tangent half-angle substitution
$$I=2\int \frac {\log\left[(a-b) t^2 +(a+b)\right]}{1+t^2} dt -2\int \frac {\log\left[1+ t^2 \right]}{1+t^2} dt$$ which are not bad if, we write
$$ \frac {\log\left(c t^2 +d\right)}{1+t^2}=\frac{\log \left(t-i \sqrt{\frac{d}{c}}\right)+\log \left(t+i \sqrt{\frac{d}{c}}\right)}{(t-i) (t+i)}+\frac{\log(c)}{1+t^2}$$ and use partial fraction to face things such as
$$J_\pm=\int \frac {\log(t+\alpha)}{t\pm i}\,dt$$ which are simple.
Where the difficulty start is at the time we need to evaluate since $a$ and $b$ are already complex numbers.
Since there is an antiderivative, there is a closed form for the definite integral. Now, what is it ?
A: Let $I(a)=\int_0^\pi \tan^{-1}\frac{\cos a+ \cos x}{\sin a}dx$. Then, $I(0) = \frac{\pi^2}2$ and
$$I’(a)=-\int_0^\pi\frac{1+\cos a \cos x}{1+2\cos a \cos x +\cos^2 x}dx=-\frac\pi{2\sqrt2}\left( \sqrt{\tan\frac a2} + \sqrt{\cot\frac a2}\right)
$$
and
\begin{align}
&\int_0^{2\pi }\tan^{-1}\frac{1+ 2\cos x}{\sqrt3}dx\\
=& \ 2I(\frac\pi3) = 2\left(I(0) +\int_0^{\pi/3}I’(a)da\right)\\
=& \ {\pi^2}- \frac\pi{\sqrt2}\int_0^{\pi/3} \left( \sqrt{\tan\frac a2} + \sqrt{\cot\frac a2}\right)da\\
=& \ \pi^2 -2\pi \sin^{-1}\left(\sin\frac a2-\cos\frac a2\right)\bigg|_0^{\pi/3} =2\pi \csc^{-1}(\sqrt3+1)\\
\end{align}
A: Here's a solution by Taylor series abuse. We have the useful Taylor series
\begin{equation}
\arctan\left(\frac{1+2y}{\sqrt{3}}\right)=\frac{\pi}{6}+\frac{\sqrt{3}}{2}\sum_{k=1}^\infty\frac{a_ky^k}{k}
\end{equation}
converging for $y\in [-1,1]$, where $(a_k)_k$ is a sequence of period $3$ with $(a_1,a_2,a_3)=(1,-1,0)$. We thus have that
\begin{equation}
I=\int_0^{2\pi}
\arctan\left(\frac{1+2\cos(x)}{\sqrt{3}}\right)dx=\frac{\pi^2}{3}+\frac{\sqrt{3}}{2}\sum_{k=1}^\infty\frac{a_k}{k}\int_0^{2\pi}\cos^k(x)dx
\end{equation}
Noting that
\begin{equation}
\int_0^{2\pi}\cos^k(x)dx=\frac{\pi}{2^{k-1}}{k\choose k/2}
\end{equation}
when $k$ is even, and the integral vanishes when  $k$ is odd, we may simplify
\begin{equation}
I=\frac{\pi^2}{3}+\pi\sqrt{3}\sum_{k=1}^\infty\frac{a_{2k}}{2^{2k}(2k)}{2k\choose k}
\end{equation}
Note that $a_{2k}$ may also be expressed as
\begin{equation}
a_{2k}=-\frac{i\sqrt{3}}{3}\left[e^{i2k\pi/3}-e^{i4k\pi/3}\right]
\end{equation}
Using this fact, and noting that the following useful Taylor series
\begin{equation}
\sum_{k=1}^\infty\frac{y^k}{2^{2k}(2k)}{2k\choose k}=-\log\left(\frac{1+\sqrt{1-y}}{2}\right)
\end{equation}
converges on the $3$rd roots of unity, we thus may write
\begin{equation}
\begin{split}
I&=\frac{\pi^2}{3}-i\pi\sum_{k=1}^\infty\frac{1}{2^{2k}(2k)}{2k\choose k}\left[e^{i2k\pi/3}-e^{i4k\pi/3}\right]\\
&=\frac{\pi^2}{3}+i\pi\left[\log\left(\frac{1+\sqrt{1-e^{i2\pi/3}}}{2}\right)-\log\left(\frac{1+\sqrt{1-e^{i4\pi/3}}}{2}\right)\right]\\
&=\frac{\pi^2}{3}+2\pi\text{arctan}\left(\frac{\mathfrak{I}(1-e^{i2\pi/3})}{\mathfrak{R}(1-e^{i2\pi/3})}\right)\\
&=\frac{\pi^2}{3}+2\pi\arctan\left(-\frac{\sqrt{2\sqrt{3}-3}}{2+\sqrt{3+2\sqrt{3}}}\right)\\
&=2\pi\text{arccot}\left(\sqrt{3+2\sqrt{3}}\right)
\end{split}
\end{equation}
where the last equality can be obtained through the arctan addition formula, and by noting that $\frac{\pi^2}{3}=2\pi\arctan\left(\frac{1}{\sqrt{3}}\right)$.
A: $$I=\int_0^{2\pi}\arctan\left(\frac{1+2\cos x}{\sqrt 3}\right)dx\overset{\tan \frac{x}{2}\to x}=4\int_0^\infty \frac{\arctan(\sqrt 3)-\arctan\left(\frac{x^2}{\sqrt 3}\right)}{1+x^2}dx$$

$$I(t)=\int_0^\infty \frac{\arctan\left(tx^2\right)}{1+x^2}dx\Rightarrow I'(t)=\int_0^\infty \frac{x^2}{1+t^2x^4}\frac{1}{1+x^2}dx$$
$$=\frac{\pi}{2\sqrt 2}\frac{1}{1+t^2}\left(\sqrt t+\frac{1}{\sqrt t}\right)-\frac{\pi}{2}\frac{1}{1+t^2}$$

$$I\left(\frac{1}{\sqrt 3}\right)=\frac{\pi}{2\sqrt 2}\int_0^\frac{1}{\sqrt 3}\frac{1}{1+t^2}\left(\sqrt t+\frac{1}{\sqrt t}\right)dt-\frac{\pi}{2}\int_0^\frac{1}{\sqrt 3}\frac{1}{1+t^2}dt$$
$$=\frac{\pi}{2}\arctan\left(\frac{\sqrt {2t}}{1-t}\right)\bigg|_0^\frac{1}{\sqrt 3}-\frac{\pi^2}{12}=\boxed{\frac{\pi}{2}\arctan\left(\sqrt{3+2\sqrt 3}\right)-\frac{\pi^2}{12}}$$
$$\Rightarrow I=4\left(\frac{\pi^2}{6}-\mathcal J\left(\frac{1}{\sqrt 3}\right)\right)=\boxed{2\pi\operatorname{arccot}\left(\sqrt{3+2\sqrt 3}\right)}$$
