Hermitian representation of a matrix

Hi!

I have the following problem: I have done some computations in order to obtain three 4x4-matrices represented as a 12x4-array, aka a span V of 4 linear independet vectors comming from C^12; these 4 vectors build a basis of my linear space V. From theory I know there should be a very particular basis of this vector space V, such that if I split this 12x4 matrix back into the three 4x4-matrices, these should be Hermitian. What I’m trying to do is the following: I want to force the small matrices to be Hermitian and then by assembling then back together to 12x4 array, check if they still build V and then if yes I’m hopefully done. So I’m wondering if I can “force” somehow my small 4x4 matrices to be Hermitian. What I mean by that: my original 4x4 matrix A is similar to some Hermitian matrix 4x4 B: A = P^{-1}BP with P is a matrix of basis change; is there a way to compute B in Julia, if I know that it exists?

TL;DR: is there a way to compute a Hermitian representation of A if I have A~B, where A is my original nxn matrix, B is a nxn Hermitian matrix and ~ is similarity relation?

Not sure I totally understand what you’re trying to do, but the LinearAlgebra package provides a function ishermitian to check whether a matrix is Hermitian.

using LinearAlgebra
V = ... # calculate somehow
ishermitian(V[1:4, :]) # is first sub-matrix Hermitian?
# All three sub-matrices Hermitian?
all(ishermitian(V[i:i+3, :]) for i in range(1, length=3, step=4))

If the sub-matrices are not quite Hermitian, due to e.g. floating-point error, it also has a Hermitian matrix type, which forces a matrix to be Hermitian by ignoring the lower or upper triangle:

# Force each one to be Hermitian and reconstruct V
Vrecon = vcat([Hermitian(V[i:i+3, :]) for i in range(1, length=3, step=4)]...)

If you need to actually calculate B, and you know what P is, that’s simply

ishermitian(A)
B = P * A * inv(P)

Thanks for your reply, but non of the above help me.

What I need to do is to calculate an invertible P, so that the relation A = inv P B P holds for some hermitian B (from theory such B should exist). I was wondering, if there is some type of standard algorithm already implemented in Julia to do that, something like an SVD, LU or diagonalization etc. Do you know of any?

I’m still not totally clear on what you are trying to accomplish here…a minimum working example (MWE) might help us help you better. Both the SVD and LU decompositions (and many more) are available in LinearAlgebra as svd and lu. You can check out the package documentation here: https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/index.html

Yes: if A is similar to any Hermitian matrix, then it must be diagonalizable with real eigenvalues, i.e. A = X \Lambda X^{-1} where X is the matrix of eigenvectors and \Lambda is the diagonal matrix of eigenvalues (which is Hermitian). So, you could use B = \Lambda and P = X^{-1}. In Julia:

using LinearAlgebra
F = eigen(A)
B = Diagonal(F.values)
P = inv(F.vectors)

Of course, if you know theoretically that A is similar to a Hermitian matrix (how?), the same theory may indicate a simpler change of basis to get a Hermitian (but not diagonal) B. (The choice of B and P is not unique!)

I know that it is similar because of how my initial problem is posed. If you’re interested, see details below (if not, the end is marked):

The existence of such a B comes basically form the fact, that any hyperbolic polynomial f \in C[X,Y,Z] has a hermitian determinantal representation, i.e. one can write f as a determinant of some hermitian matrix: f = det(M(x,y,z)), where M is a hermitian 4x4 matrix of linear forms (homogenous polynomial of degree 1) in three variables x, y, z. M is basically something like xA + yB + zC with some hermitian 4x4 matrices A, B, C over C and such that f = det(M(x, y, z)).
What I did was to compute the first column of the adjuct matrix of M (it’s easier) and then out of the identity M \cdot M^adj = det(M) \cdot I = [f;0;0;0] by coefficient comparision (for that I solved some systems of linear equations Atilde x = b and computed the kernel of the representing matrix Atilde) I ended up with this 4 dimensional vector space V which in a way is just A, B and C stacked upon each other like so: [A;B;C]. And because of the existence of the hermitian determinantal representation (which also satisfies the Atilde x=b from above) I basically know that what I’m looking for must live in V too, i.e. I need some appropriate change of basis of V, so that then [A;B;C] are hermitian. So I’m trying to figure out how to do that. I was thinking about splitting V in A, B and C, force them to be hermitian and figure out how to glue them back together (and if that deglue-ing destroys things at all, I’m not sure, but I suppose it can happen) and then be done, so I’m exploring possibilities.
details end

Thank you for bringing me to eigen, this might help! I’m aware that the choice of B and P is not unique, but thanks for pointing that out. I also can’t make something out of my theory to help me find a suitable basis, because the actual statement is not directly connected to this.