3
$\begingroup$

Bug introduced in 7.0 and fixed in 9.0


Mathematica evaluates Sum[((n - y - 1)*(n - y)^2*n^y)/y!, {y, 0, n - 2}] as -2 e^n n. This should not be a negative value. What am I doing wrong?

$\endgroup$
5
  • 2
    $\begingroup$ This is a problem of version 8. In version 9.04 I get (1/(n! Gamma[ n]))(-n! (5 n^n + E^n (1 + 4 n) Gamma[n] - E^n Gamma[n, n] - 2 E^n Gamma[1 + n, n]) + n^n Gamma[n] HypergeometricPFQ[{2, 2, 2}, {1, 1, 1 + n}, n]). $\endgroup$ Mar 11, 2013 at 22:34
  • $\begingroup$ OK. HypergeometricPFQ[{2, 2, 2}, {1, 1, 1 + n}, n] looks very hard to interpret! Do you have any idea what that looks like asymptotically? $\endgroup$
    – Simd
    Mar 11, 2013 at 22:38
  • $\begingroup$ @Sjoerd Interestingly, if you simply change the upper limit from n-2 to n-1 (which introduces a zero into the sum, leaving it unaltered) MMA 8 obtains (1/((1 + n)! Gamma[ 2 + n]))n ((1 + n)! (n^n (1 + 2 n) - E^n Gamma[2 + n] - E^n Gamma[2 + n, n]) + n^n Gamma[2 + n] HypergeometricPFQ[{2, 2, 2}, {1, 1, 2 + n}, n])--which numerical tables show is correct. Also, if the full Sum is involved within a more complex expression, it might get evaluated correctly. $\endgroup$
    – whuber
    Mar 11, 2013 at 22:39
  • $\begingroup$ Lembik, hypergeometric functions are nice: they have series expansions, known poles, integral representations, etc. Take a look at the help page for the series definition. $\endgroup$
    – whuber
    Mar 11, 2013 at 22:40
  • 1
    $\begingroup$ @whuber Fact remains that this particular result is indeed dead wrong. $\endgroup$ Mar 11, 2013 at 22:40

1 Answer 1

2
$\begingroup$

This is apparently a problem of version 8 where I get the same. In version 9.0.1 I get

(1/(n! Gamma[ n]))(-n! (5 n^n + E^n (1 + 4 n) Gamma[n] - E^n Gamma[n, n] - 
2 E^n Gamma[1 + n, n]) + n^n Gamma[n] HypergeometricPFQ[{2, 2, 2}, {1, 1, 1 + n}, n])

or, with nicer formatting,

Mathematica graphics

This can be reduced with

Sum[((n - y - 1)*(n - y)^2*n^y)/y!, {y, 0, n - 2}] // FullSimplify

to

(2 n (n^n - E^n Gamma[n, n]))/Gamma[n]

or, in TraditionalForm,

Mathematica graphics

$\endgroup$
5
  • $\begingroup$ That's very clever of Mathematica! $\endgroup$
    – Simd
    Mar 11, 2013 at 22:54
  • $\begingroup$ WA online gives the same error. Wouldn't they be using the most recent version? $\endgroup$
    – Simd
    Mar 12, 2013 at 18:38
  • $\begingroup$ @Lembic I seem to recall reading that W|A is updated frequently, so indeed that is what one would expect. $\endgroup$ Mar 12, 2013 at 21:25
  • $\begingroup$ I mean W|A gives the wrong answer where apparently 9.0.1 gives the right answer. I don't have 9.0.1 to test sadly. On a related topic, do Wolfram release bug fixes for Mathematica or do you have to wait another year to get an upgrade? $\endgroup$
    – Simd
    Mar 12, 2013 at 22:02
  • $\begingroup$ @lembik I understood what you meant, and I find it curious as well. As to fixes: WRI releases only a few updates for each major version. Generally I'd say two or three. Depending on your license you may or may not have access to them. $\endgroup$ Mar 13, 2013 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.