ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 04 Nov 2013 05:18:21 +0100Sum a list of vectorshttps://ask.sagemath.org/question/10658/sum-a-list-of-vectors/I'm given a list of rational vectors, i.e., something like [(1,2,3), (1/2, 4, 5), (-1, 0, 0)], and I need to sum all vectors of this list.
Even though I searched a bit, I cannot find the right sage command for this task. For example, sum() does not seem to work here. At least I couldn't figure out how to apply it to a list of such type.
Of course I could use a loop and an additional variable that saves the partial sums. But there has to be a more elegant way.SamsaMon, 04 Nov 2013 05:18:21 +0100https://ask.sagemath.org/question/10658/Sage showed "TypeError: need a summation variable" when i used sum function with for loophttps://ask.sagemath.org/question/10674/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(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?
terces907Wed, 30 Oct 2013 05:43:42 +0100https://ask.sagemath.org/question/10674/