Let $S=\sum\_{n=1}^\infty a\_n$, be a semi-convergent series with $T=\sum\_{n=1}^\infty a\_n^2 < \infty$ and $\sum\_{n=1}^\infty |a\_n|=\infty$. Under which conditions are the following formulas valid? They are of course valid for finite sums, but not necessarily for infinite sums.


$$S^2 = T + 2 \sum\_{n=1}^\infty a\_n w\_n \mbox{ with } w\_n=\sum\_{m=n+1}^\infty a\_m$$


$$S^2 = T + 2 \sum\_{{\substack{\gcd(n,m)=1\\ 0<n<m}}}^\infty v\_{n/m} \mbox{ with } v\_{n/m}=\sum\_{k=1}^\infty 
a\_{km}a\_{kn}$$


Things would be straightforward if we were dealing with a [Cauchy product](https://en.wikipedia.org/wiki/Cauchy_product), but this is not the case here. Note that in the second formula, the first few terms are $v\_{1/2},v\_{1/3},v\_{2/3}, v\_{1/4},v\_{3/4},v\_{1/5},v\_{2/5},v\_{3/5},v\_{4/5},v\_{1/6},v\_{5/6},v\_{1/7},\dots$.


The result (first formula) is correct for instance if $a\_n=(-1)^{n+1} n^{-0.8}$. The series I am interested in are related to the Riemann Hypothesis and defined in the Appendix in my previous question, [here](https://mathoverflow.net/questions/379650/more-mysteries-about-the-zeros-of-the-riemann-zeta-function).



Squaring a semi-convergent series
For
$$S^2 = T + 2 \sum\_{n=1}^\infty a\_n w\_n \mbox{ with } w\_n=\sum\_{m=n+1}^\infty a\_m\tag{1}$$
to be valid, it is enough that $\sum\_n a\_n$ be any alternating series with $\sum\_{n=1}^\infty a\_n^2<\infty$ and $|a\_n|$ converging to $0$ (eventually) monotonically.


Indeed, since (1) holds for finite sums, this question boils down to the convergence of the series $\sum\_{n=1}^\infty a\_n w\_n$. Given the mentioned conditions on $(a\_n)$, this series will indeed converge because eventually (for some natural $N$ and all $n\ge N$) we will have $|w\_n|\le|a\_{n+1}|\le|a\_n|$ and hence $\sum\_{n=N}^\infty |a\_n w\_n|\le\sum\_{n=N}^\infty a\_n^2<\infty$.


