Ask Your Question

Revision history [back]

Since $\bar{\mathbb{Q}}$ is a little big, try instead working in a number field $K$ that's big enough but as small as possible:

M = [matrix(QQ,l) for l in L]
K,_,_ = number_field_elements_from_algebraics(sum([m.eigenvalues() for m in M], []), minimal=True)
p = identity_matrix(K,8)
q = ~p
for m in M:
    a = q*m*p
    da, pa = a.change_ring(K).jordan_form(transformation=True)
    p = p*pa
    q = ~p

Here $K$ is an abstract number field of degree $48$ with several (i.e. $48$) different embeddings into $\bar{\mathbb{Q}}$.

sage: set([sigma(p.det()) for sigma in K.embeddings(QQbar)])
{-97929.96732359303?, 97929.96732359303?}

For a given sigma in K.embeddings(QQbar), you can embed p and q by p.apply_map(sigma) and q.apply_map(sigma); those matrices are defined over QQbar and they simultaneously diagonalize all m in M.