MATLAB: Matlab/Mupad ignores absolute value when multiplying complex conjugate expressions

eigenvalueshermitian matrix

Hello everyone,
Recently, I recognized that Matlab (as well as Mupad) ignores to take the absolute value when multiplying a variable with its complex conjugate. I'm currently trying to calculate the eigenvalues of an 4 x 4 Hermitian matrix and I believe that this issue results in wrong eigenvalues. Take for example the matrix (now in Mupad):
assume(x, Type::Real)
M := matrix([[0,conjugate(I*x),0,0], [I*x,0,0,0], [0,0,1,conjugate(I*x)], [0,0,I*x,1]])
then the eigenvalues from Mupad are linalg::eigenvalues(M) => {x, 1-x, -x, x+1}. That's wrong! It should be: {|x| 1-|x|, -|x|, x+1}.
Can anyone help ? Thanks.
Best regards
Bernhard

Best Answer

If x is -1, then the eigenvalues returned by MuPAD are -1, 2, 1, 0. The eigenvalues you expected are 1, 0, -1, 2 (assuming you meant |x|+1 as your last expression.) They're the same, just in a different order.
More generally, since both |x| and -|x| are eigenvalues in your list of expected eigenvalues and you told MuPAD it can assume x is real, that's the same as including x and -x in the list of eigenvalues. They'll just be listed in a different order if x is negative. Similarly for real x, 1-|x| and 1+|x| are the same as 1-x and 1+x, just in a different order if x is negative.
Now if you assumed x was Type::Complex, and called:
simplify(linalg::eigenvalues(M))
then the sets {|x|, -|x|} and {x, -x} are NOT necessarily the same but in a different order. In that case, MuPAD knows it cannot eliminate the absolute value signs, and indeed when I make that modification to your assume call the results do include the absolute value signs.