Ignore:
Timestamp:
12/02/07 12:17:20 (5 years ago)
Branch:
default
Parents:
7505:2a3f3513a11b (diff), 7507:de39c2037850 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge

Location:
sage/rings
Files:
4 edited

Unmodified
Removed
• ## sage/rings/number_field/number_field.py

 r7478 return False def pari_polynomial(self): def pari_polynomial(self, name='x'): """ PARI polynomial corresponding to polynomial that defines this field.   This is always a polynomial in the variable "x". this field. By default, this is a polynomial in the variable "x". EXAMPLES: sage: k. = NumberField(y^2 - 3/2*y + 5/3) sage: k.pari_polynomial() x^2 - 3/2*x + 5/3 x^2 - 3/2*x + 5/3 sage: k.pari_polynomial('a') a^2 - 3/2*a + 5/3 """ try: return self.__pari_polynomial if (self.__pari_polynomial_var == name): return self.__pari_polynomial else: self.__pari_polynomial = self.__pari_polynomial(name) self.__pari_polynomial_var = name return self.__pari_polynomial except AttributeError: poly = self.polynomial() with localvars(poly.parent(), 'x'): with localvars(poly.parent(), name): self.__pari_polynomial = poly._pari_() self.__pari_polynomial_var = name return self.__pari_polynomial
• ## sage/rings/number_field/number_field.py

 r7506 """ return infinity.infinity def polynomial_ntl(self): """ return self.__regulator def residue_field(self, prime, name = None, check = False): def residue_field(self, prime, names = None, check = False): """ Return the residue field of this number field at a given prime, ie \$O_K / p O_K\$. INPUT: prime -- a prime ideal of the maximal order in this number field. name -- the name of the variable in the residue field names -- the name of the variable in the residue field check -- whether or not to check the primality of prime. OUTPUT: sage: P = K.ideal(61).factor()[0][0] sage: K.residue_field(P) Residue field of Fractional ideal (-2*a^2 + 1) Residue field in abar of Fractional ideal (-2*a^2 + 1) """ import sage.rings.residue_field return sage.rings.residue_field.ResidueField(prime) return sage.rings.residue_field.ResidueField(prime, names = names) def signature(self): return K def absolute_polynomial_ntl(self): """ Return defining polynomial of this number field as a pair, an ntl polynomial and a denominator. This is used mainly to implement some internal arithmetic. EXAMPLES: sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial_ntl() ([-27 34 51], 51) """ try: return (self.__abs_polynomial_ntl, self.__abs_denominator_ntl) except AttributeError: self.__abs_denominator_ntl = ntl.ZZ() den = self.absolute_polynomial().denominator() self.__abs_denominator_ntl.set_from_sage_int(ZZ(den)) self.__abs_polynomial_ntl = ntl.ZZX((self.absolute_polynomial()*den).list()) return (self.__abs_polynomial_ntl, self.__abs_denominator_ntl) def absolute_polynomial(self): r""" To:   Complex Field with 58 bits of precision Defn: a |--> -0.62996052494743676 - 1.0911236359717214*I b |--> -0.00000000000000019428902930940239 + 1.0000000000000000*I, ... b |--> -1.9428902930940239e-16 + 1.0000000000000000*I, Relative number field morphism: ... From: Number Field in a with defining polynomial x^3 - 2 over its base field To:   Complex Field with 58 bits of precision Defn: a |--> 1.2599210498948731 b |--> -0.99999999999999999*I] sage: f[0](a)^3 2.0000000000000002 - 0.00000000000000086389229103644993*I 2.0000000000000002 - 8.6389229103644993e-16*I sage: f[0](b)^2 -1.0000000000000001 - 0.00000000000000038857805861880480*I -1.0000000000000001 - 3.8857805861880480e-16*I sage: f[0](a+b) -0.62996052494743693 - 0.091123635971721295*I sage: C.complex_embeddings() [Ring morphism: From: Cyclotomic Field of order 4 and degree 2 To:   Complex Field with 53 bits of precision Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I, Ring morphism: From: Cyclotomic Field of order 4 and degree 2 To:   Complex Field with 53 bits of precision Defn: zeta4 |--> -0.000000000000000183697019872103 - 1.00000000000000*I] From: Cyclotomic Field of order 4 and degree 2 To:   Complex Field with 53 bits of precision Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I, Ring morphism: From: Cyclotomic Field of order 4 and degree 2 To:   Complex Field with 53 bits of precision Defn: zeta4 |--> -1.83697019872103e-16 - 1.00000000000000*I] """ CC = sage.rings.complex_field.ComplexField(prec) parts = -b/(2*a), (Dpoly/D).sqrt()/(2*a) self._NumberField_generic__gen = self._element_class(self, parts) def coerce_map_from_impl(self, S): """ EXAMPLES: sage: K. = QuadraticField(-3) sage: f = K.coerce_map_from(QQ); f Natural morphism: From: Rational Field To:   Number Field in a with defining polynomial x^2 + 3 sage: f(3/5) 3/5 sage: parent(f(3/5)) is K True """ if S is QQ: return number_field_element_quadratic.Q_to_quadratic_field_element(self) else: return NumberField_absolute.coerce_map_from_impl(self, S) def discriminant(self, v=None):
• ## sage/rings/polynomial/polynomial_element.pyx

 r7504 sage: expand(F) T^6 + 10/7*T^5 + (-867/49)*T^4 + (-76/245)*T^3 + 3148/35*T^2 + (-25944/245)*T + 48771/1225 sage: f = x^2 - 1/3 ; K. = NumberField(f) ; A. = K[] ; g = A(x^2-1) sage: g.factor() (T - 1) * (T + 1) sage: h = A(3*x^2-1) ; h.factor() (3) * (T - a) * (T + a) sage: h = A(x^2-1/3) ; h.factor() (T - a) * (T + a) Over the real double field: G = None from sage.rings.number_field.all import is_NumberField, is_RelativeNumberField from sage.rings.number_field.all import is_NumberField, \ is_RelativeNumberField, NumberField from sage.rings.finite_field import is_FiniteField return Factorization(v, from_M(F.unit())) elif is_NumberField(R) or is_FiniteField(R): elif is_FiniteField(R): v = [x._pari_("a") for x in self.list()] f = pari(v).Polrev() G = list(f.factor()) elif is_NumberField(R): if (R.defining_polynomial().denominator() == 1) and \ (self.denominator() == 1): v = [ x._pari_("a") for x in self.list() ] f = pari(v).Polrev() Rpari = R.pari_nf() if (Rpari.variable() != "a"): Rpari = Rpari.copy() Rpari[0] = Rpari[0]("a") Rpari[6] = [ x("a") for x in Rpari[6] ] G = list(Rpari.nffactor(f)) else: Rdenom = R.defining_polynomial().denominator() new_Rpoly = (R.defining_polynomial() * Rdenom).change_variable_name("a") Rpari, Rdiff = new_Rpoly._pari_().nfinit(3) AZ = polynomial_ring.PolynomialRing(QQ,'z') Raux = NumberField(AZ(Rpari[0]),'alpha') S, gSRaux, fRauxS = Raux.change_generator(Raux(Rdiff)) phi_RS = R.Hom(S)([S.gen(0)]) phi_SR = S.Hom(R)([R.gen(0)]) unit = self.leading_coefficient() temp_f = self * 1/unit v = [ gSRaux(phi_RS(x))._pari_("a") for x in temp_f.list() ] f = pari(v).Polrev() pari_factors = Rpari.nffactor(f) factors = [ ( self.parent([ phi_SR(fRauxS(Raux(pari_factors[0][i][j]))) for j in range(len(pari_factors[0][i])) ]) , int(pari_factors[1][i]) ) for i in range(pari_factors.nrows()) ] return Factorization(factors, unit) elif is_RealField(R): sage: R(4).is_irreducible() True TESTS: sage: F. = NumberField(x^2-5) sage: Fx. = PolynomialRing(F) sage: f = Fx([2*t - 5, 5*t - 10, 3*t - 6, -t, -t + 2, 1]) sage: f.is_irreducible() False sage: f = Fx([2*t - 3, 5*t - 10, 3*t - 6, -t, -t + 2, 1]) sage: f.is_irreducible() True """ if self.is_zero():