Sage: Ticket #9630: Python ints should have a conversion to Maxima
https://trac.sagemath.org/ticket/9630
<p>
I don't know how this might be done, but
</p>
<pre class="wiki">for n in range(1,10):
sum(k, k, 1, n)
</pre><p>
doesn't work, while
</p>
<pre class="wiki">for n in [1..10]:
sum(k,k,1,n)
</pre><p>
does. We need to fix
</p>
<pre class="wiki">int(3)._maxima_()
AttributeError: 'int' object has no attribute '_maxima_'
</pre><p>
Duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9393" title="defect: symbolic sum cannot handle python ints (closed: fixed)">#9393</a>.
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/9630
Trac 1.1.6nbruinThu, 29 Jul 2010 06:31:11 GMT
https://trac.sagemath.org/ticket/9630#comment:1
https://trac.sagemath.org/ticket/9630#comment:1
<p>
the particular error that arises here is raised in sage/calculus/calculus.pyc line 501:
</p>
<pre class="wiki">sum = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)])
</pre><p>
One could fix this one by first coercing a,b into SR. As an example:
</p>
<pre class="wiki">sage: SR(int(1))._maxima_()
1
</pre><p>
This code looks rather convoluted to me anyway: Convert to maxima, take string representative, paste together and then simplify? Shouldn't the whole sum first be turned into a pynac sum expression, the whole thing converted to maxima, simplified, and then cast back?
</p>
<pre class="wiki">sage: var("x,a,b") # this is just because I don't know
sage: SUM=sum(sin(x^2),x,a,b).operator() # where this is defined
sage: SR(SUM(x,x,1,int(10))._maxima_().simplify_sum())
55
</pre>
TicketkcrismanThu, 29 Jul 2010 13:23:47 GMT
https://trac.sagemath.org/ticket/9630#comment:2
https://trac.sagemath.org/ticket/9630#comment:2
<p>
Sure, if Pynac sum expressions had been known to exist (or how to use them) when this code went in. There was also some weird bug that this originally took care of that had to do with held expressions in Maxima, if I recall correctly, though that had ceased to be an issue.
</p>
<p>
This just goes to show that we need some sort of Pynac tutorial so that more people can be effective on this!
</p>
TicketmjoMon, 16 Jan 2012 05:29:30 GMTcc set
https://trac.sagemath.org/ticket/9630#comment:3
https://trac.sagemath.org/ticket/9630#comment:3
<ul>
<li><strong>cc</strong>
<em>mjo</em> added
</li>
</ul>
<p>
I don't think it's possible to monkey-patch methods onto int, but the symbolic sum issue has been fixed and I have a patch with a doctest (needs review!) at <a class="closed ticket" href="https://trac.sagemath.org/ticket/9393" title="defect: symbolic sum cannot handle python ints (closed: fixed)">#9393</a>.
</p>
TicketburcinMon, 16 Jan 2012 09:39:42 GMTstatus, milestone changed; reviewer set
https://trac.sagemath.org/ticket/9630#comment:4
https://trac.sagemath.org/ticket/9630#comment:4
<ul>
<li><strong>status</strong>
changed from <em>new</em> to <em>needs_review</em>
</li>
<li><strong>reviewer</strong>
set to <em>Michael Orlitzky, Burcin Erocal</em>
</li>
<li><strong>milestone</strong>
changed from <em>sage-4.8</em> to <em>sage-duplicate/invalid/wontfix</em>
</li>
</ul>
<p>
This is a duplicate of <a class="closed ticket" href="https://trac.sagemath.org/ticket/9393" title="defect: symbolic sum cannot handle python ints (closed: fixed)">#9393</a>. There is a patch with a doctest attached to that ticket.
</p>
TicketburcinMon, 16 Jan 2012 09:39:49 GMTstatus changed
https://trac.sagemath.org/ticket/9630#comment:5
https://trac.sagemath.org/ticket/9630#comment:5
<ul>
<li><strong>status</strong>
changed from <em>needs_review</em> to <em>positive_review</em>
</li>
</ul>
TicketjdemeyerMon, 16 Jan 2012 10:07:05 GMTstatus, description changed; resolution set
https://trac.sagemath.org/ticket/9630#comment:6
https://trac.sagemath.org/ticket/9630#comment:6
<ul>
<li><strong>status</strong>
changed from <em>positive_review</em> to <em>closed</em>
</li>
<li><strong>resolution</strong>
set to <em>duplicate</em>
</li>
<li><strong>description</strong>
modified (<a href="/ticket/9630?action=diff&version=6">diff</a>)
</li>
</ul>
Ticket