# How to anti-diagonalize a matrix in Mathematica?

Given a matrix M, i.e.:

M = {{0, 0, a, b}, {0, 0, c, d}, {e, f, 0, 0}, {g, h, 0, 0}};


how can I use Mathematica to anti-diagonalize this matrix? By anti-diagonalization I mean a result such as:

res = {{0,0,0,e},{0,0,e,0},{0,e,0,0},{e,0,0,0}}

where the e[i] are the anti-diagonal values which make matrices res and M similar to each other.

EDIT:

Note that:

res.res


{{e e, 0, 0, 0}, {0, e e, 0, 0}, {0, 0, e e, 0}, {0, 0, 0, e e}}

which means that the eigenvalues of res are +Sqrt[ee], -Sqrt[ee], +Sqrt[ee], -Sqrt[ee], which makes the ordering of the anti-diagonal values e[i] in pairs important.

EDIT2:

With the following explicit example we can see that using a characteristic polynomial Det[M-Reverse/@IdentityMatrixx] actually cannot lead to a similar matrix:

M = {{0, 0, 1, 2}, {0, 0, 3, 4}, {5, 6, 0, 0}, {7, 8, 0, 0}};
Eigenvalues[M]
% // N list = x /. Solve[Det[M - Reverse /@ IdentityMatrix x] == 0, x];
Sqrt[(# /. List -> Times &) /@ Subsets[list, {2}] //Expand // Simplify]
% // N We see that none of the resulting pairs Sqrt[e[i]e[j]] are equal to any of the four eigenvalues of M. Therefore, the procedure does not work and we should look for something else.

• What are "antidiagonal eigenvalues"? Are they defined by the existence of a antidiagonal matrix which is similar to $M$? – anderstood Jan 13 '17 at 19:33
• @anderstood Yes, I am just interested in anti-diagonalizing the matrix. The use of a term like "antidiagonal eigenvalues" was unfortunate. I will remove it. – Kagaratsch Jan 13 '17 at 19:58
• Isn't your question about maths more than mathematica? Also, only a "few" matrices are "anti-diagonalizable". For example, if I am not mistaken, no $2\times 2$ matrix $M$ whose diagonal elements are not opposite ($m_{11}\neq -m_{22}$) is "anti-diagonalizable". – anderstood Jan 13 '17 at 20:08
• @anderstood Interesting, I did not know that. At corey979 : You are right, I fixed it. – Kagaratsch Jan 13 '17 at 20:22

Is this what you want?

M = {{0, 0, a, b}, {0, 0, c, d}, {e, f, 0, 0}, {g, h, 0, 0}};

anti1 = SparseArray[Band[{1, 4}, Automatic, {1, -1}] -> x, {4, 4}];

M - anti1 // MatrixForm Solve[Det[M - anti1] == 0, x] • Almost, I would also like to maintain a correct order of the eigenvalues x from top right to bottom left. With a characteristic polynomial we get the values, but not the order? – Kagaratsch Jan 13 '17 at 17:23
• No. First, in the above there are only symbols. How do you want to order them? I mean, consider w and w+z - which one is smaller? Any answer you give I'll falsify by providing some values of w, z. Second, there is no correct order when it comes to diagonalization - the eigenvalues have to correspond to their eigenvectors. Period. The algebra is correct when you place the first eigen-(value AND vector) in the first, second, of 137th column. – corey979 Jan 13 '17 at 17:30
• Finally, if you want the numerical values in some order, you can use ReplaceAll and SortBy to obtain them in that order, and then construct the anti-diagonal matrix. // You'd have to provide a mathematical theory of such anti-eigenvalues and anti-eigenvectors. What relation should the anti-eigenvector matrix obey with the original matrix M? Etc. – corey979 Jan 13 '17 at 17:30
• Aaand - what's the correct order for complex eigenvalues? – corey979 Jan 13 '17 at 17:37
• While for a diagonal matix simultaneous exchange of two rows and columns is a similarity transformation, doing so for an anti-diagonal matrix is not. Label x1,x2,x3,x4 from bottom-left to top-right. To exchange x1<->x2 we have to exchange columns 1<->2 and rows 3<->4. While this is a similarity transformation, it also exchanges x3<->x4. So the order of xi is important, in pairs. – Kagaratsch Jan 13 '17 at 17:37