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, 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.