In this question on Math.SE there appears this sum: $$ S = \sum_{n\geq1}s_n, \qquad s_n = \frac{|\sin n|^n}{n}, $$ which converges very slowly. What methods would you suggest for evaluating it numerically?

What I managed to do is unsatisfactory. Pick a bound $M$, and approximate the remainder of the sum over $n\geq M$ using $$ \frac{|\sin n|^n}{n} \approx \frac1\pi\int_0^\pi \frac{|\sin t|^n}{n}\,dt = T_n, $$ then write $$S_M = \sum_{1\leq n<M}s_n + \sum_{n\geq M}T_n. $$ The infinite sum over $T_n$ has a closed form in terms of generalized hypergeometric functions.

I tried Shanks and Cohen-Villegas-Zagier convergence acceleration techniques (in mpmath) applied to $S_{10^6k}$ and $S_{10^7k}$, $1\leq k\leq10$, but they didn't work well, giving values about $10^{-3}$ away from each other ($2.151$). When I tried to fit $$ S_M = S_\infty + b M^\alpha, $$ for $M=\{1,2,3\}\times 10^7$, I got $\alpha=-\frac12$ and $$ S_\infty = 2.1509. $$

This is only five digits with $10^7$ terms. Is there a better method?

EDIT The values for $S_{10^6\{1\ldots10\}}$ are:

Z6 = [2.1503320981264467, 2.1504796881940735, 2.150563926321965,
      2.150601535111673, 2.1506361337302553, 2.1506605927579456,
      2.15067535745342, 2.150691134235195, 2.1507008825140925,

The values for $S_{10^7\{1\ldots10\}}$ are:

Z7 = [2.1507120293097395, 2.1507656995403974, 2.1507894767527613,
      2.1508036508488018, 2.1508133237402696, 2.150820463977797,
      2.1508260133696635, 2.1508304866069095, 2.150834191855564,

The values for $S_{1+10^8\{1\ldots10\}}$ are:

Z8 = [2.1508373250785855, 2.1508542694443973, 2.1508618019128343,
      2.150866279387301, 2.150869344143939, 2.1508715999897547,
      2.150873358367117, 2.1508747716998142, 2.1508759457833806,

The main reason I say that convergence acceleration seems to fail is that it gives somewhat different results (error $\sim 10^{-3}$) for $Z_6$ and $Z_7$. The simple model above gives the same result (to five digits), but introducing the next asymptotic term and trying to fit $S_\infty+b_1 M^{-1/2}+b_2 M^{-3/2}$ makes the two series agree slightly less, not more.

EDIT When fitting $S_\infty+b M^{-1/2}$ with least squares one thing to note is that the estimate for $Z_7$ lies two estimated standard errors from the estimate for $Z_6$, so I'm not sure how accurate it is. The better value, estimated from $Z_7$ seems to be $2.150895272(1)$, but this might be inaccurate.

EDIT The sum $\sum_{n\geq m}T_n$ behaves as $m^{-1/2}$ as $m\to\infty$, and is given by $$ \frac{\Gamma(m)}{\pi 2^m}\left(\frac{2}{\Gamma(1+\frac m2)^2}F\left( \begin{array}{c} 1,\frac{1+m}{2},\frac m2\\1+\frac m2,1+\frac m2 \end{array}\right) + \frac{m}{\Gamma(\frac{3+m}{2})^2}F\left(\begin{array}{c} 1,\frac{1+m}{2},1+\frac m2\\ \frac{3+m}{2},\frac{3+m}{2}\end{array} \right) \right). $$

  • $\begingroup$ Could you post the values of $S_M$ for $M=\{1,2,3,4,5,6,7,8,9,10\}\times 10^7$ ? $\endgroup$ Jun 22, 2014 at 4:25
  • $\begingroup$ @Kirill Did they prove over on the other page that the sum was less than or equal to 2.15? $\endgroup$
    – bobbym
    Jun 22, 2014 at 7:41
  • $\begingroup$ @ClaudeLeibovici I edited the question with the numbers. $\endgroup$
    – Kirill
    Jun 23, 2014 at 3:13
  • $\begingroup$ @bobbym I'm not sure. $\endgroup$
    – Kirill
    Jun 23, 2014 at 4:24
  • $\begingroup$ It seems that the next dominant error term in $S_M$ is coming from the tail of the sum over the $s_n$ rather than from the sum over the $T_n$. I wonder what kind of asymptotic series it has? $\endgroup$ Jun 23, 2014 at 5:07

1 Answer 1


For example to get the sum with an error not much above $10^{-20}$, I'd sum up only those values that make a contribution greater than $10^{-20}/n$. And that's quite simple, because $|\sin(n)|^n$ while be greater than $10^{-20}$ only if $|\sin(n)|>10^{-20/n}$ or if $|\sin(n)|>1 - 46.05 /n$, and for say $n > 1,000,000$, these $n$ are quite rare and could be found say using Euclid's algorithm - they are all integers $n$ close to odd multiples of $\pi/2$.

Addition: $|\sin(n)|>1 - 46.05 /n$ iff $|\cos (n)|>9.6 n^{-1/2}$, and that is about how close $n$ would have to be to an odd multiple of $\pi/2$. So this is less rare than I hoped - but still quite rare when $n \geq 10^9$, for example. And consecutive integers that are close to odd multiples of $\pi/2$ are very easy to find with a slight adaption of Euclid's algorithm. So the effort to calculate the sum up to n grows only with $n^{1/2}$, which means adding up to say $n=10^{24}$ or so is feasible.

And then of course extrapolation can be used to improve the result.

PS. Doing the summation using long double (64 bit precision), there are only 2,296 values $n$ between $30 \cdot 10^9$ and $30.1 \cdot 10^9$ where $\sin(n)$ is close enough to $ \pm 1$ so that the sum actually gets changed, that is less than one in 43,000 values. Picking only those values would make the calculation obviously a lot faster.

  • 6
    $\begingroup$ Could you post the code and the value you got for the sum? $\endgroup$
    – Kirill
    Jun 23, 2014 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .