<s>[INST] Closed form of $\sum _{k\ge 1} \frac{(-1)^{\binom{k}{p}}}{k}$, an alternating harmonic series with the signs determined by a binomial coeffcient In a comment to Evaluating $\int_{0}^{1} \lim_{n \rightarrow \infty} \sum_{k=1}^{4n-2}(-1)^\frac{k^2+k+2}{2} x^{2k-1} dx$ for $n \in \mathbb{N}$ I proposed to study this alternating harmonic sum
$$s(p) = \sum _{k\ge 1} \frac{(-1)^{\binom{k}{p}}}{k}\tag{1}$$
where the sign of the terms is determined by a binomial coefficient.
This turned out to be interesting, and the results can be formulated in three statements:
Statement 1: the sum is convergent only if $p$ is power of $2$: $p = 2^q, q=0,1,2,...$
Statement 2: the closed expressions of $s$ for the first few values of $q$ are
$$s(1) = -\log (2)\simeq -0.693147$$
$$s(2) = \frac{\pi }{4}-\frac{\log (2)}{2}\simeq 0.438825$$
$$s(4)= \frac{\pi}{8} \left(1+2 \sqrt{2}\right) -\frac{\log (2)}{4}\simeq 1.33013 $$
$$s(8) = \frac{\pi}{16} \left(4 \sqrt{2+\sqrt{2}}+2 \sqrt{2}+1\right)  -\frac{\log (2)}{8}\simeq 2.11629$$
The next step was hard, and I did not expect to find a simple expression. But here it is
$$\begin{align}s(16) = \frac{\pi}{16} \left(4 \left(\sqrt{2-\sqrt{2+\sqrt{2}}}+\sqrt{\left(2+\sqrt{2}\right) \left(2-\sqrt{2+\sqrt{2}}\right)}\right)+\sqrt{2}+2 \sqrt{2+\sqrt{2}}+2 \sqrt{2-\sqrt{2+\sqrt{2}}}+2 \sqrt{\sqrt{2+\sqrt{2}}+2}+\frac{1}{2}\right)  -\frac{\log (2)}{16}\simeq 2.85436\end{align}$$
Statement 3: The general structure seems to be
$$s(p=2^q) =  \frac{\pi}{p}a(p)-\frac{1}{p} \log(2) \tag{2}$$
where $a(p)$ is an algebraic number composed of the number $2$.
Questions
(1) are these results known in the literature?
(2) can you derive/prove the three statements?
(3) can you give the expression $a(p)$ to extend the given range?
 [/INST] Here, I will examine Statement 2 and 3.
Step 1. To determine the parity of $\binom{k}{2^q}$, we consider its generating function in the ring $\mathbb{F}_2[\![x]\!]$ of formal power series with coefficients in $\mathbb{F}_{2}$:
\begin{align*}
\sum_{k=0}^{\infty} \binom{k}{2^q} x^k
&= \frac{x^{2^q}}{(1-x)^{2^q + 1}}
= \frac{x^{2^q}}{(1-x)(1 - x^{2^q})}
= \frac{1 - x^{2^q}}{1 - x} \cdot \frac{x^{2^q}}{(1 - x^{2^q})^2} \\
&= (1 + x + \cdots + x^{2^q-1})(x^{2^q} + x^{3\cdot2^q} + x^{5\cdot 2^q} + \cdots).
\end{align*}
(In the second step, we utilized the Freshman's dream.) By expanding this product, we find that
$$ \binom{k}{2^q} \equiv \begin{cases}
0, & \lfloor k/2^q \rfloor = 0, 2, 4, \ldots; \\
1, & \lfloor k/2^q \rfloor = 1, 3, 5, \ldots; \\
\end{cases} \pmod{2} $$
Using this, the series $s(2^q)$ can be recast as
\begin{align*}
s(2^q)
&= \int_{0}^{1} \frac{1}{x} \left[ \sum_{k=0}^{\infty} (-1)^{\binom{k}{2^q}} x^k - 1 \right] \, \mathrm{d}x \\
&= \int_{0}^{1} \frac{1}{x} \left[ \frac{1 - x^{2^q}}{(1 - x)(1 + x^{2^q})} - 1 \right] \, \mathrm{d}x \\
&= \int_{0}^{1} \frac{1 - 2x^{2^q - 1} + x^{2^q}}{(1-x)(1 + x^{2^q})} \, \mathrm{d}x.
\end{align*}
Step 2. Now write
$$ P(x) = 1 - 2x^{2^q - 1} + x^{2^q}
\qquad\text{and}\qquad
Q(x) = (1-x)(1 + x^{2^q})$$
for the numerator and denominator of the integrand, respectively. Also, let
$$ Z = \{\omega \in \mathbb{C} : 1 + \omega^{2^q} = 0 \} $$
be the zero set of $1 + x^{2^q}$. Since $P(1) = 0$, $\omega \in Z$ are the only poles of $P(x)/Q(x)$, all of which being simple. So,
\begin{align*}
\frac{P(x)}{Q(x)}
= \sum_{\omega \in Z} \frac{P(\omega)}{Q'(\omega)} \frac{1}{x - \omega}
= \sum_{\omega \in Z} \frac{-2^{1-q}}{1-\omega} \frac{1}{x - \omega}.
\end{align*}
Integrating both sides from $0$ to $1$,
\begin{align*}
s(2^q)
&= - 2^{1-q} \sum_{\omega \in Z} \frac{1}{1-\omega} [\log(1 - \omega) - \log(-\omega)],
\end{align*}
where $\log(\cdot)$ is the principal branch of the complex logarithm.
Step 3. From this point on, we will assume that $q \geq 1$ so that $2^q$ is an even number. Then the map $\omega \mapsto -\omega$ is a permutation of the set $Z$, and so, we may permute the sum to rewrite
\begin{align*}
s(2^q)
&= - 2^{1-q} \sum_{\omega \in Z} \frac{1}{1+\omega} [\log(1 + \omega) - \log \omega]
\end{align*}
Also, note that
$$ \frac{1}{1+\omega} = \frac{1 - i\tan(\frac{1}{2}\arg\omega)}{2}
\qquad\text{and}\qquad
\operatorname{Im} \left[ \log(1 + \omega) - \log \omega \right] =  - \frac{\arg\omega}{2}. $$
Since $s(2^q)$ is a real number and each $\log \omega$ is pure imaginary, the sum reduces to
\begin{align*}
s(2^q)
&= \frac{1}{2^q} \sum_{\omega \in Z} \left[ \frac{\arg\omega}{2} \tan\left(\frac{\arg\omega}{2}\right) - \operatorname{Re}[\log(1 + \omega)] \right] \\
&= \frac{1}{2^q} \sum_{\omega \in Z} \frac{\arg\omega}{2} \tan\left(\frac{\arg\omega}{2}\right) - \frac{1}{2^q}\operatorname{Re}\left[\log \prod_{\omega \in Z} (1 + \omega)\right] \\
&= \bbox[color:navy;padding:3px;border:1px dotted navy;]{\frac{\pi}{4^q} \sum_{k=1}^{2^{q-1}} (2k-1) \tan\left(\frac{(2k-1)\pi}{2^{q+1}}\right) - \frac{\log 2}{2^q}.}
\end{align*}
Step 4. Finally, we note that the first sum is algebraic. Since $\tan(k\theta)$ is a rational function of $\tan\theta$, it suffices to verify that $\tan(\pi/2^{q+1})$ is algebraic for all $q$. Indeed, if we assume that $0 \leq \theta \leq \frac{\pi}{4}$ and if $\alpha = 2\cos(2\theta)$, then
$$ \tan \theta = \sqrt{\frac{2-\alpha}{2+\alpha}}
\qquad\text{and}\qquad \tan\left(\frac{\theta}{2}\right) = \sqrt{\frac{2-\sqrt{2+\alpha}}{2+\sqrt{2+\alpha}}}. $$
Using this, we get
\begin{align*}
q = 1
&\quad\implies\quad \tan\left(\frac{\pi}{2^2}\right) = 1 = \sqrt{\frac{2-0}{2+0}}, \\[0.25em]
q = 2
&\quad\implies\quad \tan\left(\frac{\pi}{2^3}\right) = \sqrt{\frac{2-\sqrt{2}}{2+\sqrt{2}}}, \\[0.25em]
q = 3
&\quad\implies\quad \tan\left(\frac{\pi}{2^4}\right) = \sqrt{\frac{2-\sqrt{2 + \smash[b]{\sqrt{2}} }}{2+\sqrt{2 + \smash[b]{\sqrt{2}} }}}, \\[0.25em]
&\qquad \vdots
\end{align*}
</s>