# Sage produces non-invertible transformation matrix to SR Jordan form

Consider the following matrix:

```
M = 1/4 * matrix([(0, 0, -(I + 1)*sqrt(2), -(I + 1)*sqrt(2), (I + 1)*sqrt(2), (I + 1)*sqrt(2)),
(0, 0, -(I - 1)*sqrt(2), (I - 1)*sqrt(2), (I - 1)*sqrt(2), -(I - 1)*sqrt(2)),
((I - 1)*sqrt(2), (I - 1)*sqrt(2), I - 1, I - 1, I - 1, I - 1),
(-(I + 1)*sqrt(2), (I + 1)*sqrt(2), -I - 1, I + 1, -I - 1, I + 1),
((I - 1)*sqrt(2), (I - 1)*sqrt(2), -I + 1, -I + 1, -I + 1, -I + 1),
(-(I + 1)*sqrt(2), (I + 1)*sqrt(2), I + 1, -I - 1, I + 1, -I - 1)])
```

The matrix `M`

is diagonalizable. Indeed, let `z = exp(i*pi/3)`

; then `M`

is similar to `J = diagonal_matrix([ -1, -1, z, z, z.conjugate(), z.conjugate() ])`

. For example, one can use `matrix(QQbar, M).is_similar(matrix(QQbar, J))`

to obtain a similarity transformation. We must embed M (implicitly defined over SR) into QQbar to have exactness to perform the similarity computation. Indeed, both `M.is_similar(J)`

and `M.diagonalization()`

raise respectively `TypeError`

and `ValueError`

as expected. Since `M`

is diagonalizable, the diagonalization agrees (up to permutation) with the Jordan form `matrix(QQbar, M).jordan_form()`

as expected.

In SageMath version 10.4.beta3 as well as 9.5 I can also run `M.jordan_form()`

with no errors thrown; the answer agrees with `matrix(QQbar, M).jordan_form()`

. However, `matrix(QQbar, M).jordan_form(transformation=True)`

and `M.jordan_form(transformation=True)`

do not agree; the latter produces a transformation matrix that is not invertible!

The documentation for Matrix_symbolic_dense.jordan_form suggests that matrices over SR support Jordan form with the transformation flag set to true--why in this case does Sage appear to produce a non-invertible transformation matrix for a correctly computed Jordan form? Or should I in general be converting away from SR to perform similarity transformations in Sage?

Looks like a bug. Try to find a smaller instance if you can.

This particular example comes from the representation of the double cover of the alternating group A5 in SU(2). It is a tensor product of

`matrix([(0, -sqrt(2), sqrt(2)), (I*sqrt(2), I, I), (I*sqrt(2), -I, -I)])`

and`matrix([(I + 1, I + 1), (I - 1, -I + 1)])`

, though`jordan_form`

(over SR) computes transformation matrices correctly for both tensor factors.Upon further digging the bug appears to be in Maxima, not Sage. The erroneous transformation matrix comes from

`M._maxima_lib_().diag_mode_matrix(M._maxima_().jordan())`

.Try to reproduce it directly in maxima, and then file a bug in maxima bug-tracker.