| 1 | initial version |
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.
| 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.
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.