Opened 11 years ago

Closed 9 years ago

#9630 closed defect (duplicate)

Python ints should have a conversion to Maxima

Reported by: kcrisman Owned by: burcin
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: mjo Merged in:
Authors: Reviewers: Michael Orlitzky, Burcin Erocal
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

I don't know how this might be done, but

for n in range(1,10): 
    sum(k, k, 1, n) 

doesn't work, while

for n in [1..10]:

does. We need to fix

AttributeError: 'int' object has no attribute '_maxima_'

Duplicate of #9393.

Change History (6)

comment:1 Changed 11 years ago by nbruin

the particular error that arises here is raised in sage/calculus/calculus.pyc line 501:

sum  = "'sum(%s, %s, %s, %s)" % tuple([repr(expr._maxima_()) for expr in (expression, v, a, b)])

One could fix this one by first coercing a,b into SR. As an example:

sage: SR(int(1))._maxima_()

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?

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())

comment:2 Changed 11 years ago by kcrisman

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.

This just goes to show that we need some sort of Pynac tutorial so that more people can be effective on this!

comment:3 Changed 9 years ago by mjo

  • Cc mjo added

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 #9393.

comment:4 Changed 9 years ago by burcin

  • Milestone changed from sage-4.8 to sage-duplicate/invalid/wontfix
  • Reviewers set to Michael Orlitzky, Burcin Erocal
  • Status changed from new to needs_review

This is a duplicate of #9393. There is a patch with a doctest attached to that ticket.

comment:5 Changed 9 years ago by burcin

  • Status changed from needs_review to positive_review

comment:6 Changed 9 years ago by jdemeyer

  • Description modified (diff)
  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.