@@ -470,6 +470,39 @@ def uniformizer(self):
470470 """
471471 return self ._initial_approximation .uniformizer ()
472472
473+ def _call_ (self , f ):
474+ r"""
475+ Return the valuation of ``f``.
476+
477+ EXAMPLES::
478+
479+ sage: from mac_lane import * # optional: standalone
480+ sage: K = QQ
481+ sage: R.<x> = K[]
482+ sage: vK = pAdicValuation(K, 2)
483+ sage: f = (x^2 + 7) * (x^2 + 9)
484+ sage: V = vK.mac_lane_approximants(f, require_incomparability=True)
485+ sage: V = sorted(V, key=str)
486+
487+ sage: w = LimitValuation(V[0], f)
488+ sage: w((x^2 + 7) * (x + 3))
489+ 3/2
490+
491+ sage: w = LimitValuation(V[1], f)
492+ sage: w((x^2 + 7) * (x + 3))
493+ +Infinity
494+
495+ sage: w = LimitValuation(V[2], f)
496+ sage: w((x^2 + 7) * (x + 3))
497+ +Infinity
498+
499+ """
500+ self ._improve_approximation_for_call (f )
501+ if self ._G .divides (f ):
502+ from sage .rings .all import infinity
503+ return infinity
504+ return self ._approximation (f )
505+
473506 def _improve_approximation (self ):
474507 r"""
475508 Perform one step of the Mac Lane algorithm to improve our approximation.
@@ -539,18 +572,24 @@ def _improve_approximation_for_call(self, f):
539572 of ``f`` in `K[x]` (of minimal degree.) Write `v` for
540573 ``self._approximation` and `\phi` for the last key polynomial of
541574 `v`. With repeated quotient and remainder `g` has a unique
542- expansion as `g=\sum a_i\phi^i`. Suppose that `g` is an
575+ expansion as `g=\sum a_i\phi^i`. Suppose that `g` is an
543576 equivalence-unit with respect to ``self._approximation``, i.e.,
544577 `v(a_0) < v(a_i\phi^i)` for all `i\ne 0`. If we denote the limit
545578 valuation as `w`, then `v(a_i\phi^i)=w(a_i\phi^i)` since the
546579 valuation of key polynomials does not change during augmentations
547580 (Theorem 6.4 in [ML1936'].) By the strict triangle inequality,
548581 `w(g)=v(g)`.
549- Note that any `g` which is not in `(G) ` is an equivalence-unit
582+ Note that any `g` which is coprime to `G ` is an equivalence-unit
550583 after finitely many steps of the Mac Lane algorithm. Indeed,
551584 otherwise the valuation of `g` would be infinite (follows from
552585 Theorem 5.1 in [ML1936']) since the valuation of the key
553586 polynomials increases.
587+ When `f` is not coprime to `G`, consider `s=gcd(f,G)` and write
588+ `G=st`. Since `G` is squarefree, either `s` or `t` have finite
589+ valuation. With the above algorithm, this can be decided in
590+ finitely many steps. From this we can deduce the valuation of `s`
591+ (and in fact replace `G` with the factor with infinite valuation
592+ for all future computations.)
554593
555594 """
556595 from sage .rings .all import infinity
@@ -564,12 +603,25 @@ def _improve_approximation_for_call(self, f):
564603 # zero coefficients.)
565604 return
566605
567- if self ._approximation .is_equivalence_unit (f ):
568- # see ALGORITHM above
569- return
570-
571- self ._improve_approximation ()
572- return self ._improve_approximation_for_call (f )
606+ while not self ._approximation .is_equivalence_unit (f ):
607+ # TODO: I doubt that this really works over inexact fields
608+ s = self ._G .gcd (f )
609+ if s .is_constant ():
610+ self ._improve_approximation ()
611+ else :
612+ t = self ._G // s
613+
614+ while True :
615+ if self ._approximation .is_equivalence_unit (s ):
616+ # t has infinite valuation
617+ self ._G = t
618+ return self ._improve_approximation_for_call (f // s )
619+ if self ._approximation .is_equivalence_unit (t ):
620+ # s has infinite valuation
621+ self ._G = s
622+ return
623+
624+ self ._improve_approximation ()
573625
574626 def _improve_approximation_for_reduce (self , f ):
575627 r"""
0 commit comments