1 | initial version |

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)
print(K)
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`

.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.