ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 26 Apr 2024 08:00:17 +0200Sage produces non-invertible transformation matrix to SR Jordan formhttps://ask.sagemath.org/question/77072/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?
Thu, 25 Apr 2024 05:22:20 +0200https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/Comment by FrédéricC for <p>Consider the following matrix:</p>
<p><code>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)])</code></p>
<p>The matrix <code>M</code> is diagonalizable. Indeed, let <code>z = exp(i*pi/3)</code>; then <code>M</code> is similar to <code>J = diagonal_matrix([ -1, -1, z, z, z.conjugate(), z.conjugate() ])</code>. For example, one can use <code>matrix(QQbar, M).is_similar(matrix(QQbar, J))</code> 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 <code>M.is_similar(J)</code> and <code>M.diagonalization()</code> raise respectively <code>TypeError</code> and <code>ValueError</code> as expected. Since <code>M</code> is diagonalizable, the diagonalization agrees (up to permutation) with the Jordan form <code>matrix(QQbar, M).jordan_form()</code> as expected.</p>
<p>In SageMath version 10.4.beta3 as well as 9.5 I can also run <code>M.jordan_form()</code> with no errors thrown; the answer agrees with <code>matrix(QQbar, M).jordan_form()</code>. However, <code>matrix(QQbar, M).jordan_form(transformation=True)</code> and <code>M.jordan_form(transformation=True)</code> do not agree; the latter produces a transformation matrix that is not invertible!</p>
<p>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?</p>
https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77095#post-id-77095Try to reproduce it directly in maxima, and then file a bug in maxima bug-tracker.Fri, 26 Apr 2024 08:00:17 +0200https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77095#post-id-77095Comment by swhitehead for <p>Consider the following matrix:</p>
<p><code>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)])</code></p>
<p>The matrix <code>M</code> is diagonalizable. Indeed, let <code>z = exp(i*pi/3)</code>; then <code>M</code> is similar to <code>J = diagonal_matrix([ -1, -1, z, z, z.conjugate(), z.conjugate() ])</code>. For example, one can use <code>matrix(QQbar, M).is_similar(matrix(QQbar, J))</code> 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 <code>M.is_similar(J)</code> and <code>M.diagonalization()</code> raise respectively <code>TypeError</code> and <code>ValueError</code> as expected. Since <code>M</code> is diagonalizable, the diagonalization agrees (up to permutation) with the Jordan form <code>matrix(QQbar, M).jordan_form()</code> as expected.</p>
<p>In SageMath version 10.4.beta3 as well as 9.5 I can also run <code>M.jordan_form()</code> with no errors thrown; the answer agrees with <code>matrix(QQbar, M).jordan_form()</code>. However, <code>matrix(QQbar, M).jordan_form(transformation=True)</code> and <code>M.jordan_form(transformation=True)</code> do not agree; the latter produces a transformation matrix that is not invertible!</p>
<p>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?</p>
https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77082#post-id-77082This 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())`.Thu, 25 Apr 2024 13:58:53 +0200https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77082#post-id-77082Comment by FrédéricC for <p>Consider the following matrix:</p>
<p><code>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)])</code></p>
<p>The matrix <code>M</code> is diagonalizable. Indeed, let <code>z = exp(i*pi/3)</code>; then <code>M</code> is similar to <code>J = diagonal_matrix([ -1, -1, z, z, z.conjugate(), z.conjugate() ])</code>. For example, one can use <code>matrix(QQbar, M).is_similar(matrix(QQbar, J))</code> 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 <code>M.is_similar(J)</code> and <code>M.diagonalization()</code> raise respectively <code>TypeError</code> and <code>ValueError</code> as expected. Since <code>M</code> is diagonalizable, the diagonalization agrees (up to permutation) with the Jordan form <code>matrix(QQbar, M).jordan_form()</code> as expected.</p>
<p>In SageMath version 10.4.beta3 as well as 9.5 I can also run <code>M.jordan_form()</code> with no errors thrown; the answer agrees with <code>matrix(QQbar, M).jordan_form()</code>. However, <code>matrix(QQbar, M).jordan_form(transformation=True)</code> and <code>M.jordan_form(transformation=True)</code> do not agree; the latter produces a transformation matrix that is not invertible!</p>
<p>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?</p>
https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77079#post-id-77079Looks like a bug. Try to find a smaller instance if you can.Thu, 25 Apr 2024 12:01:48 +0200https://ask.sagemath.org/question/77072/sage-produces-non-invertible-transformation-matrix-to-sr-jordan-form/?comment=77079#post-id-77079