Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I came up with such a function which for given algebraic numbers returns the common number field and the algebraic numbers as elements in this field:

def to_common_field(l) :
    r"""
    Given a list of algebraic numbers in QQbar, returns a list of these algebraic numbers
    as elements in a minimal number field
    """
    with SR.temp_var() as y, SR.temp_var() as v, SR.temp_var(n=len(l)) as u :
        QQ_number_field = NumberField(y-1, v) # QQ as number field

        L_tower = NumberField(y-1, v) # start with QQ 

        l_new = []
        # create tower of extensions
        for i, a in enumerate(l) :
            # get extension field of current element
            Ka, aK, _ = QQbar(a).as_number_field_element()

            # enlarge field
            if Ka == QQ :
                Ka = QQ_number_field # can only enlarge with number field not with QQ
                aK = Ka(aK)
            L_tower, psi, phi, _ = L_tower.composite_fields(Ka, u[i], both_maps=True)[0]
            # phi : Ka -> L_tower_new, psi : L_tower_old -> L_tower_new

            # move all previously considered elements to new field
            for i in range(len(l_new)) :
                l_new[i] = psi(l_new[i])
            l_new.append(phi(aK))

        return L_tower, l_new

Here is an example:

sage: l = [sqrt(3), sqrt(2), 2]
sage: to_common_field(l)
(Number Field in symbol375 with defining polynomial y^4 - 10*y^2 + 1,
[1/2*symbol375^3 - 11/2*symbol375, 1/2*symbol375^3 - 9/2*symbol375, 2])

What would be nice, but I was not able to do this yet, is to additionally return the embedding from the common number field to QQbar such that all elements are mapped to the appropriate algebraic number.