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')
---------------------------------------------------------------------------
<class 'sage.libs.pari.gen.PariError'> Traceback (most recent call last)
/home/grout/sage/<ipython console> in <module>()
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in NumberField(polynomial, name, check, names, cache)
243
244 if isinstance(polynomial, (list, tuple)):
--> 245 return NumberFieldTower(polynomial, name)
246
247 name = sage.structure.parent_gens.normalize_names(1, name)
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in NumberFieldTower(v, names, check)
411 # return z
412 #else:
--> 413 return w.extension(f, name, check=check)
414
415
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in extension(self, poly, name, names, check)
1813 if name is None:
1814 raise TypeError, "the variable name must be specified."
-> 1815 return NumberField_relative(self, poly, str(name),
check=check)
1816
1817 def factor_integer(self, n):
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in __init__(self, base, polynomial, name, latex_name, names, check)
3110
3111 if check:
-> 3112 if not polynomial_y.is_irreducible():
3113 raise ValueError, "defining polynomial (%s)
must be irreducible"%polynomial
3114
/home/grout/sage/polynomial_element.pyx in
sage.rings.polynomial.polynomial_element.Polynomial.is_irreducible()
/home/grout/sage/polynomial_element.pyx in
sage.rings.polynomial.polynomial_element.Polynomial.factor()
/home/grout/sage/gen.pyx in sage.libs.pari.gen._pari_trap()
<class 'sage.libs.pari.gen.PariError'>: (8)
sage: c=NumberField([x^2-3, x-1],'a')
---------------------------------------------------------------------------
<class 'sage.libs.pari.gen.PariError'> Traceback (most recent call last)
/home/grout/sage/<ipython console> in <module>()
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in NumberField(polynomial, name, check, names, cache)
243
244 if isinstance(polynomial, (list, tuple)):
--> 245 return NumberFieldTower(polynomial, name)
246
247 name = sage.structure.parent_gens.normalize_names(1, name)
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in NumberFieldTower(v, names, check)
411 # return z
412 #else:
--> 413 return w.extension(f, name, check=check)
414
415
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in extension(self, poly, name, names, check)
1813 if name is None:
1814 raise TypeError, "the variable name must be specified."
-> 1815 return NumberField_relative(self, poly, str(name),
check=check)
1816
1817 def factor_integer(self, n):
/home/grout/sage/local/lib/python2.5/site-packages/sage/rings/number_field/number_field.py
in __init__(self, base, polynomial, name, latex_name, names, check)
3110
3111 if check:
-> 3112 if not polynomial_y.is_irreducible():
3113 raise ValueError, "defining polynomial (%s)
must be irreducible"%polynomial
3114
/home/grout/sage/polynomial_element.pyx in
sage.rings.polynomial.polynomial_element.Polynomial.is_irreducible()
/home/grout/sage/polynomial_element.pyx in
sage.rings.polynomial.polynomial_element.Polynomial.factor()
/home/grout/sage/gen.pyx in sage.libs.pari.gen._pari_trap()
<class 'sage.libs.pari.gen.PariError'>: (8)
-Jason
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,)
On 16/02/2008, Jason Grout <jason...@creativetrax.com> 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.
John
--
John Cremona
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
Thanks!
Jason
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
--
John Cremona
OK, so the first thing I tried (sorry) caused a crash. I'll file a
ticket for this: #2194
John
--
John Cremona
John
On 17/02/2008, Carl Witty <cwi...@newtonlabs.com> wrote:
>
--
John Cremona
I've created tickets #2217, #2219, and #2220 from the things you
mentioned in this message. I think I covered everything you mentioned
and I think that I didn't duplicate things. Feel free to change the
tickets if I didn't do something right.
Thanks for all your help!
Jason
John
--
John Cremona
Thank you very much for the clarification on that ticket!
Jason