I agree that this would be a useful funtion to have. I would call it splitting_field() with a description similar to that of root_field() -- whose docstring does not say that self should be irreducible, though in fact it must.
In the meantim you should be able to work with what is available as follows: sage: QQx.<x>=QQ[] sage: f=(x^2-2)*(x^2-3) sage: F=NumberField([p for p,n in f.factor()],'a') sage: F2=F.absolute_field('b') sage: F2.structure() (Isomorphism from Number Field in b with defining polynomial x^4 - 10*x^2 + 1 to Number Field in a0 with defining polynomial x^2 - 3 over its base field, Isomorphism from Number Field in a0 with defining polynomial x^2 - 3 over its base field to Number Field in b with defining polynomial x^4 - 10*x^2 + 1) Here F is first defined as a relative extension, with generators a0,a1 satisfying the equations: sage: a0,a1=F.gens() sage: a0^2, a1^2 (3, 2) then F2 is the associated absolute field, with F2.structure() giving maps from each of these into the other. sage: F2toF, FtoF2=F2.structure() sage: FtoF2(a0) -1/2*b^3 + 11/2*b sage: FtoF2(a0).minpoly() x^2 - 3 sage: FtoF2(a1) -1/2*b^3 + 9/2*b sage: FtoF2(a1).minpoly() x^2 - 2 John On 16/02/2008, Jason Grout <[EMAIL PROTECTED]> wrote: > > John Cremona wrote: > > Are you sure you mean to give NumberField() two polynomials, one of > > which (x) defines the trivial extension? You are only giving one name > > so I rpresume what you mean (to define a quadratic field) is > > > > > > sage: NumberField([x^2-3],'a') > > Number Field in a with defining polynomial x^2 - 3 > > sage: F=NumberField([x^2-3],'a') > > sage: F.gens() > > (a,) > > Yes, I'd like to get the quadratic extension. I know I can do this > without the x; my question was about why it didn't work the way I was > trying (and why it was complaining that x was not irreducible), but I > didn't know if I was naively doing something wrong either. > > What I'm trying to do is get a number field that has all the roots of a > (not necessarily irreducible) polynomial. I was trying to automatically > construct a field that contained the eigenvalues of a matrix. But when > calling NumberField on the list of irreducible factors of the > characteristic polynomial, things were blowing or not making sense to me > if there was a linear factor somewhere. > > Is there an easier way to get an extension that contains all the roots > of a given polynomial (which may not be irreducible)? I tried the > following, but it didn't work; should it? > > sage: a=QQ['x']; x=a.gen() > sage: b=(x^2-2)*(x^2-3) > sage: b.root_field('y') > --------------------------------------------------------------------------- > <type 'exceptions.ValueError'> Traceback (most recent call last) > > /home/grout/<ipython console> in <module>() > > /home/grout/polynomial_element.pyx in > sage.rings.polynomial.polynomial_element.Polynomial.root_field() > > /home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py > in NumberField(polynomial, name, check, names, cache) > 274 K = NumberField_quadratic(polynomial, name, check) > 275 else: > --> 276 K = NumberField_absolute(polynomial, name, None, check) > 277 > 278 if cache: > > /home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py > in __init__(self, polynomial, name, latex_name, check) > 2466 > 2467 def __init__(self, polynomial, name, latex_name=None, > check=True): > -> 2468 NumberField_generic.__init__(self, polynomial, name, > latex_name, check) > 2469 self._element_class = > number_field_element.NumberFieldElement_absolute > 2470 > > /home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py > in __init__(self, polynomial, name, latex_name, check) > 621 if check: > 622 if not polynomial.is_irreducible(): > --> 623 raise ValueError, "defining polynomial (%s) must > be irreducible"%polynomial > 624 if not polynomial.parent().base_ring() == QQ: > 625 raise TypeError, "polynomial must be defined > over rational field" > > <type 'exceptions.ValueError'>: defining polynomial (x^4 - 5*x^2 + 6) > must be irreducible > > > > > > > On 16/02/2008, Jason Grout <[EMAIL PROTECTED]> wrote: > >> Is the following output for b.gens() correct? > >> > >> sage: NumberField([x,x^2-3],'a') > >> Number Field in a0 with defining polynomial x over its base field > >> sage: b=NumberField([x,x^2-3],'a') > >> sage: b.gens() > >> (0, 0) > >> > >> To contrast: > >> > >> sage: c=NumberField([x^2-3, x^2-2],'a') > >> sage: c.gens() > >> (a0, a1) > >> > >> > >> Also, this blows up: > >> > >> sage: c=NumberField([x^2-3, x],'a') > > > > The problem here is that x is triggering a an error in the > > irreducibility test, which is a little bizarre since of course x is > > irreducible. > > > > So the real issue is: why is x allowed to determine an absolute number > > field (base Q) but not a relative one? My guess is that this is a > > side-effect of the differing code being used to test irreducibility in > > the two cases, > > > > Personally, I think that trivial extensions should be allowed and > > treated just as non-trivial ones. I have recently had to define > > extensions of the ring ZZ, and find this awkward: > > > > sage: R=ZZ.extension(x^2+5,'a') > > sage: R.gens() > > [1, a] > > sage: S=ZZ.extension(x+5,'b') > > sage: S.gens() > > [1] > > > > In the latter case I need S to remember the polynomial used to > > generaite it and would expect its gens() to include (in this case) -5. > > > > On the same topic, R and S above have no defining_polynomial() method. > > I'll try to fix that if it looks easy. > > Thanks! > > Jason > > > > > -- John Cremona --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---