Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

"TypeError: need a summation variable" when i use function with for loop

I try to make a summation list and the commands are below this:

sage: var('n')

sage: var('x')

sage: f = (2/n)(sin(nx)*(-1)^(n+1))

sage: funclist = [sum(f,n,1,20) for n in range(1,3)]

but i found an error message:

TypeError: need a summation variable

How to solve this problem?

Sage showed "TypeError: need a summation variable" when i use used sum function with for loop

I try to make a summation list and the commands are below this:

sage: var('n')

sage: var('x')

sage: f = (2/n)(sin(nx)*(-1)^(n+1))

sage: funclist = [sum(f,n,1,20) for n in range(1,3)]

but i found an error message:

TypeError: need a summation variable

How to solve this problem?

Sage showed "TypeError: need a summation variable" when i used sum function with for loop

I try to make a summation list and the commands are below this:

sage: var('n')

sage: var('x')

sage: f = (2/n)(sin(nx)*(-1)^(n+1))(2/n)*(sin(n*x)*(-1)^(n+1))

sage: funclist = [sum(f,n,1,20) for n in range(1,3)]

but i found an error message:

TypeError: need a summation variable

How to solve this problem?