Closed form of a sum of ratios of integers

169 Views Asked by At

I am computing in a program this sum (does it have a "name"):

$$\sum_{\alpha=2}^{K} \frac{\alpha-1}{\alpha}$$

is there a way to avoid the sum, term by term, and use a more compact closed form ?

3

There are 3 best solutions below

3
On BEST ANSWER

No there isn't, because finding a compact form for the sum is equivalent to find a compact form for the harmonic sum $$ \sum_{k=1}^n \frac1k $$ which we know that doesn't exists. But you can approximate your sum by using $$ \sum_{k=1}^n \frac1k=\log(n)+\gamma+O(n^{-1}) $$

4
On

$$\sum_{\alpha=2}^{K} \frac{\alpha-1}{\alpha}=K-\digamma^{(0)}(K+1)-\gamma$$

With

$\digamma^{(0)}$ is the derivative of the digamma function

and

$\gamma$ is the eulergamma

5
On

In the comments I proposed following formula for $K\gg 1$ (about $15$ digits precision for $K>30$) $$K-\gamma-\log(K+1/2)-\frac 1{24K^2}+\frac 1{24K^3}-\frac{23}{960K^4}+\frac 1{160K^5}+\frac {11}{8064K^6}+\frac 1{896K^7}$$ and to compute directly $\,K-H_K\;$ for small values of $K$ ($H_K=\displaystyle\sum_{i=1}^K\frac 1i\;$ is an harmonic number).

This works well using machine precision (simple or double precision computations) but for higher precision a variant of this formula will be useful.

Let's concentrate on the evaluation of $H_K$ : the idea is to compute the $m$ first terms of $H_K$ (with $m$ much smaller than $K$) and to approximate the remaining terms $\;\displaystyle\sum_{i=m+1}^K\frac 1i\;$ using the Euler-Maclaurin formula applied to $f(i)=\dfrac 1i\;$ with $p$ Bernoulli numbers $B_{2i}$. This gives :

$$H_K\approx\sum_{i=1}^m \frac 1i+\log\frac Km-\frac{\frac 1m-\frac 1K}2+\sum_{i=1}^p \frac{B_{2i}}{2i}\left(\frac 1{m^{2i}}-\frac 1{K^{2i}}\right)$$

This is an asymptotic expansion and the error will be smaller than the last term that is about $\dfrac{B_{2p}}{2p\;m^{2p}}$. From the asymptotic expansion of $B_{2p}$ the error will thus be of order $\,\left(\dfrac p{\pi\, e \,m}\right)^{2p}$.

You will probably have to experiment a little to find the adequate values of $m$ and $p$ for your purpose ($p$ should not be too large because of the cost of evaluation of $B_{2p}$ but clearly a larger $p$ will require a much smaller value of $m$ for the same precision).


pari/gp script and session :

h(m)=sum(i=1,m,1./i)
Ha(K,m,p)=h(m)+log(K/m)-(1/m-1/K)/2+sum(i=1,p,bernfrac(2*i)/(2*i)*(1/m^(2*i)-1/K^(2*i)))

> \p 200
realprecision = 202 significant digits (200 digits displayed)
> Ha(10^7,100,100)
time = 35 ms.
%117 = 16.695311365859851815399118939540451884249869752373080462785135954356288692174254687711603714370150288290523817663737266777337218196739075784366572290986079962307335928126443225226765412693037825657127
>  h(10^7)
time = 20,941 ms.
%118 = 16.695311365859851815399118939540451884249869752373080462785135954356288692174254687711603714370150288290523817663737266777337218196739075784366572290986079962307335928126443225226765412693054650051411
> %-%117
%119 = 1.6824394283730879816 E-188

The first evaluation is much faster (to $188$ digits precision here) !

Excellent experimentations,