# Revision history [back]

The symbolic sum sum(((-1)^l/factorial(l)),l,0,n) is not "spontaneously" evaluated. You might force that by using the numerical_approximation method (but this gives you a float where an exact (Integer) result is available).

Another workaround is to convert this expression to a Sympy expression, and force its evaluation via the doit method :

sage: Dn
factorial(n)*sum((-1)^l/factorial(l), l, 0, n)
sage: Dn.subs(n=7)
5040*sum((-1)^l/factorial(l), l, 0, 7)
sage: Dn.subs(n=7)._sympy_()
5040*Sum((-1)**l/factorial(l), (l, 0, 7))
sage: Dn.subs(n=7)._sympy_().doit()
1854


BTW, Sage might benefit of such a method...

The symbolic sum sum(((-1)^l/factorial(l)),l,0,n) is not "spontaneously" evaluated. You might force that by using the numerical_approximation method (but this gives you a float where an exact (Integer) result is available).

EDIT : tmonteil types faster than I do. My answer was a bit late, but quasi-identical to Thierry's, which is the simplest solution.

Another workaround is to convert this expression to a Sympy expression, and force its evaluation via the doit method :

sage: Dn
factorial(n)*sum((-1)^l/factorial(l), l, 0, n)
sage: Dn.subs(n=7)
5040*sum((-1)^l/factorial(l), l, 0, 7)
sage: Dn.subs(n=7)._sympy_()
5040*Sum((-1)**l/factorial(l), (l, 0, 7))
sage: Dn.subs(n=7)._sympy_().doit()
1854


BTW, Sage might benefit of such a method...this workaround may help in cases where Sage's simplify fails to find an answer (it happens...).