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

change_default_prec as a replacement for the deprecated set_default_prec #32333

Open
ThibautVerron opened this issue Aug 4, 2021 · 10 comments
Open

Comments

@ThibautVerron
Copy link

In http://trac.sagemath.org/18416, the method set_default_prec of power series rings was marked deprecated, and the warning states that the default precision should be set at construction. This was done before in #16201 for Laurent series.

The point of those changes was to ensure that power series and Laurent series rings are immutable.

I suggest to replace set_default_prec with a method change_default_prec, which would return a copy of self with the wanted precision. It would be similar to how change_ring works, for example.

For an application, see the following example:

sage: Pow.<x> = PowerSeriesRing(QQ, default_prec=5)
sage: Laur = Pow.fraction_field()
sage: f = Pow(1).add_bigoh(100); f
1 + O(x^100)
sage: f.parent()(1/(1+x))*f # forgetting about the ring Laur
1 - x + x^2 - x^3 + x^4 + O(x^5)

To get the correct precision, one would need something like

sage: R = f.parent() 
sage: S = PowerSeriesRing(R.base_ring(),R.gen(),default_prec=100)
sage: S = S.fraction_field() 
sage: S(1/(1+x))*f  
1 - x + x^2 - x^3 + x^4 + ... + x^99 + O(x^100)

The idea would be to replace that with:

sage: S = f.parent().change_default_prec(100)
sage: S(1/(1+x))*f  
1 - x + x^2 - x^3 + x^4 + ... + x^99 + O(x^100)

CC: @slel

Component: algebra

Keywords: series precision

Author: Thibaut Verron

Branch/Commit: u/gh-ThibautVerron/change_default_prec @ 94fd7c5

Reviewer: Travis Scrimshaw

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

@ThibautVerron ThibautVerron added this to the sage-9.4 milestone Aug 4, 2021
@ThibautVerron
Copy link
Author

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 9, 2021
@ThibautVerron
Copy link
Author

New commits:

3871800Implementation of change_default_prec

@ThibautVerron
Copy link
Author

Commit: 3871800

@slel
Copy link
Member

slel commented Aug 19, 2021

Author: Thibaut Verron

@tscrim
Copy link
Collaborator

tscrim commented Aug 23, 2021

comment:5

I agree that we should have this feature, but I don't think we should call __copy__. Instead, we should pass the relevant information onto the constructor so that it properly creates an object normally (in particular, if it uses a cache such as UniqueRepresentation). This means that classes implementing this will likely need to implement it themselves (with a generic implementation perhaps raising a NotImplementedError).

Also, I don't think you should rely on the fraction field of a power series ring being the Laurent polynomial ring. It is not true that ZZ((x)) is the fraction field of ZZ[[x]].

@ThibautVerron
Copy link
Author

comment:6

Thanks for the comments!

I agree that we should have this feature, but I don't think we should call __copy__

Oh, right, that didn't work.

This means that classes implementing this will likely need to implement it themselves

Okay, I made the changes and I added implementations for power series (univariate and multivariate) and Laurent series. I tried to pass all relevant parameters to the constructor, but some are just lost after the initialization (for instance implementation). change_var and change_ring do not seem to care, so I guess if it is a problem, it's a problem for another ticket?

It is not true that ZZ((x)) is the fraction field of ZZ[[x]].

Oops.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2021

Changed commit from 3871800 to 94fd7c5

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 23, 2021

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

c15952fLaurent series rings are not always (fraction) fields
a3863d2Added examples
09ccf55Generic method, implementation for univariate power series
eec8defImplementation for multivariate power series
94fd7c5Minor

@tscrim
Copy link
Collaborator

tscrim commented Aug 25, 2021

comment:8

Replying to @ThibautVerron:

Thanks for the comments!

Thank you for the changes.

Okay, I made the changes and I added implementations for power series (univariate and multivariate) and Laurent series. I tried to pass all relevant parameters to the constructor, but some are just lost after the initialization (for instance implementation). change_var and change_ring do not seem to care, so I guess if it is a problem, it's a problem for another ticket?

Yes, I agree that it should be left for another ticket. Likely some additional information is needed to be stored and passed along.

@tscrim
Copy link
Collaborator

tscrim commented Aug 25, 2021

Reviewer: Travis Scrimshaw

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 Apr 2, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
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