Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following works for me:

S.<X> = QQ[]
K.<j> = QuadraticField(-1)
R.<x> = K[]

polynomials = [X^2 + 1, X^2 + 2, X^2 + X + 1]

count = 0
for f in polynomials:
    count += 1
    print "[%s]" % count
    if R(f).is_irreducible():
        print "\tIrreductible case for %s over K..." % f
        L = NumberField( [X^2+1, f], names='a');
        print "\tThe number field L is:"
        print "\t%s" % L
        print "\tThe base field of L is:"
        print "\t%s" % L.base_field()
        print "\tL has absolute degree %s" % L.absolute_degree()
        print "\tL has relative degree %s" % L.relative_degree()
    else:
        print "\tReducible case for %s over K" % f

Results:

[1]
        Reducible case for X^2 + 1 over K
[2]
        Irreductible case for X^2 + 2 over K...
        The number field L is:
        Number Field in a0 with defining polynomial X^2 + 1 over its base field
        The base field of L is:
        Number Field in a1 with defining polynomial X^2 + 2
        L has absolute degree 4
        L has relative degree 2
[3]
        Irreductible case for X^2 + X + 1 over K...
        The number field L is:
        Number Field in a0 with defining polynomial X^2 + 1 over its base field
        The base field of L is:
        Number Field in a1 with defining polynomial X^2 + X + 1
        L has absolute degree 4
        L has relative degree 2

Note that f.is_irreducible is only a method, as a boolean it always avaluates to True, one has to call it, f.is_irreducible() to have the needed True or False. Also, always make the difference between the transcendentals like x over different fields.