<s>[INST] On the log-cosine integral $\int\limits_0^{\pi/2}\ln(\cos(x))\,dx$ I know that
$$\mathcal I = \int\limits_0^{\pi/2}\ln(\cos(x))\,dx = -\frac\pi2 \ln(2)$$
and I am aware of a few different clever ways to demonstrate this result (e.g. MSE 4065767 and MSE 1992462). I would like to know if there's any way to wrap up the method I outline below.
Substituting $t=\tan\left(\frac x2\right)$ yields
$$\mathcal I= 2\int_0^1 \frac{\ln\left(\frac{1-t^2}{1+t^2}\right)}{1+t^2} \, dt = 2 \left(\underbrace{\int_0^1\frac{\ln(1-t^2)}{1+t^2}\,dt}_{\mathcal J^-} - \underbrace{\int_0^1\frac{\ln(1+t^2)}{1+t^2} \, dt}_{\mathcal J^+} \right)$$
Exploiting the series expansion for $\frac1{1+t^2}$, we have
$$\mathcal J^- = \int_0^1 \ln(1-t^2) \sum_{n=0}^\infty (-t^2)^n = \sum_{n=0}^\infty (-1)^n \underbrace{\int_0^1 t^{2n} \ln(1-t^2) \, dt}_{{J_n}^-}$$
and similarly,
$$\mathcal J^+ = \sum_{n=0}^\infty \underbrace{\int_0^1 t^{2n} \ln(1+t^2) \, dt}_{{J_n}^+}$$
I derive the following recurrences for ${J_n}^{\pm}$:
$$\begin{cases}{J_0}^- = 2\ln(2) - 2 \\ {J_n}^- = \frac{2n-1}{(2n+1)^2} - \frac1{2n+1} + \frac{2n-1}{2n+1} {J_{n-1}}^- & \text{for }n\ge1\end{cases}$$
$$\begin{cases}{J_0}^+ = \ln(2) - 2 + \frac\pi2 \\ {J_n}^+ = \frac{2n-1}{(2n+1)^2} - \frac{2\ln(2)-1}{2n+1} - \frac{2n-1}{2n+1}{J_{n-1}}^+ & \text{for }n\ge1\end{cases}$$
where ${J_0}^\pm$ are found by exploiting the series for $\ln(1\pm t)$ and several others derived from the expansion of $\frac1{1-t}$. I managed to solve these for ${J_n}^{\pm}$, so that
$$\mathcal J^- = \frac{(\ln(2)-1)\pi}2 + \sum_{n=0}^\infty \frac{(-1)^n}{2n+1} \left(\sum_{i=0}^{n-1} \frac{2i+1}{2i+3} - n\right)$$
$$\mathcal J^+ = \frac{\pi^2-3\pi}8 + \sum_{n=0}^\infty \frac{(-1)^n}{2n+1} \sum_{i=0}^{n-1} (-1)^i \frac{2i+1}{2i+3}$$
Barring any mistakes, the remaining sum seems to be
$$2 \sum_{n=0}^\infty \frac{(-1)^n}{2n+1} \left(\sum_{i=0}^{n-1} (1-(-1)^i) \frac{2i+1}{2i+3} - n\right) = \frac{3\pi}2\ln(2) - \frac{\pi^2}4 - \frac\pi4$$
but I have no idea where to go with this.
Is there anything I can do to further refine $\mathcal J^- - \mathcal J^+$? I do see a bit of cancellation of terms when $i$ is even, which lets me simplify the inner sum to
$$2\sum_{i=0}^{\left\lfloor\frac{n-1}2\right\rfloor} \frac{4i+1}{4i+3} - n$$
but that doesn't seem helpful.
We do have, with $H_n$ the $n$-th harmonic number,
$$\sum_{i=0}^{n-1} \frac{2i+1}{2i+3} = \sum_{i=0}^{n-1}\left(1 - \frac2{2i+3}\right) = n - 2\left(H_{2n+1} - \frac12 H_n - 1\right)$$
though I'm not so sure I can write its alternating counterpart in $\mathcal J^+$ in a similar way. Then
$$\mathcal J^- = \frac12\ln(2) - \pi - 2 \sum_{n=0}^\infty \frac{(-1)^n H_{2n+1}}{2n+1} + \sum_{n=0}^\infty \frac{(-1)^n H_n}{2n+1} = \frac{2\ln(2)-\pi}4 - G$$
 [/INST] With $x\to (1-x)/(1+x)$,
$$\int_0^1 \frac{\ln\left(\frac{1-x^2}{1+x^2}\right)}{1+x^2} dx=\int_0^1 \frac{\ln\left(\frac{2x}{1+x^2}\right)}{1+x^2}dx$$
$$=\int_0^1\frac{\ln(2)}{1+x^2}dx+\int_0^1\frac{\ln(x)}{1+x^2}dx-\int_0^1\frac{\ln(1+x^2)}{1+x^2}dx$$
$$=\frac{\pi}{4}\ln(2)-G+\sum_{n=0}^\infty\frac{(-1)^nH_n}{2n+1}.\tag{1}$$
To get this sum, multiply both sides of
$$\int_0^1\frac{x^{2n}}{1+x}dx=\ln(2)+\frac1{2n+1}+H_n-H_{2n+1},$$
by $\frac{(-1)^n}{2n+1}$ then consider the summation over $n\ge 0$,
$$\underbrace{\sum_{n=0}^\infty\frac{\ln(2)(-1)^n}{2n+1}}_{\frac{\pi}{4}\ln(2)}+\underbrace{\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)^2}}_{G}+\sum_{n=0}^\infty\frac{(-1)^nH_n}{2n+1}-\sum_{n=0}^\infty\frac{(-1)^nH_{2n+1}}{2n+1}$$
$$=\int_0^1\frac{1}{1+x}\sum_{n=0}^\infty \frac{(-x^2)^n}{2n+1}dx=\int_0^1\frac{\arctan x}{x(1+x)}dx$$
Since
$$\sum_{n=0}^\infty\frac{(-1)^nH_{2n+1}}{2n+1}=-\int_0^\infty (-1)^n \int_0^1 x^{2n}\ln(1-x)dx$$
$$=- \int_0^1 \ln(1-x)\sum_{n=0}^\infty (-x^2)^n dx=-\int_0^1\frac{\ln(1-x)}{1+x^2}dx=\int_0^1\frac{\arctan x}{x(1+x)}dx,$$
where the last equality was proved by @Sangchul Lee here, we have
$$\sum_{n=0}^\infty\frac{(-1)^n H_n}{2n+1}=-\frac{\pi}{4}\ln(2)-G+2\int_0^1\frac{\arctan x}{x(1+x)}dx$$
$$=-\frac{\pi}{4}\ln(2)-G+2\underbrace{\int_0^1\frac{\arctan x}{x}dx}_{G}-2\int_0^1\frac{\arctan x}{1+x}dx$$
$$=-\frac{\pi}{4}\ln(2)+G-2\int_0^1\frac{\arctan x}{1+x}dx$$
where
$$\int_0^1\frac{\arctan x}{1+x}dx\overset{x\to (1-x)/(1+x)}{=}\int_0^1\frac{\pi/4-\arctan x}{1+x}dx$$
$$\Longrightarrow\int_0^1\frac{\arctan x}{1+x}dx=\frac{\pi}{8}\ln(2).$$
Therefore
$$\sum_{n=0}^\infty \frac{(-1)^n H_n}{2n+1}=G-\frac{\pi}{2}\ln(2).$$
Plug this result in $(1)$, we have
$$\int_0^1 \frac{\ln\left(\frac{1-x^2}{1+x^2}\right)}{1+x^2} dx=-\frac{\pi}{4}\ln(2)\Longrightarrow  \int\limits_0^{\pi/2}\ln(\cos(x))dx = -\frac\pi2 \ln(2).$$
</s>