Ask Your Question

Revision history [back]

Given the syntax of the sum() function, which can be read by executing "sum?" (with the question mark) in the Sage notebook, you don't need to define a list to compute the sum. For example,

sage: var('x')
sage: f = x^2   # note that you don't write f(x) = x^2
sage: sum(f,x,0,4)
30

Also, be careful defining a variable, x, as well as a list with the same name. (You write f = x^2 as well as x=[0,1,2,3,4].) Hope this helps.

click to hide/show revision 2
Clarified parenthetical remark.

Given the syntax of the sum() function, which can be read by executing "sum?" (with the question mark) in the Sage notebook, you don't need to define a list to compute the sum. For example,

sage: var('x')
sage: f = x^2   # note that you don't write f(x) = x^2
sage: sum(f,x,0,4)
30

Also, be careful defining a variable, x, as well as a list with the same name. (You write wrote f = x^2 as well as x=[0,1,2,3,4].) Hope this helps.