| 1 | initial version |
To add to the diversity of answers here, another valid approach is to add a single line to what you already have:
f(x)=x^2
g(x)=x*f(x)
k=var('k')
sum(g(k),k,0,4)
This will return 100. The point is that you can use this syntax to sum the values of a proper function, but not arbitrary Python expressions.
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.