| 1 | initial version |
Instead of using the symbolic sum that you mention, you can use Python's built-in sum that takes an iterable such as a generator expression:
sage: n = 5
sage: sum((j if j % 2 == 0 else j + 1)*x^j for j in range(1,n+1))
6*x^5 + 4*x^4 + 4*x^3 + 2*x^2 + 2*x
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.