Ask Your Question
0

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

asked 11 years ago

terces907 gravatar image

updated 11 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 11 years ago

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?).

Preview: (hide)
link

Comments

kcrisman gravatar imagekcrisman ( 11 years ago )

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: 11 years ago

Seen: 1,740 times

Last updated: Oct 30 '13