From eaa42aa504a902f717f573638880f7c9464952e5 Mon Sep 17 00:00:00 2001 From: Lazybanana Date: Sun, 16 Mar 2025 19:10:13 +0530 Subject: [PATCH] Add reduce_to_unit method to GaussValuation, fixes #39702 --- src/sage/rings/valuation/gauss_valuation.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py index 4fc1c555a79..f937774f716 100644 --- a/src/sage/rings/valuation/gauss_valuation.py +++ b/src/sage/rings/valuation/gauss_valuation.py @@ -47,7 +47,7 @@ from sage.misc.cachefunc import cached_method from sage.structure.factory import UniqueFactory - +from sage.rings.infinity import infinity class GaussValuationFactory(UniqueFactory): r""" @@ -809,3 +809,21 @@ def upper_bound(self, f): return infinity else: return self._base_valuation.upper_bound(coefficients[-1]) + + def reduce_to_unit(self, f): + r""" + Reduce the unit part of an element. + + Given an element `f`, this method returns the reduction of `f` after shifting it to have valuation 0. + + Parameters: + f -- an element of the domain + + Returns: + The reduction of `f * u`, where `u` is an element with valuation `-v(f)`. + """ + s = self(f) + if s == infinity: + return self.reduce(f) # f is zero + u = self.equivalence_unit(-s) + return self.reduce(f * u)