Here is my code:
using LinearAlgebra
a = randn(50,50);
a = (a+a')/2;
println(ishermitian(a))
println(ishermitian(inv(a)))
The output is
True
False
However, the inverse of a Hermitian matrix is supposed to be Hermitian.
Turns out that the non-Hermitian part of inv(a)
is small, so this is a machine precision error. The number maximum(abs.(inv(a)-inv(a)'))
is \sim10^{-14}.
I am using inverse of a particular Hermitian matrix to generate a quantum Hamiltonian, and it needs to be Hermitian. As a check, I am verifying the Hamiltonian is hermitian before running the code.
However, due to the numerical error I mentioned above, there is no way to distinguish between non-hermiticity generated by machine precision errors, and non-hermiticity generated by typo/bugs in my code.
Is there a solution to this problem?