Opened 6 years ago
Last modified 3 years ago
#17400 needs_work defect
simplify_full returns odd result from symbolic series input
Reported by: | rws | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-7.4 |
Component: | symbolics | Keywords: | |
Cc: | Merged in: | ||
Authors: | Ralf Stephan | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | u/rws/17400-1 (Commits, GitHub, GitLab) | Commit: | 22c947a8ee6d435db6d103246e88674d50e12286 |
Dependencies: | #17399, #17659 | Stopgaps: |
Description (last modified by )
SR
.series will lose the order term when passed to Maxima. Thus only the coefficients may be simplified, and this must be done in all simplify*
functions.
sage: x=var('x') sage: s=(1/(1-x)).series(x,6) sage: s.coeffs() [[x^5 + x^4 + x^3 + x^2 + x + Order(x^6) + 1, 0]] sage: s.simplify_full().coeffs() [[Order(x^6) + 1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]
See also the related #17399.
Originally found in http://ask.sagemath.org/question/24968/coefficients-in-polynomial-ring-over-symbolic-ring/
Also, series
should simplify its terms on a per-term basis:
sage: var('x,y') (x, y) sage: ex=1/(1-x*y-x^2) sage: ex.series(x,5) 1 + (y)*x + (y^2 + 1)*x^2 + ((y^2 + 1)*y + y)*x^3 + (((y^2 + 1)*y + y)*y + y^2 + 1)*x^4 + Order(x^5)
Compare with e.g. Pari:
? 1/(1-x*y-x^2) + O(x^5) %1 = 1 + y*x + (y^2 + 1)*x^2 + (y^3 + 2*y)*x^3 + (y^4 + 3*y^2 + 1)*x^4 + O(x^5)
Both issues can be fixed by writing series simplification methods.
Change History (22)
comment:1 Changed 6 years ago by
- Description modified (diff)
comment:2 Changed 6 years ago by
- Description modified (diff)
comment:3 Changed 6 years ago by
comment:4 follow-up: ↓ 18 Changed 6 years ago by
- Description modified (diff)
There are no power series objects in Maxima, just conversion to infinite sums, i.e. formal power series:
sage: maxima.powerseries(x^2+1/(1-x),x,0) 'sum(_SAGE_VAR_x^i2,i2,0,inf)+_SAGE_VAR_x^2 sage: maxima.powerseries(x^2+1/(1-x),x,0).sage() x^2 + sum(x^i3, i3, 0, +Infinity)
The Taylor series objects have an order parameter on creation, but this does not get output or translated to Sage:
sage: maxima.taylor(1+x+x^2+x^3,x,0,3) 1+_SAGE_VAR_x+_SAGE_VAR_x^2+_SAGE_VAR_x^3 sage: maxima.taylor(1+x+x^2+x^3,x,0,3).sage() x^3 + x^2 + x + 1
so there is no way around it that SR
.series will lose the order term when passed to Maxima. Thus only the coefficients may be simplified, and this must be done in or called from all simplify*
functions.
comment:5 Changed 6 years ago by
The following functions call Maxima, have a meaning /wrt series, and therefore need to be modified:
simplify
, simplify_trig
, simplify_rectform
, simplify_rational
, simplify_log
, expand_log
, expand_trig
.
comment:6 Changed 6 years ago by
- Description modified (diff)
comment:7 Changed 6 years ago by
- Branch set to u/rws/simplify_full_returns_odd_result_from_symbolic_series_input
comment:8 Changed 6 years ago by
- Commit set to 266023507133808606f076ff2f51aa7add64ed0b
- Dependencies set to #17399, #17659
Proof of concept.
New commits:
a4d2084 | 17659: make symbolic series subclass of Expression
|
ed003f0 | 16203: make imports more specific to prevent import loops
|
32ae67c | 17399: do not let maxima handle ex.series coefficients
|
99820cf | 17399: roll back previous commit to allow merge of 17428
|
168b659 | Merge branch 'u/rws/coefficients_of_symbolic_expressions_revamp' of trac.sagemath.org:sage into t/17399/fix_coefficients_for_symbolic_series
|
6cd5286 | 17399: handle series in ex.coefficients()
|
0b9914f | 17399: remove whitespace changes
|
2e74911 | Merge commit '0b9914f8b6cd4cb0f885f0550bfd375d80495a71' of trac.sagemath.org:sage into t/17400/simplify_full_returns_odd_result_from_symbolic_series_input
|
2660235 | 17400: implement series.simplify_full()
|
comment:9 Changed 6 years ago by
- Branch changed from u/rws/simplify_full_returns_odd_result_from_symbolic_series_input to public/17400
comment:10 Changed 6 years ago by
- Commit changed from 266023507133808606f076ff2f51aa7add64ed0b to 26435537dc959224ea2fb700f216f4090af70ac1
- Status changed from new to needs_review
Squashed it all into one commit.
New commits:
2643553 | 17400: merge 17659, add simplify/expand methods for SymbolicSeries
|
comment:11 Changed 6 years ago by
- Branch changed from public/17400 to u/rws/17400
comment:12 Changed 6 years ago by
- Commit changed from 26435537dc959224ea2fb700f216f4090af70ac1 to 73cd5bf461c4f301239a39489889ff28f17df361
- Milestone changed from sage-6.5 to sage-6.6
comment:13 Changed 6 years ago by
- Milestone changed from sage-6.6 to sage-pending
Pending because #17659 is pending.
comment:14 Changed 5 years ago by
- Branch changed from u/rws/17400 to u/rws/17400-1
comment:15 Changed 5 years ago by
- Commit changed from 73cd5bf461c4f301239a39489889ff28f17df361 to 611f93b9a10863247293ae330c8f9432fb6a22b0
comment:16 Changed 5 years ago by
- Milestone changed from sage-pending to sage-7.1
No, you're right. Maybe there are conflicts with #17402.
comment:17 Changed 5 years ago by
- Status changed from needs_review to needs_work
Merge conflict, possibly with #20088
comment:18 in reply to: ↑ 4 Changed 5 years ago by
Replying to rws:
There are no power series objects in Maxima, [...] The Taylor series objects have an order parameter on creation, but this does not get output or translated to Sage
So there are power series-type object in maxima. We could just access those then and use them to translate back-and-forth. It's a bit of a question how much functionality maxima has for it and whether maxima itself works with them faithfully.
The internal representation seems to be a bit complicated:
sage: P=maxima_calculus.taylor(exp(x),x,0,5) sage: P 1+_SAGE_VAR_x+_SAGE_VAR_x^2/2+_SAGE_VAR_x^3/6+_SAGE_VAR_x^4/24+_SAGE_VAR_x^5/120 sage: P.ecl() <ECL: ((MRAT SIMP (((MEXPT SIMP) $%E |$_SAGE_VAR_x|) |$_SAGE_VAR_x|) (#:|%e^_SAGE_VAR_x2396| #:|_SAGE_VAR_x2397|) ((|$_SAGE_VAR_x| ((5 . 1)) 0 NIL #:|_SAGE_VAR_x2397| . 2)) TRUNC) PS (#:|_SAGE_VAR_x2397| . 2) ((5 . 1)) ((0 . 1) 1 . 1) ((1 . 1) 1 . 1) ((2 . 1) 1 . 2) ((3 . 1) 1 . 6) ((4 . 1) 1 . 24) ((5 . 1) 1 . 120))>
but fundamentally everything is there to create/peel apart these objects.
(note that it would be a bit harder to work with these objects via the expect-interface to maxima)
A basic explanation of the MRAT format is here: http://def.fe.up.pt/pipermail/maxima-discuss/2005/010416.html
EDIT: never mind, this isn't suitable for power series. This whole "TRUNC" property is very fickle (and it doesn't carry proper order information). It disappears with very trivial arithmetic already.
comment:19 Changed 5 years ago by
- Commit changed from 611f93b9a10863247293ae330c8f9432fb6a22b0 to e3907ec38750e1be59d10490dc1d511e5307b768
Branch pushed to git repo; I updated commit sha1. New commits:
e3907ec | Merge branch 'develop' into t/17400/17400-1
|
comment:20 Changed 5 years ago by
- Milestone changed from sage-7.1 to sage-7.4
- Status changed from needs_work to needs_review
comment:21 Changed 5 years ago by
- Commit changed from e3907ec38750e1be59d10490dc1d511e5307b768 to 22c947a8ee6d435db6d103246e88674d50e12286
comment:22 Changed 3 years ago by
- Status changed from needs_review to needs_work
Two doctests failing, see patchbot.
Probably with symbolic series, only coefficients should be simplified in the
simplify*
functions.