Closed expression for sum $\sum_{k=1}^{\infty} (-1)^{k+1}\frac{\left\lfloor \sqrt{k}\right\rfloor}{k}$

Inspired by the recent question if the series $\sum_{k=1}^{\infty} \frac{\sqrt{k}-\left\lfloor \sqrt{k}\right\rfloor}{k}$ diverges (which is the case) I became interested in the alternating series which is convergent by the Leibniz criterion.

The core of the problem is then the question if this sum

$$s = \sum_{k=1}^{\infty} (-1)^{k+1}\frac{\left\lfloor \sqrt{k}\right\rfloor}{k}\simeq 0.591561$$

has a closed expression. Here $\left\lfloor {x}\right\rfloor$ is the greatest integer less than or equal to $x$.

I have found a nice integral representation for $s$ but I could not find a closed expression. Also, due to the slow convergence of the sum it is not trivial to get a numerical result with high accuracy which might be necessary to identify a possible closed expression.

Problems

a) find a closed expression for $s$
b) find the numerical result exact to 20 decimal places


Solution 1:

Update

We may use the convergence acceleration of alternating series developed by Cohen, Villegas, and Zagier. Let $$s = \ln 2 + \sum_{n=1}^\infty (-1)^n n \sum_{i=1}^{n} \frac{1}{(n^2 + 2i-1)(n^2+2i)}$$ and $$s_n = \ln 2 + \sum_{k=1}^n \frac{c_{n,k}}{d_n}\sum_{i=1}^k \frac{k}{(k^2 + 2i-1)(k^2+2i)}$$ where \begin{align} d_n &= \frac{(3+\sqrt{8})^n + (3-\sqrt{8})^n}{2}, \\ c_{n,k} &= (-1)^k \sum_{m=k+1}^n \frac{n}{n+m} \binom{n+m}{2m} 2^{2m}. \end{align} From Proposition 1 in [1], we have $$|s-s_n| \le \frac{s}{d_n}.$$

Maple: $\mathrm{evalf}(s, 30) = 0.591560779349817340213846903345$, $\mathrm{evalf}(s_{28} - s, 30) = 1.6944769437\cdot 10^{-21}.$

[1] Henri Cohen, Fernando Rodriguez Villegas, and Don Zagier, "Convergence Acceleration of Alternating Series".

Previously written

We have \begin{align} s &= \sum_{k=1} (-1)^{k+1} \frac{\lfloor \sqrt{k}\rfloor}{k}\\ &= \sum_{n=1}^\infty \left(\sum_{k = n^2} (-1)^{k+1} \frac{\lfloor \sqrt{k}\rfloor}{k}\right) + \sum_{n=1}^\infty \left(\sum_{n^2 < k < (n+1)^2} (-1)^{k+1} \frac{\lfloor \sqrt{k}\rfloor}{k}\right)\\ &= \sum_{n=1}^\infty \frac{(-1)^{n+1}}{n} - \sum_{n=1}^\infty (-1)^n n \sum_{i=1}^{2n} (-1)^i \frac{1}{n^2 + i}\\ &= \ln 2 - \sum_{n=1}^\infty (-1)^n n \sum_{i=1}^{2n} (-1)^{i} \frac{1}{n^2 + i}\\ &= \ln 2 + \sum_{n=1}^\infty (-1)^n n \sum_{i=1}^{n} \frac{1}{(n^2 + 2i-1)(n^2+2i)}.\tag{1} \end{align} Maple can give numerical approximation of (1) with high accuracy. Or we may use "Convergence Acceleration of Alternating Series" technique to calculate (1).

Solution 2:

Results

I have not found a closed form of $s$. However, I will show below that the sum

$$s = \sum_{k=1}^{\infty} (-1)^{k+1}\frac{\left\lfloor \sqrt{k}\right\rfloor}{k}\tag{1}$$

has the following integral representation

$$s_i = \int_0^1 f(x) \, dx\tag{2a}$$

where the integrand is defined as

$$f(x) = \frac{1-\vartheta _4(0,x)}{2 x (x+1)}\tag{2b} $$

Here

$$\vartheta _4(u,q) = 1 + 2 \sum_{n=1}^{\infty} (-1)^n q^{n^{2}} \cos(2 n u)\tag{3}$$

is a Jacobi theta function $[1]$.

The integrand of $s_i$ looks pretty harmless

enter image description here

Derivation

We start by writing down a list of summands of $s$ long enough to see a pattern

$$s\simeq \left\{1,-\frac{1}{2},\frac{1}{3},-\frac{2}{4},\frac{2}{5},-\frac{2}{6},\frac{2}{7},-\frac{2}{8},\frac{3}{9},-\frac{3}{10},\frac{3}{11},-\frac{3}{12},\frac{3}{13},-\frac{3}{14},\frac{3}{15},-\frac{4}{16},\frac{4}{17},-\frac{4}{18}\right\}$$

We see that the list can be decomposed into sublists

$$s_1= \left\{1,-\frac{1}{2},\frac{1}{3}\right\}$$

$$s_2= \left\{-\frac{2}{4},\frac{2}{5},-\frac{2}{6},\frac{2}{7},-\frac{2}{8}\right\}= 2 \left\{-\frac{1}{4},\frac{1}{5},-\frac{1}{6},\frac{1}{7},-\frac{1}{8}\right\}$$

$$s_3= \left\{\frac{3}{9},-\frac{3}{10},\frac{3}{11},-\frac{3}{12},\frac{3}{13},-\frac{3}{14},\frac{3}{15}\right\}= 3 \left\{\frac{1}{9},-\frac{1}{10},\frac{1}{11},-\frac{1}{12},\frac{1}{13},-\frac{1}{14},\frac{1}{15}\right\}$$

Notice that the denominators of the sublist $s_1$ runs from $1$ to $3$, of $s_2$ from $4$ to $8$,of $s_3$ from $9$ to $15$ resp., in general of sublist $s_m$ from $m^2$ to $(m+1)^2-1=m(m+2)$.

To express the pattern formally we use the alternating harmonic sum defined as

$$A(n) = \sum _{k=1}^n \frac{(-1)^{k+1}}{k}\tag{4}$$

Then we can write

$$s_1 = A(3),\\ s_2 = 2 (A(8) -A(3)),\\ s_3 = 3(A(15) - A(8)) $$

and for the partial sums

$$p_1 = s_1 = A(3), \\p_2 = s_1+s_2 = 2 A(8) -A(3), \\p_3 = p_2+s_3 = 3 A(15) - A(8)-A(3)$$

the general partial sum of index $m$ is then

$$p_{m} = m A((m+1)^2-1) - \sum_{k=2}^{m} A(k^2-1)\tag{5}$$

Observing now that

$$A(n) = \sum_{k=1}^n (-1)^{k+1}\int_0^1 x^{k-1}\,dx= \int_0^1 \sum_{k=1}^n (-1)^{k+1} x^{k-1}\,dx= \int_0^1 \frac{1-(-1)^n x^n}{x+1} \, dx\tag{6}$$

we get

$$p_{m} =\int_0^1 \left( \frac{m \left((-1)^{m (m+2)} x^{m (m+2)-1}+1\right)}{x+1}-\sum _{k=2}^m \frac{(-1)^{k^2} x^{k^2-1}+1}{x+1}\right) \,dx\tag{7}$$

Without changing the value we can extend the second sum down to $k=1$. Now we observe that the contribution $\frac{m}{1+x}$ cancels out and that the parity of $k^2$ is the same as that of $k$ and similarly $m(m+2) \sim m$ so that we have

$$p_{m} = \int_0^1 \left(\frac{m \left((-1)^{m} x^{m (m+2)}\right)}{x(x+1)}-\sum _{k=1}^m \frac{(-1)^{k} x^{k^2}}{x(x+1)}\right) \,dx\tag{8}$$

Now we need the limit $m\to\infty$ to get $s=\lim_{m\to \infty } \, p_{m}$.

The first integral is given by

$$I_1(m) = m (-1)^m \int_0^1 \frac{x^{m (m+2)}}{x (x+1)} \, dx\\=\frac{1}{2} (-1)^m m \left(\psi ^{(0)}\left(\frac{1}{2} (m+1)^2\right)-\psi ^{(0)}\left(\frac{1}{2} m (m+2)\right)\right)\tag{9}$$

For $m>>1$ we find that $I_1 \sim \frac{(-1)^m}{2 m}$ so that it vanishes in the limit.

For the limit of the second integral

$$I_2(m) = -\int_0^1 \sum _{k=1}^m \frac{(-1)^{k} x^{k^2}}{x(x+1)} \,dx\tag{10}$$

we have to calculate the sum of the integrand up to $m\to\infty$. Observing $(3)$ we obtain $(2)$. QED.

Discussion

0) Honestly speaking, I didn't expect to find an integral representation because I thought that sharply discontinuous aggregates like $\left\lfloor x\right\rfloor$ would not lead to a smooth formula. But, luckily, my feelings turned out to be misleading, and I was pushed forward by the rather straightforward derivation itself.

1) Series expansion of the integrand

The list of terms of the series expansion of the integrand starts like this

$$f(x) = \left\{1,-x,x^2,-2 x^3,2 x^4,-2 x^5,2 x^6,-2 x^7,3 x^8,-3 x^9,3 x^{10},-3 x^{11},3 x^{12},-3 x^{13},3 x^{14},-4 x^{15}\right\}$$

When integrated

$$s=\int_0^1 f(x) \,dx \simeq \left\{1,-\frac{1}{2},\frac{1}{3},-\frac{1}{2},\frac{2}{5},-\frac{1}{3},\frac{2}{7},-\frac{1}{4},\frac{1}{3},-\frac{3}{10},\frac{3}{11},-\frac{1}{4},\frac{3}{13},-\frac{3}{14},\frac{1}{5},-\frac{1}{4}\right\}$$

we get back where we started from.

This gives me some comfort because I felt a little uneasy about the general validity of the limit while selecting the special form of the partial sums

2) We have in fact found an integral representation also for the sum

$$h = \sum_{k=1}^{\infty} (-1)^{k+1}\frac{\sqrt{k}-\left\lfloor \sqrt{k}\right\rfloor}{k}$$

because the trivial part is

$$\sum _{k=1}^{\infty } \frac{(-1)^{k+1}}{\sqrt{k}}=-\left(\sqrt{2}-1\right) \zeta \left(\frac{1}{2}\right)\simeq 0.604899$$

3) Accuracy

The accuracy issue is briefly that - roughly speaking - Mathematica gives a different numerical result for the integral with NIntegrate than for the sum with NSum. I believe that the value obtained with NIntegrate is better because the integrand is alsmost trivial (see the graph). We had a similar topic recently here.

In the meantime, Yuriy S in a comment has given this numerical value for the integral $(2)$ with Mathematica's NIntegrate, and WorkingPrecision -> 30

$$i_{Yuriy} = 0.591560779349817340213846903345$$

I can confirm this result.

I have calculated the sum with NSum and different values of WorkingPrecision. The results are wobbling appreciably about the limiting value as can be seen in the picture

enter image description here

And I can ony give this very modest result (the average)

$$s_{WH,NSum} = 0.59123$$

Alternatively, the plain Sum of the first million terms is

$$s_{WH,Sum} = 0.5910$$

The accuracy is but $\frac{1}{\sqrt{k_{max}}} \simeq 10^{-3}$

River Li in his solution $[2]$ has transformed the limiting form of the sum $(5)$ into the better converging double sum

$$s_{RL} = \log(2) + \sum_{n=1}^\infty (-1)^n n \sum_{i=1}^{n} \frac{1}{(n^2 + 2i-1)(n^2+2i)}$$

The n-summand has a closed form in terms of polygamma functions and goes asymptotically like $\frac{1}{n^2}$. Hence the convergence is similar to that of Dirichlet $\eta(2)$.

Mathematica finds 5 valid digits for $s_{RL}$ with 1000 n-summands in a few seconds, but refuses to sum 2000 terms is acceptable time.

However, River Li found twenty digits using Maple, a result he later confirmed using the "Convergence Acceleration methods for Alternating Sums" as described here $[3]$ with only 28 terms. This method claims that you can get high precision results from just a few tens of terms. Usage of the method is nicely described in the update of River Li's solution.

Hence I conclude that using summation to find the value of the sum with high accuracy as requested in problem b) needs sophisticated summation methods which provide convergence acceleration, accompanied by a good SC-tool.

Here we are lucky to have the integral representation of the sum for which Mathematica delivers as many digits as requested.

4) Generalization

If we consider the similar problem with the p-th root instead of the square root we have

$$s(p) = \sum _{k=1}^{\infty } \frac{(-1)^{k+1} \left\lfloor k^{1/p}\right\rfloor }{k} = \int_{0}^{1} f(p,x)\,dx$$

where now the integrand is given by

$$f(p,x)=\frac{\sum _{m=1}^{\infty } (-1)^{m-1} x^{m^p}}{x (x+1)}$$

I know no name for this special function which replaces the Jacobi theta function.

The problem with a rational exponent $\frac{p}{q}$ with $1 \lt p\lt q$ seems to be much more difficult to tackle.

5) Using Fourier expansion

We can get rid of the floor function using the Fourier series

$$\left\lfloor x\right\rfloor = x -\frac{1}{2} + \frac{1}{\pi}\sum_{k=1}^{\infty} \frac{\sin(2 \pi k x)}{k}\tag{5.1}$$

@Jam has pursued this approach in https://math.stackexchange.com/a/3452471/198592, and ended with this sum to be evaluated

$$d=-\frac{1}{\pi}{\sum_{n\geq 1}\sum_{k\geq 1}\frac{\left(-1\right)^{n}\sin\left(2\pi k\sqrt{n}\right)}{nk}}\tag{5.2}$$

We can do the $k$-sum

$$\sum_{k\geq 1} \frac{\sin\left(2\pi k\sqrt{n}\right)}{k}= \frac{i}{2}\left(\log \left(1-e^{2 i \pi \sqrt{n}}\right)-\log \left(1-e^{-2 i \pi \sqrt{n}}\right)\right) \\ = \frac{1}{2} i \log \left(\frac{1-e^{2 i \pi \sqrt{n}}}{1-e^{-2 i \pi \sqrt{n}}}\right)\\ =\frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n}}\right)\tag{5.3}$$

For a square integer $n$ this expression diverges.

Hence we have to take the limit when $n$ goes to a square integer.

Since we have two ways to approach the integer we take the arithmetic mean.

Hence

$$\frac{1}{2} \left(\lim_{n\to 2^+} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n}}\right)+\lim_{n\to 2^-} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n}}\right)\right)\tag{5.4}$$

In general we have to replace

$$\frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n}}\right) \to \\ \frac{1}{2} \left(\lim_{z\to n^+} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{z}}\right)+\lim_{z\to n^-} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{z}}\right)\right)\tag{5.5}$$

or, stated differently, with some small positive $\epsilon$

$$\frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n}}\right) \to \\ \frac{1}{2} \left(\lim_{\epsilon \to 0^+} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n+\epsilon }}\right)+\lim_{\epsilon \to 0^-} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n+\epsilon }}\right)\right)\tag{5.6}$$

This procedure lets the expression vanish for square $n$.

Hence we can write

$$d=-\frac{i}{2\pi} \sum_{n\geq 1} \frac{(-1)^{n}}{n} \frac{1}{2} \left(\lim_{\epsilon \to 0^+} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n+\epsilon }}\right)+\lim_{\epsilon \to 0^-} \, \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n+\epsilon }}\right)\right)\tag{5.7}$$

Maybe we can exchange summation and the limit.

Defining

$$d(\epsilon)=-\frac{i}{2\pi} \sum_{n\geq 1} \frac{(-1)^{n}}{n} \left( \frac{1}{2} i \log \left(-e^{2 i \pi \sqrt{n+\epsilon }}\right)\right)\tag{5.8}$$

we get

$$d = \frac{1}{2}\left( \lim_{\epsilon \to 0^+} d(\epsilon) + \lim_{\epsilon \to 0^-} d(\epsilon)\right)\tag{5.9}$$

I am not sure if we have really gained something by trying to perform the $k$-sum.

I found another expression for d which skips explicitly over the squares. It is

$$d_{nsq}=\frac{i}{2\pi }\sum _{m=1}^{\infty }(-1)^m \sum _{j=1}^{2 m} (-1)^j\frac{ \log \left(-e^{2 i \pi \sqrt{j+m^2}}\right)}{ \left(j+m^2\right)}\tag{5.10}$$

The convergence is satisfactory as can be seen from the following graph

enter image description here

References

$[1]$ http://mathworld.wolfram.com/JacobiThetaFunctions.html
$[2]$ https://math.stackexchange.com/a/3450665/198592
$[3]$ https://people.mpim-bonn.mpg.de/zagier/files/exp-math-9/fulltext.pdf

Solution 3:

Partial solution and alternative characterisation

We may rephrase the problem with the following rearrangement, reducing the problem to the double-series in red, which I will refer to as $d$.

$$\begin{align} s &=\sum_{n\ \text{square}}\frac{\left(-1\right)^{n+1}}{n}\lfloor\sqrt{n}\rfloor +\sum_{n\ \text{not square}}\frac{\left(-1\right)^{n+1}}{n}\lfloor\sqrt{n}\rfloor \tag{1} \\ &=-\sum_{n\ \text{square}}\frac{\left(-1\right)^{n}}{n}\sqrt{n} -\sum_{n\ \text{not square}}\frac{\left(-1\right)^{n}}{n}\left(\sqrt{n}-\tfrac12+\tfrac1\pi\sum_{k\ge 1}\frac{\sin(2\pi k\sqrt{n})}{k}\right) \tag{2} \\ &=-\left[\sum_{n\ \text{square}}\frac{\left(-1\right)^{n}}{\sqrt{n}} +\sum_{n\ \text{not square}}\frac{\left(-1\right)^{n}}{\sqrt{n}}\right]\ldots \\&\quad\ldots+\tfrac12\color{blue}{\sum_{n\ \text{not square}}\frac{\left(-1\right)^{n}}{n}}-\tfrac1\pi\sum_{n\ \text{not square}}\sum_{k\ge 1}\frac{\left(-1\right)^{n}\sin(2\pi k \sqrt{n})}{nk} \\ \\ &=-\left(\sqrt{2}-1\right)\zeta\left(\tfrac12\right)+\frac12\left(\frac{{\pi^{2}}}{12}-{\ln 2}\right)-\frac{1}{\pi}\color{red}{\sum_{n\geq 1}\sum_{k\geq 1}\frac{\left(-1\right)^{n}\sin\left(2\pi k\sqrt{n}\right)}{nk}} \tag{3} \end{align}$$

In $(1)$, we separate the sum for $s$ into two parts, one over the squares and one over all other naturals, to account for the discontinuity of the following Fourier series at the integers. In $(2)$, we use the Fourier series of the floor function, $\lfloor x\rfloor=\displaystyle x-\tfrac12+\tfrac1\pi\sum_{k\ge 1}\frac{\sin(2\pi kx)}{k}$. In $(3)$, we use that $\sum_{k\geq1}\frac{(-1)^k}{\sqrt{k}}=(\sqrt2-1)\zeta(\frac12)$ (Question 2059712) and that $\sin(2\pi n)=0$ for $n\in\mathbb{N}$. We may evaluate the series in blue with $$\begin{aligned} \sum_{n\ \text{not square}}\frac{\left(-1\right)^{n}}{n} &=\sum_{n\ge1}\frac{\left(-1\right)^{n}}{n}-\sum_{n\ \text{square}}\frac{\left(-1\right)^{n}}{n} \\ &=-\ln2-\sum_{k\ge1}\frac{\left(-1\right)^{k^2}}{k^2} \\ &=-\ln2-\frac{-\pi^2}{12} \end{aligned} $$

by using $\sum_{k\geq1}\frac{(-1)^k}{k^2}=\frac{-\pi^2}{12}$ and that $k^2$ has the same parity as $k$.


Partial analytic solution to $f_1(k)$

The two sums over $n$ and $k$, in the series for $d$, can be swapped, which gives us $\displaystyle d=\frac{-1}{\pi}\sum_{k\ge1}\frac{f_1(k)}{k}$, where $\displaystyle f_1(k)=\sum_{n\geq1}\frac{(-1)^n\sin(2\pi k\sqrt{n})}{n}$, which has the fairly simple Laplace transform $\frac{1}{2\pi}F\left(\frac{x}{2\pi}\right)$, where $\displaystyle F(x)=\sum_{n\ge 1}\frac{\left(-1\right)^{n}}{\sqrt{n}\left(n+x^2\right)}$. Therefore, $\displaystyle d=-\frac{1}{2\pi^{2}}\sum_{k=1}^{\infty}\frac{\mathcal{L}^{-1}\left\{F\left(\frac{s}{2\pi}\right),k\right\}}{k}$.

$F(x)$ has a similar series to the zeta functions. Substituting $x$ for $x^2$ in $F$ and taking the $k$'th derivative gives us $\small\displaystyle \frac{\mathrm{d}^k}{\mathrm{d}x^k}\sum_{n\ge 1}\frac{\left(-1\right)^{n}}{\sqrt{n}\left(n+x\right)}= \sum_{n\ge 1}\frac{(-1)^{k}k!\left(-1\right)^{n}}{\sqrt{n}\left(n+x\right)^{k+1}}$, so we have the interesting Maclaurin series, $\small \displaystyle F(x)=\sum_{k\ge0}\left(-1\right)^{k+1}\left[1-{2^{-\frac{1}{2}-k}}\right]\zeta\left(k+\frac{3}{2}\right)x^{2k}$. Although this only converges within a small radius of convergence, it does hint at the possibility of a closed form or analytic extension of this series.


Comments on further directions

The expression for $s$ converges slower than River Li's but could possibly be tractable. It is similar to the series evaluated in the following questions, which would suggest that it could be amenable to the Euler-Maclaurin, Abel-Plana or Poisson summation formulae. It is also possible that it could be expressed in terms of theta or Bessel functions, though I am yet to find whether this is the case.

  • Question 3374399: $\sum_{n\geq1}\sin(\pi\sqrt{n^2+1})$

  • Question 3364125: $\sum_{n\geq1}\frac{\sin\left(x\sqrt{n^2+a^2}\right)}{\sqrt{n^2+a^2}}$

  • Question 27123 : $\sum_{n\ge1}\frac{\sin\left(\sqrt{n}x\right)}{n}$

  • Question 3352737: $\sum_{1\leq n \leq x}\sin\sqrt{n}$

  • Question 2270: $\sum_{n\geq 1}\frac{\sin(n^x)}{n}$


Addressing conflicting evaluation of $\displaystyle\sum_k$

Wolfgang's analytic solution in the comments for the sum over $k$ had an unexpected value, which I believe was due to $\displaystyle \sum_{k\ge1}\frac{\sin(2\pi k \sqrt{n})}{k} = \frac{i\operatorname{Log}\left({-e^{-2\pi i\sqrt{n}}}\right)}{2}$ only being true for $\sqrt{n}\notin\mathbb{Z}$, where $\operatorname{Log}(z)$ is the principal branch of the complex logarithm. This is because, when $m\in\mathbb{Z}$, we have $\sin(2\pi m)\equiv0$ but $\operatorname{Log}(-e^{-2\pi i m})\equiv\operatorname{Log}(-1)\equiv \pi i$. This is effectively the same problem that made me remove the squares from the earlier Fourier series. If you take into account the discrepant sum over $\sqrt{n}\in\mathbb{Z}$, I believe the two series should be equal.

$$\begin{align}d&=\frac{-i}{2\pi}\sum_{n\ge1}\frac{(-1)^n\operatorname{Log}(-e^{2\pi i \sqrt{n}})}{n}-\left(\sum_{m\ge 1}\frac{-i(-1)^{m^2}(\pi i)}{2\pi m^2}\right) \\ &=\underbrace{-0.489\ldots}_{\approx -0.336072}-\frac12\sum_{m\ge 1}\frac{(-1)^{m}}{m^2} \\ &=-0.489-\frac12\left(\frac{-\pi^2}{12}\right) \\ &=-0.077 \end{align}$$