# Bug in mathematica: computing the sum of the ratios $(n-k+1)/(n-k+2)$

While experimenting with certain sums, I came to the following sum:

$$S_n = \sum_{k=0}^n \frac{n-k+1}{(n+1) (n+2) (n-k+2)}.$$

After rewriting the summand as $$\frac{n-k+1}{(n+1) (n+2) (n-k+2)} = \frac{n^{\underline{k}}}{(n+2)^{\underline{k}}(n-k+2)^2}$$ and then feeding the sum to Mathematica, i obtained $$S_n = \frac{7}{6(n+1)(n+2)}$$

But directly summing the first expression above does not yield this closed-form result, because this "result" is wrong! (see edits below) Where is the bug or what am i missing?

EDIT: There seems to be some bug / feature in Mathematica which is leading to the erroneous computation above; the correct answer is of course, as also observed in two answers below. If someone can explain the bug, then he / she should feel free to report it to Wolfram.

(To be specific, the answer above is using $7/6 = (1+2)-H_{1+2}$, instead of $n+2 - H_{n+2}$ as it should)

-
You sure about what you're getting? I get $\frac1{n+1}-\frac1{n^2+3n+2}\sum_{j=1}^{n+2}\frac1{j}$. – J. M. Nov 21 '10 at 11:28
@JM: I tried summing with: FactorialPower[n,k]/(FactorialPower[n+2,k] (n-k+2)^2 and that gives me the simplied sum i wrote; otherwise after replacing $n-k$ by $k$ in the first sum, I got something like what you have. i am confused as of now! – user1709 Nov 21 '10 at 11:37
$VersionNumber, if you don't mind? – J. M. Nov 21 '10 at 11:44 am using version 7. – user1709 Nov 21 '10 at 11:50 FactorialPower[n,k]/(FactorialPower[n+2,k] (n-k+2)^2 seems to be missing needed parentheses... – J. M. Nov 21 '10 at 12:00 ## 3 Answers You can write the sum as $$\frac1{(n+1)(n+2)} \sum_{k=0}^{n} \frac{n+1-k}{n+2-k},$$ so it's enough to compute the last part of it. This is just $$\frac{n+1}{n+2} + \frac{n}{n+1} + \dots + \frac{n+1-n}{n+2-n} = 1 - \frac1{n+2} + 1 - \frac1{n+1} + \dots + 1 - \frac1{n+2-n}$$ $$= n + 2 - H_{n+2},$$ where$H_n = \sum_{k=1}^n \frac1{k}$is the$n$:th Harmonic number. Your sum is then $$\frac{n + 2 - H_{n+2}}{(n+1)(n+2)}.$$ - thanks for your answer. i got this sum too; but it seems somewhere in mathematica i am doing something wrong, because of which i keep getting the first sum, which made me think that i have a bug, and i asked the question. – user1709 Nov 23 '10 at 22:09 Here is the same answer with a variation on the calculations$\begin{eqnarray*} S_{n} &=&\sum_{k=0}^{n}\dfrac{n-k+1}{(n+1)(n+2)(n-k+2)} \\ &=&\dfrac{1}{(n+1)(n+2)}\sum_{k=0}^{n}\dfrac{n-k+1}{n-k+2}\qquad (n+1)(n+2)% \text{ is independent of }k \\ &=&\dfrac{1}{(n+1)(n+2)}\sum_{m=2}^{n+2}\frac{m-1}{m}\qquad \text{substitution }m=n-k+2 \\ &=&\dfrac{1}{(n+1)(n+2)}\sum_{m=2}^{n+2}\left( 1-\dfrac{1}{m}\right) \\ &=&\dfrac{1}{(n+1)(n+2)}\left(\sum_{m=2}^{n+2}1\right)-\dfrac{1}{(n+1)(n+2)}\sum_{m=2}^{n+2}% \dfrac{1}{m} \\ &=&\dfrac{n+2-2+1}{(n+1)(n+2)}-\dfrac{1}{(n+1)(n+2)}\left( \sum_{i=1}^{n+2}% \dfrac{1}{i}\right) +\dfrac{1}{(n+1)(n+2)} \\ &=&\dfrac{n+1}{(n+1)(n+2)}-\dfrac{H_{n+2}}{(n+1)(n+2)}+\dfrac{1}{(n+1)(n+2)} \\ &=&\dfrac{n+2-H_{n+2}}{(n+1)(n+2)}, \end{eqnarray*}$where$H_{n+2}=\displaystyle\sum_{i=1}^{n+2}\dfrac{1}{i}.\$

-
Thanks for your details; I had gotten this sum too, but mathematica was giving the wrong version quoted in my question above. i think this discrepancy reveals a bug in mathematica! – user1709 Nov 22 '10 at 22:14

Mathematica apparently does not have a nice way of looking at the sum as it is given,

$$S_n = \sum_{k=0}^n \frac{n-k+1}{(n+1) (n+2) (n-k+2)}.$$

However, when you calculate this sum as a definite integral, for both the equation above and the one you derived, ie

$$\sum_{k=0}^{n=p} \frac{n^{\underline{k}}}{(n+2)^{\underline{k}}(n-k+2)^2}.$$

Where p is the number you enter to make it a definite sum, you get the same calculation as when using the original equation.

I initially used the FactorialPower[n,k] command and then I thought that maybe the domain for k was causing issues, so I rewrote the falling factorials using the gamma function to see if that would help. If you are not familiar with how to do this,

$$n^{\underline{k}} = \frac{ \Gamma (n+1)}{ \Gamma (n-k+1)}$$.

Either way I write the falling factorial, I still come up with the equation you are getting when I use an indefinite sum, which is,

$$S_n = \frac{7}{6(n+1)(n+2)}$$.

As you know, this is in fact not correct. I am not sure why it works for the definite sum, but not the indefinite sum. I will keep thinking about this and let you know what I come up with, if I come up with anything.

If you find an answer, please let us know here. Sorry I cannot be of more help.

-
thanks for trying out Tyler. – user1709 Nov 24 '10 at 11:26