How do I calculate sum of a finite harmonic series of the following form?
$$\sum_{k=a}^{b} \frac{1}{k} = \frac{1}{a} + \frac{1}{a+1} + \frac{1}{a+2} + \cdots + \frac{1}{b}$$
Is there a general formula for this? How can we approach this if not?
How do I calculate sum of a finite harmonic series of the following form?
$$\sum_{k=a}^{b} \frac{1}{k} = \frac{1}{a} + \frac{1}{a+1} + \frac{1}{a+2} + \cdots + \frac{1}{b}$$
Is there a general formula for this? How can we approach this if not?
On
Let $H_{x} = \frac{1}{1}+\frac{1}{2}+\frac{1}{3}+\cdots+\frac{1}{x}$.
So if I'm not wrong, what you are looking for is, $H_{b}−H_{a - 1}$
On
This answer is more for additional information and as an exercise for myself to remember Gosper's algorithm.
There is no nice closed formula for this. By nice we can take hypergeometric functions (functions $f(n)$ such that $f(n+1)/f(n)$ is a rational function) or even finite sums of hypergeometric functions. If there were, in particular you would get a nice closed formula for $H(n):=1+1/2+1/3+...+1/n$.
Assume that $H(n)$ is hypergeometric. Then $1/n=H(n)-H(n-1)$, i.e. $$nH(n)-nH(n-1)=1$$.
Now, since we are assuming $H$ is hypergeometric we get $$nH(n)=\frac{H(n)}{(H(n+1)-H(n))}=\frac{1}{\frac{H(n+1)}{H(n)}-1},$$
which should be rational. So, we are looking for a rational function $K(n):=nH(n)$ such that
$$(n-1)K(n)-nK(n-1)=n-1.$$
Observe that if $a\neq1$ is a pole of $K(n)$ then it would have to be a pole of $K(n-1)$. If $1$ is a pole of $K$ then $-2$ is a pole of $K(n-1)$ and therefore also a pole of $K$. This is impossible because it implies $K$ has infinitely many poles. Therefore $K$ is a polynomial. But there are no polynomials satisfying this equation. In fact, assume $K(n)=an^r+bn^{r-1}+\ldots$. Plug it in the equation and you get that the leading term of the left hand side is $(r-1)an^r$. Therefore we get that $r=1$ and $(r-1)a=1$ from imposing that it should be equal to the right hand side $n-1$. But these equations are impossible.
Thus $H$ is not an hypergeometric function. Further arguments show that it can't be either a finite sum of hypergeometric functions.
You can't find a general formula. All you can do is the use the standard asymptotic formula for the harmonic sum
$$H_n = \sum_{k=1}^n \frac1k = \ln n + \gamma +\frac1{2n} -\frac1{12n^2} + \frac1{120n^4} + ... $$
where $\gamma \approx 0.5772156649$ is the Euler–Mascheroni constant.
Your sum would be $H_b - H_{a-1}$.