Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: n, k = var('n, k')
sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f
(x, k) |--> -2*sum((-1)^n*sin(n*x)/n, n, 1, k)

I'm not sure what you think is wrong here. The 2 and a factor of -1 were both factored out, that's all.

However, I do agree that this doesn't expand. What is happening is that we are sending the sum to Maxima

if algorithm == 'maxima':
    return maxima.sr_sum(expression,v,a,b)

and then ordinarily when it returns, it is still a Maxima object (which may be a bug?). But when we put it in the function, it becomes a Sage object - but we don't have a Sage "sum" object. So I think that is what would have to be fixed.

sage: n, k = var('n, k')
sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
#where n = 1,2,3 ... k
sage: f
(x, k) |--> -2*sum((-1)^n*sin(n*x)/n, n, 1, k)

I'm not sure what you think is wrong here. The 2 and a factor of -1 were both factored out, that's all.

However, I do agree that this doesn't expand. What is happening is that we are sending the sum to Maxima

if algorithm == 'maxima':
    return maxima.sr_sum(expression,v,a,b)

and then ordinarily when it returns, it is still a Maxima object (which may be a bug?). But when we put it in the function, it becomes a Sage object - but we don't have a Sage "sum" object. So I think that is what would have to be fixed.


That this is possible is shown by the following Maxima example (which I put on the ticket):

(%i1) f: -2*'sum((-1)^n*sin(n*x)/n,n,1,2);
                                2
                               ====       n
                               \     (- 1)  sin(n x)
(%o1)                      - 2  >    ---------------
                               /            n
                               ====
                               n = 1

(%i8) f, nouns;
                                 sin(2 x)
(%o8)                       - 2 (-------- - sin(x))
                                    2