Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why is sum(LIST[n], n, 0, 5) for a given list LIST wrong?

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)

?

Why is sum(LIST[n], n, 0, 5) for a given list LIST wrong?

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)

?