Opened 6 years ago

Closed 6 years ago

#21645 closed defect (fixed)

Full symbolic sum function

Reported by: rws Owned by:
Priority: major Milestone: sage-7.4
Component: symbolics Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Nils Bruin
Report Upstream: N/A Work issues:
Branch: 7e8d0d0 (Commits, GitHub, GitLab) Commit: 7e8d0d09e3e718144b88664d05d1680a64f7081d
Dependencies: Stopgaps:

Status badges

Description (last modified by rws)

sum(ex,...) always gets sent to calculus.symbolic_sum() where Maxima is called. If unevaluated an anonymous function sum is returned.

sage: ex=sum(gamma(n), n,1,a)
sage: ex.operator()
sage: type(_)
<class 'sage.symbolic.function_factory.NewSymbolicFunction'>

This is unsatisfactory in many regards. Calls always go through Maxima, even if one wants just a sum expression held unevaluated. Also the anonymous function cannot be evaluated or substituted. For these reasons making a full symbolic sum function is a natural decision.

See also #17505

Change History (10)

comment:1 Changed 6 years ago by tmonteil

Indeed ! This issue is known for a while, see this ask question for a dirty workaround. Funnily, i recently got a similar request privately, and was about to open a ticket to add a hold parameter to symbolic sum, i guess this ticket will take care of that too.

comment:2 Changed 6 years ago by rws

Description: modified (diff)

comment:3 Changed 6 years ago by rws

Branch: u/rws/full_symbolic_sum_function

comment:4 Changed 6 years ago by rws

Authors: Ralf Stephan
Commit: 65d3d44d5245feb68ea652184a0024a00d7b7ad6
Status: newneeds_review

New commits:

65d3d4421645: full symbolic sum function

comment:5 Changed 6 years ago by git

Commit: 65d3d44d5245feb68ea652184a0024a00d7b7ad629f7d1b349d606dddfe79086d9c3167d207443bd

Branch pushed to git repo; I updated commit sha1. New commits:

29f7d1b21645: remove forgotten diagnostic

comment:6 Changed 6 years ago by nbruin

Looking at the patch, I see presently special work happens on maxima's return values, which replaces maxima's "inert" sum with sage's newly grown symbolic sum function. I think that's problematic (for instance, we could have nested sums, and the nested sums would escape this treatment).

It should be possible to use the standard SR-to-maxima and maxima-to-SR translation dictionaries for this, just as functions like sin etc. get properly translated. Isn't the line

+        BuiltinFunction.__init__(self, "sum", nargs=4,
+                               conversions=dict(maxima='sum'))

already enough to get the required automatic translations? If not, perhaps there is a manual override somewhere else that needs to be *removed* to let the normal translation take its course?

Version 0, edited 6 years ago by nbruin (next)

comment:7 Changed 6 years ago by git

Commit: 29f7d1b349d606dddfe79086d9c3167d207443bd7e8d0d09e3e718144b88664d05d1680a64f7081d

Branch pushed to git repo; I updated commit sha1. New commits:

7e8d0d021645: remove unnecessary code

comment:8 Changed 6 years ago by rws

You're right!

comment:9 Changed 6 years ago by nbruin

Reviewers: Nils Bruin
Status: needs_reviewpositive_review

Looks good and patchbot is happy (coverage plugin failure seems to be on code that this actual branch doesn't touch)

comment:10 Changed 6 years ago by vbraun

Branch: u/rws/full_symbolic_sum_function7e8d0d09e3e718144b88664d05d1680a64f7081d
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.