Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to add a condition in the sum funciton in sage

I want to implement the following sum $\sum_{j=0}^{n}a_jx^j$ under the following conditions the coefficient $a_j=j$ if $j $ is even, or $j+1$ otherwise. My problem is how to include these cases in the sum function in sage. Normally the command is sum(a_j*x^j,j,1,n) but how to distinguish between the parity of j ?

click to hide/show revision 2
None

How to add a condition in the sum funciton in sage

I want to implement the following sum $\sum_{j=0}^{n}a_jx^j$ under the following conditions the coefficient $a_j=j$ if $j $ is even, or $j+1$ otherwise. My problem is how to include these cases in the sum function in sage. Normally the command is sum(a_j*x^j,j,1,n) but how to distinguish between the parity of j ?