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

Implement conversion from laurent series to rational function field #39485

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

user202729
Copy link
Contributor

@user202729 user202729 commented Feb 10, 2025

As in the title. I think this behavior makes sense because QQ(RR(…)) currently uses .simplest_rational() instead of like exact value (like x / 2^53 for some integer x), so it makes sense for similar conversions to compute a good approximation too.

I cannot prove that this round-trips, however.

Note that currently conversion from power series QQ[[x]] to polynomial ring QQ[x] truncates, because of implementation detail this leads to conversion from QQ[[x]] to Frac(QQ[x]) also truncates. I think this is undesirable behavior because identical-looking elements in QQ[[x]] versus Frac(QQ[[x]]) = LaurentSeriesRing(QQ, "x") has different conversion behavior.

Elements which are already Laurent polynomial are preserved.

Side note: .one() is faster because it's cached

sage: R.<x> = QQ[]
sage: S = Frac(R)
sage: %timeit S.one()  # fast because it's cached
90.6 ns ± 1.27 ns per loop (mean ± std. dev. of 7 runs, 10,000,000 loops each)
sage: ring_one = S.ring().one()
sage: %timeit S._element_class(S, ring_one, ring_one, coerce=False, reduce=False)
3.42 μs ± 75 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

Maybe this doesn't need to be explicitly written in the documentation (users trying to do the conversion will just see the result)

There exists also :meth:`.PowerSeries_poly.pade` which should probably be mentioned in the documentation.

Reverse direction (that one is a morphism): #39365

Possible caveat:

sage: S(Frac(V)(1/(x+1))/(x^10))
1/(x^11 + x^10)
sage: S(Frac(V)(1/(x+1))/(x^30))
(-x^19 + x^18 - x^17 + x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1)/x^30

It could be argued the latter would be simpler as 1/(x^31+x^30), but then that way gives higher denominator degree.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@user202729 user202729 marked this pull request as draft February 10, 2025 05:04
Copy link

github-actions bot commented Feb 10, 2025

Documentation preview for this PR (built with commit bcd61e5; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729 user202729 marked this pull request as ready for review February 10, 2025 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant