Ask Your Question
0

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

asked 2013-10-30 05:43:42 +0100

terces907 gravatar image

updated 2013-10-30 06:41:24 +0100

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 06:35:46 +0100

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 08:47:58 +0100 )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-30 05:43:42 +0100

Seen: 1,674 times

Last updated: Oct 30 '13