If I define
monom=[x^n for n in range(5)]
then the $n$-th entry $x^n$ is obtained by monom[n]. Why cannot I sum all these? That is,
sum(monom[n], n, 0, 5)
yields error. How can I correctly make it to act as
sum(x^n, n, 0, 5)
?
| 1 | initial version |
If I define
monom=[x^n for n in range(5)]
then the $n$-th entry $x^n$ is obtained by monom[n]. Why cannot I sum all these? That is,
sum(monom[n], n, 0, 5)
yields error. How can I correctly make it to act as
sum(x^n, n, 0, 5)
?
If I definelet
var('x,n')
monom=[x^n for n in range(5)]
then the $n$-th entry $x^n$ is obtained by monom[n]. Why cannot I sum all these? That is,
sum(monom[n], n, 0, 5)
yields error. How can I correctly make it to act as
sum(x^n, n, 0, 5)
?
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.