<s>[INST] Compute the integral $\int_{-\infty}^\infty \frac{\sin(x) (1+\cos(x))}{x(2+\cos(x))} dx$ Background
I recently found out about Lobachevsky's integral formula, so I tried to create a problem on my own for which I'd be able to apply this formula. The problem is presented below.
Problem

Compute the integral $\int_{-\infty}^\infty \frac{\sin(x) (1+\cos(x))}{x(2+\cos(x))} dx$

Attempt
If we define $f(x) := \frac{1+\cos(x)}{2+\cos(x)}$, which most definitely is $\pi$ - periodic.
The integral is, using our notation above, on the form
$$I = \int_{-\infty}^\infty \frac{\sin(x)}{x}f(x) dx.$$
The integrand is even, so we might as well compute
$$ I = 2 \int_{0}^\infty \frac{\sin(x)}{x}f(x) dx.$$
We will now have to make use of a theorem.

Lobachevsky's integral formula states that if $f(x)$ is a continous $\pi$ - periodic function then we have that $$ \int_0^\infty \frac{\sin(x)}{x}f(x) dx= \int_0^{\pi/2} f(x) dx.$$

Substituing our $f(x)$ yields us
$$ \int_0^{\pi/2} \frac{1+\cos(x)}{2+\cos(x)} dx = \pi/2 - \int_0^{\pi/2}\frac{1}{2+\cos(x)}dx $$
where
$$I_2 = \int_0^{\pi/2}\frac{1}{2+\cos(x)}dx = \int_0^{\pi/2}\frac{\sec^2(x/2)}{3+\tan^2(x/2)}dx.$$
Letting $ u = \tan(x/2)/\sqrt{3}$, for which $du = \sec^2(x/2)/(2\sqrt{3})dx$, therefore gives us:
$$ I_2 = \int_0^{1/\sqrt{3}}\frac{2\sqrt{3}}{3u^2+3} = \frac{\pi}{3\sqrt{3}}.$$
Finally we can compute $I$ to
$$I = 2\left(\frac{\pi}{2} - \frac{\pi}{3\sqrt{3}}\right) = \frac{\pi(3\sqrt{3}-2)}{3\sqrt{3}}.$$
I've tried calculating this integral in Desmos where it gives me $0$ when I calculate the integrand on the interval $(-\infty, \infty)$, and something negative for $(0,\infty)$. This contradicts my answer.
I also tried typing it into Wolfram, without success. Can anyone confirm the validity of my result?
 [/INST] Another approach:
Using the Fourier series $$1 + 2 \sum_{k=1}^{\infty} (-1)^{n} a^{n}\cos(nx) = \frac{1-a^{2}}{1+2a \cos (x) +a^{2}}, \quad |a| <1,  $$ we have
$$ \begin{align} \int_{-\infty}^{\infty} \frac{\sin (x)}{x}\frac{1-a^{2}}{1+2a \cos (x) +a^{2}} \, \mathrm dx &= \int_{-\infty}^{\infty} \frac{\sin (x)}{x}\left(1+2 \sum_{n=1}^{\infty} (-1)^{n} a^{n} \cos(nx) \right) \, \mathrm dx \\ &= \pi  + 2 \sum_{n=1}^{\infty} (-1)^{n}a^{n}\int_{-\infty}^{\infty} \frac{\sin (x)}{x} \cos(nx) \, \mathrm dx \\ &= \pi  - 2a \int_{-\infty}^{\infty} \frac{\sin (x)}{x} \, \cos (x) \, \mathrm dx + 2 \sum_{n=2}^{\infty} (-1)^{n} a^{n} \int_{-\infty}^{\infty}\frac{\sin (x)}{x} \, \cos(nx) \mathrm dx  \\ &= \pi - 2a \left(\frac{\pi}{2} \right)+2\sum_{n=2}^{\infty} (-1)^{n}a^{n}(0) \\ &= \pi \left(1-a \right) . \end{align}$$
Rewriting the integral as
$$\frac{1}{1+a^{2}}\int_{-\infty}^{\infty} \frac{\sin (x)}{x} \frac{1-a^{2}}{1+\frac{2a}{1+a^{2}}\cos(x)} \, \mathrm dx,$$ and letting $a= 2-\sqrt{3}$, we get $$\sqrt{3} \int_{-\infty}^{\infty}\frac{\sin (x)}{x} \frac{1}{2+\cos(x)} \, \mathrm dx = \pi \left(\sqrt{3}-1 \right). $$
Therefore, $$ \begin{align} \int_{-\infty}^{\infty} \frac{\sin (x)}{x} \frac{1+\cos (x)}{2+ \cos (x)} \, \mathrm dx &= \int_{-\infty}^{\infty} \frac{\sin (x)}{x} \, \mathrm dx - \int_{-\infty}^{\infty} \frac{\sin (x)}{x} \frac{1}{2+ \cos (x)} \, \mathrm dx \\ &= \pi - \frac{\pi}{\sqrt{3}} \left(\sqrt{3}  - 1  \right) \\ &= \frac{\pi}{\sqrt{3}}. \end{align} $$
The one issue with this approach is justification for switching the order of integration and summation.  Fubini's theorem is not satisfied.

Fortunately, we can use Sangchul Lee's result from the addendum of this answer to justify the switching.
</s>