Ask Your Question
0

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

asked 2013-10-29 23:43:42 -0500

terces907 gravatar image

updated 2013-10-30 00:41:24 -0500

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

sage: var('n')

sage: var('x')

sage: f = (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?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-10-30 00:35:46 -0500

Luca gravatar image

Your last line is equivalent to

[sum(f,1,1,20), sum(f,2,1,20)]

For each of these, Sage complains that it doesn't know on which variable to sum on (x or n?).

edit flag offensive delete link more

Comments

kcrisman gravatar imagekcrisman ( 2013-10-30 02:47:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-10-29 23:43:42 -0500

Seen: 1,254 times

Last updated: Oct 30 '13