diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 0416466b964..91edf7ec410 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -2016,29 +2016,24 @@ def reduce(self, I): # Useful for some geometry code. ############################################################### -def degree_lowest_rational_function(r,x): +def degree_lowest_rational_function(r, x): r""" - INPUT: - + Return the difference of valuations of r with respect to variable x. - - ``r`` - a multivariate rational function + INPUT: - - ``x`` - a multivariate polynomial ring generator x + - ``r`` -- a multivariate rational function + - ``x`` -- a multivariate polynomial ring generator x OUTPUT: + - ``integer`` -- the difference val_x(p) - val_x(q) where r = p/q - - ``integer`` - the degree of r in x and its "leading" - (in the x-adic sense) coefficient. + .. NOTE:: - - .. note:: - - This function is dependent on the ordering of a python dict. - Thus, it isn't really mathematically well-defined. I think that - it should made a method of the FractionFieldElement class and - rewritten. + This function should be made a method of the + FractionFieldElement class. EXAMPLES:: @@ -2057,35 +2052,15 @@ def degree_lowest_rational_function(r,x): sage: r = f/g; r (-b*c^2 + 2)/(a*b^3*c^6 - 2*a*c) sage: degree_lowest_rational_function(r,a) - (-1, 3) + -1 sage: degree_lowest_rational_function(r,b) - (0, 4) + 0 sage: degree_lowest_rational_function(r,c) - (-1, 4) + -1 """ from sage.rings.fraction_field import FractionField - R = r.parent() - F = FractionField(R) + F = FractionField(r.parent()) r = F(r) - if r == 0: - return (0, F(0)) - L = next(iter(x.dict())) - for ix in range(len(L)): - if L[ix] != 0: - break - f = r.numerator() - g = r.denominator() - M = f.dict() - keys = list(M) - numtermsf = len(M) - degreesf = [keys[j][ix] for j in range(numtermsf)] - lowdegf = min(degreesf) - cf = M[keys[degreesf.index(lowdegf)]] ## constant coeff of lowest degree term - M = g.dict() - keys = list(M) - numtermsg = len(M) - degreesg = [keys[j][ix] for j in range(numtermsg)] - lowdegg = min(degreesg) - cg = M[keys[degreesg.index(lowdegg)]] ## constant coeff of lowest degree term - return (lowdegf-lowdegg,cf/cg) - + f = r.numerator().polynomial(x) + g = r.denominator().polynomial(x) + return f.valuation() - g.valuation() diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index 56c0d91b4aa..fed6feca3ba 100644 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -1011,16 +1011,16 @@ def divisor_of_function(self, r): yt = lcs[1] xt = lcs[0] ldg = degree_lowest_rational_function(r(xt, yt), t) - if ldg[0] != 0: - divf.append([ldg[0], pt0]) + if ldg != 0: + divf.append([ldg, pt0]) return divf def local_coordinates(self, pt, n): r""" Return local coordinates to precision n at the given point. - Behaviour is flaky - some choices of `n` are worst that - others. + Behaviour is flaky - some choices of `n` are worst that + others. INPUT: diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 91c75b6a005..6a0c5366de3 100644 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -618,8 +618,8 @@ def divisor_of_function(self, r): # What is the '5' in this line and the 'r()' in the next??? lcs = self.local_coordinates(P,5) ldg = degree_lowest_rational_function(r(lcs[0],lcs[1]),z) - if ldg[0] != 0: - divf.append([ldg[0],P]) + if ldg != 0: + divf.append([ldg, P]) return divf