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 +0200

terces907 gravatar image

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

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 +0200

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 +0200 )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 +0200

Seen: 1,611 times

Last updated: Oct 30 '13