Ticket #12173: sqrt_normalization_fix.diff

File sqrt_normalization_fix.diff, 1.5 KB (added by fredrik.johansson, 10 years ago)

Fix normalization of sqrt for fraction field elements

• sage/rings/fraction_field_FpT.pyx

`diff --git a/sage/rings/fraction_field_FpT.pyx b/sage/rings/fraction_field_FpT.pyx`
 a return self cdef nmod_poly_t numer cdef nmod_poly_t denom cdef long a cdef FpTElement res nmod_poly_init(denom, self.p) nmod_poly_init(numer, self.p) if nmod_poly_sqrt(numer, self._numer) and nmod_poly_sqrt(denom, self._denom): # Make denominator monic a = nmod_poly_leading(denom) if a != 1: a = mod_inverse_int(a, self.p) nmod_poly_scalar_mul_nmod(numer, numer, a) nmod_poly_scalar_mul_nmod(denom, denom, a) # Choose numerator with smaller leading coefficient a = nmod_poly_leading(numer) if a > self.p - a: nmod_poly_neg(numer, numer) res = self._new_c() nmod_poly_swap(numer, res._numer) nmod_poly_swap(denom, res._denom) sage: from sage.rings.fraction_field_FpT import * sage: K = GF(7)['t'].fraction_field(); t = K.gen(0) sage: ((t + 2)^2/(3*t^3 + 1)^4).sqrt() sage: p = (t + 2)^2/(3*t^3 + 1)^4 sage: p.sqrt() (3*t + 6)/(t^6 + 3*t^3 + 4) sage: p.sqrt()^2 == p True """ s = self._sqrt_or_None() if s is None: