#15346: Symbolic sums should evaluate
-----------------------------+------------------------
Reporter: kcrisman | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-6.4
Component: symbolics | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
-----------------------------+------------------------
Changes (by jdemeyer):
* priority: minor => major
Old description:
> [http://ask.sagemath.org/question/3152 This ask.sagemath question] points
> out that
> {{{
> sage: k,n = var('k,n')
> sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
> sage: f(x,2)
> -2*sum((-1)^n*sin(n*x)/n, n, 1, 2)
> }}}
> while
> {{{
> sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
> sage: sum(f, n, 1, 2) #using summation function
> -sin(2*x) + 2*sin(x)
> }}}
> User twch found this workaround
> {{{
> sage: var('n')
> sage: def g(x,k):
> sage: return sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
> sage: print g(x,2)
> -sin(2*x) + 2*sin(x)
> }}}
> but I agree with him/her that we should look into how to fix this.
>
> The essential problem is that when Maxima does not simplify a sum, we
> don't have any mechanism (currently) to get it to "just print out all the
> numbers". Which of course may not be very nice when `k` is big, but
> presumably should be allowed to be done by users.
>
> ----
>
> By the way, the way to do this in Maxima is as follows:
> {{{
>
> (%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
> }}}
> so setting `nouns:true` just for this would work, but I can never figure
> out how to do this from within Sage - see #10955.
New description:
[http://ask.sagemath.org/question/3152 This ask.sagemath question] points
out that
{{{
sage: k,n = var('k,n')
sage: f(x,k) = sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
sage: f(x,2)
-2*sum((-1)^n*sin(n*x)/n, n, 1, 2)
}}}
while
{{{
sage: f(x)=(2/n)*(sin(n*x)*(-1)^(n+1))
sage: sum(f, n, 1, 2) #using summation function
-sin(2*x) + 2*sin(x)
}}}
User twch found this workaround
{{{
sage: var('n')
sage: def g(x,k):
sage: return sum((2/n)*(sin(n*x)*(-1)^(n+1)), n, 1, k)
sage: print g(x,2)
-sin(2*x) + 2*sin(x)
}}}
but I agree with him/her that we should look into how to fix this.
The essential problem is that when Maxima does not simplify a sum, we
don't have any mechanism (currently) to get it to "just print out all the
numbers". Which of course may not be very nice when `k` is big, but
presumably should be allowed to be done by users.
----
By the way, the way to do this in Maxima is as follows:
{{{
(%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
}}}
so setting `nouns:true` just for this would work, but I can never figure
out how to do this from within Sage - see #10955.
Possibly related: #9424
See also
- http://ask.sagemath.org/question/9937/how-do-i-evaluate-sum-containing-
factorial/
- http://ask.sagemath.org/question/24911/exponentiation-makes-a-formula-
go-crazy/
--
--
Ticket URL: <http://trac.sagemath.org/ticket/15346#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.