Opened 4 years ago
Closed 4 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: |
Description (last modified by )
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() sum 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 4 years ago by
comment:2 Changed 4 years ago by
- Description modified (diff)
comment:3 Changed 4 years ago by
- Branch set to u/rws/full_symbolic_sum_function
comment:4 Changed 4 years ago by
- Commit set to 65d3d44d5245feb68ea652184a0024a00d7b7ad6
- Status changed from new to needs_review
New commits:
65d3d44 | 21645: full symbolic sum function
|
comment:5 Changed 4 years ago by
- Commit changed from 65d3d44d5245feb68ea652184a0024a00d7b7ad6 to 29f7d1b349d606dddfe79086d9c3167d207443bd
Branch pushed to git repo; I updated commit sha1. New commits:
29f7d1b | 21645: remove forgotten diagnostic
|
comment:6 Changed 4 years ago by
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). Also, the test used (isinstance(op,SymbolicFunction)
) is a little suspicious: I think it would get the result from
sum(f(x),n,0,0)
wrong.
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?
comment:7 Changed 4 years ago by
- Commit changed from 29f7d1b349d606dddfe79086d9c3167d207443bd to 7e8d0d09e3e718144b88664d05d1680a64f7081d
Branch pushed to git repo; I updated commit sha1. New commits:
7e8d0d0 | 21645: remove unnecessary code
|
comment:8 Changed 4 years ago by
You're right!
comment:9 Changed 4 years ago by
- Reviewers set to Nils Bruin
- Status changed from needs_review to positive_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 4 years ago by
- Branch changed from u/rws/full_symbolic_sum_function to 7e8d0d09e3e718144b88664d05d1680a64f7081d
- Resolution set to fixed
- Status changed from positive_review to closed
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.