Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify_full returns odd result from symbolic series input #17400

Open
rwst opened this issue Nov 26, 2014 · 30 comments
Open

simplify_full returns odd result from symbolic series input #17400

rwst opened this issue Nov 26, 2014 · 30 comments

Comments

@rwst
Copy link

rwst commented Nov 26, 2014

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.

Depends on #17399
Depends on #17659

Component: symbolics

Author: Ralf Stephan

Branch/Commit: u/rws/17400-1 @ 22c947a

Issue created by migration from https://trac.sagemath.org/ticket/17400

@rwst rwst added this to the sage-6.5 milestone Nov 26, 2014
@rwst

This comment has been minimized.

@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Dec 4, 2014

comment:3

Probably with symbolic series, only coefficients should be simplified in the simplify* functions.

@rwst
Copy link
Author

rwst commented Jan 13, 2015

comment:4

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.

@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Jan 13, 2015

comment:5

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.

@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented Jan 23, 2015

@rwst
Copy link
Author

rwst commented Jan 23, 2015

Commit: 2660235

@rwst
Copy link
Author

rwst commented Jan 23, 2015

comment:8

Proof of concept.


New commits:

a4d208417659: make symbolic series subclass of Expression
ed003f016203: make imports more specific to prevent import loops
32ae67c17399: do not let maxima handle ex.series coefficients
99820cf17399: roll back previous commit to allow merge of 17428
168b659Merge branch 'u/rws/coefficients_of_symbolic_expressions_revamp' of trac.sagemath.org:sage into t/17399/fix_coefficients_for_symbolic_series
6cd528617399: handle series in ex.coefficients()
0b9914f17399: remove whitespace changes
2e74911Merge commit '0b9914f8b6cd4cb0f885f0550bfd375d80495a71' of trac.sagemath.org:sage into t/17400/simplify_full_returns_odd_result_from_symbolic_series_input
266023517400: implement series.simplify_full()

@rwst
Copy link
Author

rwst commented Jan 23, 2015

Dependencies: #17399, #17659

@rwst
Copy link
Author

rwst commented Jan 25, 2015

@rwst
Copy link
Author

rwst commented Jan 25, 2015

Changed commit from 2660235 to 2643553

@rwst
Copy link
Author

rwst commented Jan 25, 2015

comment:10

Squashed it all into one commit.


New commits:

264355317400: merge 17659, add simplify/expand methods for SymbolicSeries

@rwst
Copy link
Author

rwst commented Jan 25, 2015

Author: Ralf Stephan

@rwst
Copy link
Author

rwst commented Mar 5, 2015

Changed branch from public/17400 to u/rws/17400

@rwst
Copy link
Author

rwst commented Mar 5, 2015

comment:12

Squashed it all into one commit.


New commits:

73cd5bf17400: symbolic series simplification methods

@rwst
Copy link
Author

rwst commented Mar 5, 2015

Changed commit from 2643553 to 73cd5bf

@rwst rwst modified the milestones: sage-6.5, sage-6.6 Mar 5, 2015
@rwst
Copy link
Author

rwst commented Apr 20, 2015

comment:13

Pending because #17659 is pending.

@rwst rwst removed this from the sage-6.6 milestone Apr 20, 2015
@rwst rwst added the pending label Apr 20, 2015
@rwst
Copy link
Author

rwst commented Feb 5, 2016

Changed branch from u/rws/17400 to u/rws/17400-1

@vbraun
Copy link
Member

vbraun commented Feb 23, 2016

comment:15

Still pending?


New commits:

611f93bMerge branch 'u/rws/17400' of trac.sagemath.org:sage into tmp05

@vbraun
Copy link
Member

vbraun commented Feb 23, 2016

Changed commit from 73cd5bf to 611f93b

@rwst
Copy link
Author

rwst commented Feb 24, 2016

comment:16

No, you're right. Maybe there are conflicts with #17402.

@rwst rwst added this to the sage-7.1 milestone Feb 24, 2016
@rwst rwst removed the pending label Feb 24, 2016
@vbraun
Copy link
Member

vbraun commented Mar 5, 2016

comment:17

Merge conflict, possibly with #20088

@nbruin
Copy link
Contributor

nbruin commented Mar 6, 2016

comment:18

Replying to @rwst:

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.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 3, 2016

Changed commit from 611f93b to e3907ec

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 3, 2016

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

e3907ecMerge branch 'develop' into t/17400/17400-1

@rwst rwst modified the milestones: sage-7.1, sage-7.4 Aug 3, 2016
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2016

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

895d900Merge branch 'develop' into t/17400/17400-1
22c947a17400: adapt doctest to changed simplify behaviour

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2016

Changed commit from e3907ec to 22c947a

@rwst
Copy link
Author

rwst commented Nov 28, 2017

comment:22

Two doctests failing, see patchbot.

@mkoeppe mkoeppe removed this from the sage-7.4 milestone Dec 29, 2022
vbraun pushed a commit that referenced this issue Feb 24, 2023
    
Fixes #20846 (but not the related #17400).
    
URL: #35001
Reported by: Marc Mezzarobba
Reviewer(s): Frédéric Chapoton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants