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?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityThis 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,
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
,
(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$n-2
ton-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 fullSum
is involved within a more complex expression, it might get evaluated correctly. $\endgroup$